From: Ingo Molnar <mingo@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: Uros Bizjak <ubizjak@gmail.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH -tip 2/2] x86/hweight: Use POPCNT when available with X86_NATIVE_CPU option
Date: Sun, 30 Mar 2025 21:20:28 +0200 [thread overview]
Message-ID: <Z-mZfCvep7iMrqoU@gmail.com> (raw)
In-Reply-To: <20250330190651.GDZ-mWS5RRwsN8Q3g4@fat_crate.local>
* Borislav Petkov <bp@alien8.de> wrote:
> 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.
Tangible code size reduction, if it can be realized, is definitely
'something', so your claim is simply false.
> > 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*.
Even 0.5K of .text reduction is a tangible benefit.
The kernel's 35 years long history comprises of literally over a
million patches, which were small and inconsequential 99% of the time.
> > 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.
We don't know yet for sure, but I don't think an absolutist "can't do"
approach is very productive.
Thanks,
Ingo
next prev parent reply other threads:[~2025-03-30 19:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 16:48 [PATCH -tip 1/2] x86/hweight: Fix false output register dependency of POPCNT insn Uros Bizjak
2025-03-25 16:48 ` [PATCH -tip 2/2] x86/hweight: Use POPCNT when available with X86_NATIVE_CPU option Uros Bizjak
2025-03-25 17:11 ` Borislav Petkov
2025-03-30 15:15 ` Uros Bizjak
2025-03-30 17:31 ` Borislav Petkov
2025-03-30 18:47 ` Ingo Molnar
2025-03-30 19:06 ` Borislav Petkov
2025-03-30 19:20 ` Ingo Molnar [this message]
2025-03-30 19:28 ` Borislav Petkov
2025-03-25 21:56 ` Ingo Molnar
2025-03-29 9:19 ` Uros Bizjak
2025-03-29 11:00 ` David Laight
2025-03-30 7:49 ` Uros Bizjak
2025-03-30 18:02 ` David Laight
2025-03-29 23:10 ` H. Peter Anvin
2025-03-30 6:54 ` Uros Bizjak
2025-03-30 9:56 ` Ingo Molnar
2025-03-30 16:07 ` Uros Bizjak
2025-03-30 18:15 ` David Laight
2025-03-30 22:44 ` H. Peter Anvin
2025-03-30 18:54 ` Ingo Molnar
2025-03-25 17:09 ` [PATCH -tip 1/2] x86/hweight: Fix false output register dependency of POPCNT insn Borislav Petkov
2025-03-25 17:17 ` Uros Bizjak
2025-03-25 17:44 ` Borislav Petkov
2025-03-25 21:50 ` Ingo Molnar
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=Z-mZfCvep7iMrqoU@gmail.com \
--to=mingo@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=ubizjak@gmail.com \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.