From: Borislav Petkov <bp@alien8.de>
To: Ingo Molnar <mingo@kernel.org>
Cc: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andy Lutomirski <luto@amacapital.net>,
Herbert Xu <herbert@gondor.apana.org.au>,
Matt Mackall <mpm@selenic.com>, Chris Mason <clm@fb.com>,
Josef Bacik <jbacik@fb.com>, David Sterba <dsterba@suse.com>
Subject: Re: [RFC PATCH 3/3] x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros
Date: Wed, 18 Nov 2015 19:23:04 +0100 [thread overview]
Message-ID: <20151118182304.GG4138@pd.tnic> (raw)
In-Reply-To: <20151110123000.GA20227@gmail.com>
On Tue, Nov 10, 2015 at 01:30:00PM +0100, Ingo Molnar wrote:
>
> * Borislav Petkov <bp@alien8.de> wrote:
>
> > From: Borislav Petkov <bp@suse.de>
> >
> > Those are stupid and code should use static_cpu_has_safe() anyway. Kill
> > the least used and unused ones.
>
> So cpufeature.h doesn't really do a good job of explaining what the difference is
> between all these variants:
How's that for starters?
---
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index 27ab2e7d14c4..a9a8313e278e 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -351,6 +351,10 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
(((bit)>>5)==8 && (1UL<<((bit)&31) & DISABLED_MASK8)) || \
(((bit)>>5)==9 && (1UL<<((bit)&31) & DISABLED_MASK9)) )
+/*
+ * Test whether the CPU represented by descriptor @c has the feature bit @bit
+ * set.
+ */
#define cpu_has(c, bit) \
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
test_cpu_cap(c, bit))
@@ -416,11 +420,6 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
extern void warn_pre_alternatives(void);
extern bool __static_cpu_has_safe(u16 bit);
-/*
- * Static testing of CPU features. Used the same as boot_cpu_has().
- * These are only valid after alternatives have run, but will statically
- * patch the target code for additional performance.
- */
static __always_inline __pure bool __static_cpu_has(u16 bit)
{
#ifdef CC_HAVE_ASM_GOTO
@@ -495,6 +494,18 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
#endif /* CC_HAVE_ASM_GOTO */
}
+/*
+ * Test whether the boot CPU has feature bit @bit enabled.
+ *
+ * This is static testing of CPU features. It is used in the same manner as
+ * boot_cpu_has(). It is differs from the previous one in that the alternatives
+ * infrastructure will statically patch the code where the test is performed for
+ * additional performance.
+ *
+ * However, results from that macro are only valid after the alternatives have
+ * run and not before that. IOW, you want static_cpu_has_safe() instead, see
+ * below.
+ */
#define static_cpu_has(bit) \
( \
__builtin_constant_p(boot_cpu_has(bit)) ? \
@@ -580,6 +591,11 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
#endif /* CC_HAVE_ASM_GOTO */
}
+/*
+ * Like static_cpu_has() above but it works even before the alternatives have
+ * run by falling back to boot_cpu_has(). You should use that macro for all your
+ * CPU feature bit testing needs.
+ */
#define static_cpu_has_safe(bit) \
( \
__builtin_constant_p(boot_cpu_has(bit)) ? \
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
next prev parent reply other threads:[~2015-11-18 18:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 11:48 [RFC PATCH 0/3] x86/cpufeature: Cleanup stuff Borislav Petkov
2015-11-10 11:48 ` [RFC PATCH 1/3] x86/cpufeature: Move some of the scattered feature bits to x86_capability Borislav Petkov
2015-11-10 11:48 ` [RFC PATCH 2/3] x86/cpufeature: Cleanup get_cpu_cap() Borislav Petkov
2015-11-10 11:48 ` [RFC PATCH 3/3] x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros Borislav Petkov
2015-11-10 11:57 ` David Sterba
2015-11-10 12:30 ` Ingo Molnar
2015-11-10 12:37 ` Borislav Petkov
2015-11-18 18:23 ` Borislav Petkov [this message]
2015-11-24 13:05 ` Borislav Petkov
2015-11-24 22:42 ` Josh Triplett
2015-11-25 0:10 ` Andy Lutomirski
2015-11-25 2:58 ` Josh Triplett
2015-11-27 13:52 ` Borislav Petkov
2015-11-27 18:04 ` Borislav Petkov
2015-11-27 20:13 ` Josh Triplett
2015-11-27 20:23 ` Borislav Petkov
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=20151118182304.GG4138@pd.tnic \
--to=bp@alien8.de \
--cc=a.p.zijlstra@chello.nl \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=herbert@gondor.apana.org.au \
--cc=jbacik@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=mpm@selenic.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.