From: Eric Biggers <ebiggers@kernel.org>
To: linux-raid@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Cc: linux-crypto@vger.kernel.org, x86@kernel.org,
linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 3/3] raid6: simplify CPU feature checks
Date: Sun, 25 Oct 2026 12:12:07 -0700 [thread overview]
Message-ID: <20261025191207.86590-4-ebiggers@kernel.org> (raw)
In-Reply-To: <20261025191207.86590-1-ebiggers@kernel.org>
Remove unnecessary checks for features that are prerequisites for other
features, such as AVX which is a prerequisite for AVX2.
(Note: in most cases arch/x86/kernel/cpu/cpuid-deps.c warns about
missing prerequisites rather than enforcing them. This is intentional,
and it does not mean the prerequisites should be checked elsewhere.)
Then, move the raid6_recov_algo_add() lines into the appropriate places
just above so that the same CPU features aren't checked multiple times.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
lib/raid/raid6/x86/pq_arch.h | 51 ++++++++----------------------------
1 file changed, 11 insertions(+), 40 deletions(-)
diff --git a/lib/raid/raid6/x86/pq_arch.h b/lib/raid/raid6/x86/pq_arch.h
index 4a863b253b909..418e4d4a2930f 100644
--- a/lib/raid/raid6/x86/pq_arch.h
+++ b/lib/raid/raid6/x86/pq_arch.h
@@ -16,63 +16,34 @@ extern const struct raid6_recov_calls raid6_recov_ssse3;
extern const struct raid6_recov_calls raid6_recov_avx2;
extern const struct raid6_recov_calls raid6_recov_avx512;
-static inline int raid6_has_avx512(void)
-{
- return boot_cpu_has(X86_FEATURE_AVX2) &&
- boot_cpu_has(X86_FEATURE_AVX) &&
- boot_cpu_has(X86_FEATURE_AVX512F) &&
- boot_cpu_has(X86_FEATURE_AVX512BW) &&
- boot_cpu_has(X86_FEATURE_AVX512VL) &&
- boot_cpu_has(X86_FEATURE_AVX512DQ);
-}
-
-static inline bool raid6_has_avx2(void)
-{
- return boot_cpu_has(X86_FEATURE_AVX2) && boot_cpu_has(X86_FEATURE_AVX);
-}
-
-static inline bool raid6_has_ssse3(void)
-{
- return boot_cpu_has(X86_FEATURE_XMM) &&
- boot_cpu_has(X86_FEATURE_XMM2) &&
- boot_cpu_has(X86_FEATURE_SSSE3);
-}
-
-static inline bool raid6_has_sse2(void)
-{
- return boot_cpu_has(X86_FEATURE_MMX) &&
- boot_cpu_has(X86_FEATURE_FXSR) &&
- boot_cpu_has(X86_FEATURE_XMM) &&
- boot_cpu_has(X86_FEATURE_XMM2);
-}
-
static __always_inline void __init arch_raid6_init(void)
{
- if (raid6_has_avx2()) {
+ if (boot_cpu_has(X86_FEATURE_AVX2)) {
raid6_algo_add(&raid6_avx2x1);
raid6_algo_add(&raid6_avx2x2);
if (IS_ENABLED(CONFIG_X86_64))
raid6_algo_add(&raid6_avx2x4);
- if (raid6_has_avx512()) {
+ if (boot_cpu_has(X86_FEATURE_AVX512BW) &&
+ boot_cpu_has(X86_FEATURE_AVX512VL) &&
+ boot_cpu_has(X86_FEATURE_AVX512DQ)) {
raid6_algo_add(&raid6_avx512x1);
raid6_algo_add(&raid6_avx512x2);
if (IS_ENABLED(CONFIG_X86_64))
raid6_algo_add(&raid6_avx512x4);
+ raid6_recov_algo_add(&raid6_recov_avx512);
+ } else {
+ raid6_recov_algo_add(&raid6_recov_avx2);
}
- } else if (IS_ENABLED(CONFIG_X86_64) || raid6_has_sse2()) {
+ } else if (IS_ENABLED(CONFIG_X86_64) ||
+ boot_cpu_has(X86_FEATURE_XMM2)) {
/* x86_64 can assume SSE2 as baseline */
raid6_algo_add(&raid6_sse2x1);
raid6_algo_add(&raid6_sse2x2);
if (IS_ENABLED(CONFIG_X86_64))
raid6_algo_add(&raid6_sse2x4);
+ if (boot_cpu_has(X86_FEATURE_SSSE3))
+ raid6_recov_algo_add(&raid6_recov_ssse3);
} else {
raid6_algo_add_default();
}
-
- if (raid6_has_avx512())
- raid6_recov_algo_add(&raid6_recov_avx512);
- else if (raid6_has_avx2())
- raid6_recov_algo_add(&raid6_recov_avx2);
- else if (raid6_has_ssse3())
- raid6_recov_algo_add(&raid6_recov_ssse3);
}
--
2.56.0
next prev parent reply other threads:[~2026-10-25 19:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 19:12 [PATCH 0/3] raid: remove obsolete MMX optimized code Eric Biggers
2026-10-25 19:12 ` [PATCH 1/3] xor: " Eric Biggers
2026-10-25 19:12 ` [PATCH 2/3] raid6: " Eric Biggers
2026-10-25 19:12 ` Eric Biggers [this message]
2026-10-26 14:57 ` [PATCH 3/3] raid6: simplify CPU feature checks David Laight
2026-10-26 18:47 ` Eric Biggers
2026-10-26 15:00 ` [PATCH 0/3] raid: remove obsolete MMX optimized code David Laight
2026-10-27 15:07 ` Christoph Hellwig
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=20261025191207.86590-4-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--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
all inboxes | Powered by JetHome®