[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250330190651.GDZ-mWS5RRwsN8Q3g4@fat_crate.local>
Date: Sun, 30 Mar 2025 21:06:51 +0200
From: Borislav Petkov <bp@...en8.de>
To: Ingo Molnar <mingo@...nel.org>
Cc: Uros Bizjak <ubizjak@...il.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH -tip 2/2] x86/hweight: Use POPCNT when available with
X86_NATIVE_CPU option
On Sun, Mar 30, 2025 at 08:47:31PM +0200, Ingo Molnar wrote:
> +#ifdef __POPCNT__
> + asm_inline (ASM_FORCE_CLR "popcntl %[val], %[cnt]"
> + : [cnt] "=&r" (res)
> + : [val] ASM_INPUT_RM (w));
> +#else
> asm_inline (ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
> "call __sw_hweight32",
> ASM_CLR "popcntl %[val], %[cnt]",
> X86_FEATURE_POPCNT)
> : [cnt] "=a" (res), ASM_CALL_CONSTRAINT
> : [val] REG_IN (w));
> -
> +#endif
That ifdeffery.
The alternative only is fine as this is the usual way we do those insns.
The ifdeffery around it is ugly and is pushing it and it would be fine if it
would bring anything but it doesn't. It is making the code ugly for no good
reason whatsoever.
> Which is 3 straightforward lines of assembly code and a straightforward #ifdef.
And they bring what exactly?
I haven't seen anything besides some super minor, completely pointless, hm,
"savings". So much so that the uglification of the function is not worth it in
the *least*.
When I look at that code, I need to wonder now, is the __POPCNT__ defined or
not?
> My main objection is different: if __POPCNT__ isn't defined during the
> kernel build of major Linux distros, then this optimization almost
> doesn't exist to our users. And I don't think it's defined.
Yah, that too.
This whole effort is a total waste of time and energy.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists