[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6ysVBWFRfdFdLlT@thinkpad>
Date: Wed, 12 Feb 2025 09:12:36 -0500
From: Yury Norov <yury.norov@...il.com>
To: I Hsin Cheng <richard120310@...il.com>
Cc: David Laight <david.laight.linux@...il.com>, anshuman.khandual@....com,
arnd@...db.de, linux-kernel@...r.kernel.org, jserv@...s.ncku.edu.tw,
Andrew Morton <akpm@...ux-foundation.org>,
Matthias Kaehlcke <mka@...omium.org>, skhan@...uxfoundation.org
Subject: Re: [PATCH 2/2] uapi: Refactor __GENMASK_ULL() for speed-up
+ Matthias, Andrew
On Wed, Feb 12, 2025 at 08:39:09PM +0800, I Hsin Cheng wrote:
> On Tue, Feb 11, 2025 at 10:30:45PM +0000, David Laight wrote:
> > On Wed, 12 Feb 2025 00:24:12 +0800
> > I Hsin Cheng <richard120310@...il.com> wrote:
> >
> > > The calculation of "((~_ULL(0)) - (_ULL(1) << (l)) + 1)" is to generate
> > > a bitmask with "l" trailing zeroes, which is equivalent to
> > > "(~_ULL(0) << (l))".
> >
> > Yes, and if you look through the commit history you'll see it was changed
> > to avoid a compiler warning about the shift losing significant bits.
> > So you are just reverting that change and the compiler warnings will
> > reappear.
> > For non-constants I suspect that (2ul << hi) - (1ul << lo) is the
> > best answer.
> > But the compiler (clang with some options?) will still complain
> > for constants when trying to set the high bit.
> >
> > That version also doesn't need BITS_PER_[U]LONG.
> > While that is valid for C, the _ULL() are there for the assembler
> > (when they are no-ops) so there is no way asm copies can be right
> > for both GENMASK() ans GENMASK_ULL().
> >
> > David
>
> Hi David,
>
> Thanks for the review!
>
> > Yes, and if you look through the commit history you'll see it was changed
> > to avoid a compiler warning about the shift losing significant bits.
>
> I've browse through the commits of include/linux/bits.h , where
> GENMASK() was placed under. Though I didn't find specific commit of it,
> would you be so kind to paste the link of the commit?
It's c32ee3d9abd284b4f ("bitops: avoid integer overflow in GENMASK(_ULL)").
[From cover letter]
> $ ./scripts/bloat-o-meter vmlinux_old vmlinux_new
> add/remove: 0/2 grow/shrink: 46/510 up/down: 464/-1733 (-1269)
You can see, Andrew tested it and found no changes in .text size. If that
has changed, we need to revert the original patch and suppress warning.
Can you please print the full bloat-o-meter result? Which compiler(s) did
you try?
Thanks,
Yury
Powered by blists - more mailing lists