Re: [PATCH 1/2] uapi: Refactor __GENMASK() for speed-up
From: Yury Norov
Date: Tue Feb 11 2025 - 13:44:27 EST
On Tue, Feb 11, 2025 at 01:39:34PM -0500, Yury Norov wrote:
> On Wed, Feb 12, 2025 at 12:24:11AM +0800, I Hsin Cheng wrote:
> > The calculation of "((~_UL(0)) - (_UL(1) << (l)) + 1)" is to generate a
> > bitmask with "l" trailing zeroes, which is equivalent to
> > "(~_UL(0) << (l))".
>
> I used to think that GENMASK() is a compile-time macro. __GENMASK() is
> not, but it has very limited usage through the kernel, all in the uapi.
>
> > Refactor the calculation so the number of arithmetic instruction will be
> > reduced from 3 to 1.
>
> I'd like to look at it! Please share disassembly.
>
> > Signed-off-by: I Hsin Cheng <richard120310@xxxxxxxxx>
> > ---
> > Test is done to show the speed-up we can get from reducing the number of
> > instruction. The test machine runs with 6.9.0-0-generic kernel on x86_64
> > architecture with processor AMD Ryzen 7 5700X3D 8-Core Processor.
>
> So you CC arm maintainers and provide tests against x86_64. Are your
> improvements consistent for arm, power and other arches?
>
> Can you run bloat-o-meter against your change?
Ah, sorry, overlooked you bloat-o-meter results in cover letter.
Anyways, can you provide it for each patch individually?