From: Yury Norov <yury.norov@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: Re: [GIT PULL] Bitmap patches for v5.19-rc1
Date: Tue, 31 May 2022 18:15:56 -0700 [thread overview]
Message-ID: <Ypa9zOfLPbcfpOgb@yury-laptop> (raw)
In-Reply-To: <CAHk-=whTKRaz0j+cwkbLe6CEc1XWp45CLQESOqqGnRiaU1UsMQ@mail.gmail.com>
On Fri, May 27, 2022 at 09:17:21PM -0700, Linus Torvalds wrote:
> On Fri, May 27, 2022 at 8:44 AM Yury Norov <yury.norov@gmail.com> wrote:
> >
> > bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions
>
> So honestly, I pulled this, looked at the code, and then unpulled it again.
>
> This is not helping.
>
> Making changes like this:
>
> - if (mm != current->active_mm || cpumask_weight(mm_cpumask(mm)) != 1) {
> + if (mm != current->active_mm || !cpumask_weight_eq(mm_cpumask(mm), 1)) {
>
> only makes the code harder to understand.
>
> And it gets worse:
>
> - if (cpumask_weight(mask) > cpumask_weight(sibling_mask(cpu)))
> + if (cpumask_weight_gt(mask, cpumask_weight(sibling_mask(cpu))))
>
> is just disgusting. That original line is simple to read and makes
> sense. That new replacement really makes you do "Whaa?"
>
> Now, I understand that these kinds of helper functions could make for
> slightly more efficient code in that you can break out of the bitmap
> scanning early when you have found enough bits set. I get it.
>
> BUT.
>
> (a) code legibility is really really important
>
> (b) the places I found this weren't that performance-critical.
>
> (c) in most cases, the bitmaps in question are one single word
>
> so I'm unpulling this again.
>
> Now, some other parts of the pull were clear improvements. For
> example, the hyperv changes like this:
>
> - if (hc->var_cnt != bitmap_weight((unsigned long
> *)&valid_bank_mask, 64))
> + if (hc->var_cnt != hweight64(valid_bank_mask))
>
> were clear improvements where the old code was disgusting, and clearly
> improved by the change.
>
> But the "bitmap_weight_cmp()" functions (and the cpumask_weight_cmp()
> ones) are just not a direction we want to go.
>
> The special case of zero (ie "cpumask_weight() == 0" ->
> "bitmap_empty()") is one thing: making that kind of change tends to
> keep the code legible or even make it more understandable. So I didn't
> mind that. But I do mind the pointlessly complex new arbitrary weight
> comparisons, and the kind of mental cost they have.
>
> There are people in the CS world that think "abstractions are always
> good". Those people are very very wrong.
Ok, I'll send a new pull with all but bitmap_weight_cmp() patches.
next prev parent reply other threads:[~2022-06-01 1:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 15:43 Yury Norov
2022-05-28 4:17 ` Linus Torvalds
2022-06-01 1:15 ` Yury Norov [this message]
2022-06-03 19:46 Yury Norov
2022-06-04 21:20 ` pr-tracker-bot
2022-06-04 21:24 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Ypa9zOfLPbcfpOgb@yury-laptop \
--to=yury.norov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®