From: Peter Zijlstra <peterz@infradead.org>
To: Borislav Petkov <bp@alien8.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Nadav Amit <nadav.amit@gmail.com>,
Andy Lutomirski <luto@amacapital.net>,
x86@kernel.org
Subject: Re: [PATCH 1/5] x86/asm: Clarify static_cpu_has()'s intended use
Date: Mon, 1 Apr 2019 10:06:23 +0200 [thread overview]
Message-ID: <20190401080623.GC11158@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190330112022.28888-2-bp@alien8.de>
On Sat, Mar 30, 2019 at 12:20:18PM +0100, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
>
> Clarify when one should use static_cpu_has() and when one should use
> boot_cpu_has().
>
> Requested-by: Nadav Amit <nadav.amit@gmail.com>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> Cc: x86@kernel.org
> ---
> arch/x86/include/asm/cpufeature.h | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
> index 30cf12c81db3..1d337c51f7e6 100644
> --- a/arch/x86/include/asm/cpufeature.h
> +++ b/arch/x86/include/asm/cpufeature.h
> @@ -156,9 +156,12 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit);
> #else
>
> /*
> - * Static testing of CPU features. Used the same as boot_cpu_has().
> - * These will statically patch the target code for additional
> - * performance.
> + * Static testing of CPU features. Used the same as boot_cpu_has(). It
> + * statically patches the target code for additional performance. Use
> + * static_cpu_has() only in fast paths, where every cycle counts. Which
> + * means that the boot_cpu_has() variant is already fast enough for the
> + * majority of cases and you should stick to using it as it is generally
> + * only two instructions: a RIP-relative MOV and a TEST.
> */
> static __always_inline bool _static_cpu_has(u16 bit)
> {
Should we introduce cpu_has() ?
I'm sure it boot_cpu_has() is an awesome name, but in like 99.9% of the
cases we don't give a crap about which actual CPU has the feature set. We
also don't actually support asymmetric cpu features anyway.
next prev parent reply other threads:[~2019-04-01 8:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-30 11:20 [PATCH 0/5] x86/asm: Remove some static_cpu_has() usage Borislav Petkov
2019-03-30 11:20 ` [PATCH 1/5] x86/asm: Clarify static_cpu_has()'s intended use Borislav Petkov
2019-04-01 8:06 ` Peter Zijlstra [this message]
2019-04-08 14:29 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2019-03-30 11:20 ` [PATCH 2/5] x86: Convert some slow-path static_cpu_has() callers to boot_cpu_has() Borislav Petkov
2019-03-30 12:47 ` Rik van Riel
2019-03-30 12:50 ` Juergen Gross
2019-04-08 14:29 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2019-03-30 11:20 ` [PATCH 3/5] x86/kvm: " Borislav Petkov
2019-03-31 14:20 ` Paolo Bonzini
2019-03-31 15:12 ` Borislav Petkov
2019-04-01 7:24 ` Paolo Bonzini
2019-04-01 7:33 ` Borislav Petkov
2019-03-30 11:20 ` [PATCH 4/5] x86/mm: " Borislav Petkov
2019-04-08 14:30 ` [tip:x86/asm] " tip-bot for Borislav Petkov
2019-03-30 11:20 ` [PATCH 5/5] drivers/cpufreq: " Borislav Petkov
2019-04-01 9:31 ` Rafael J. Wysocki
2019-04-01 9:32 ` Rafael J. Wysocki
2019-04-01 12:48 ` Borislav Petkov
2019-04-01 21:34 ` Rafael J. Wysocki
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=20190401080623.GC11158@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=nadav.amit@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox