raid: remove obsolete MMX optimized code
Subsystems (2)
cover raid: remove obsolete MMX optimized code
This series retires 32-bit MMX optimizations for RAID.
Affected CPUs, such as the Pentium MMX and Pentium II, will just fall back to the existing well-tested scalar code instead.
This was the only remaining MMX optimized code in the kernel. MMX optimizations for the much more commonly called functions memcpy(), copy_page(), and clear_page() were already removed years ago by commit c6dbd3e5e69c ("x86/mmx_32: Remove X86_USE_3DNOW"). There are zero MMX optimizations for anything else, like crypto or CRC, which left the RAID code as an outlier.
Patch 3 also cleans up the CPU feature checks in the RAID6 code.
Eric Biggers (3):
xor: remove MMX optimized code
raid6: remove MMX optimized code
raid6: simplify CPU feature checks
lib/raid/raid6/Makefile | 4 - lib/raid/raid6/x86/mmx.c | 118 -------- lib/raid/raid6/x86/pq_arch.h | 69 +---- lib/raid/raid6/x86/sse1.c | 136 --------- lib/raid/xor/Makefile | 2 +- lib/raid/xor/x86/xor-mmx.c | 515 ----------------------------------- lib/raid/xor/x86/xor_arch.h | 5 - 7 files changed, 12 insertions(+), 837 deletions(-) delete mode 100644 lib/raid/raid6/x86/mmx.c delete mode 100644 lib/raid/raid6/x86/sse1.c delete mode 100644 lib/raid/xor/x86/xor-mmx.c
base-commit: 21a7f44fd0765fcc5194130b28767786eba1d1e7
Signature · 1 line
2.56.0
PATCH 1/3 xor: remove obsolete MMX optimized code
The MMX optimized XOR code is used only on 25-year old 32-bit CPUs that lack SSE support -- and only on systems that actually have a RAID array. Those CPUs already have well-tested scalar C fallbacks.
Together with the RAID6 code, it's also the only remaining MMX optimized code in the kernel. MMX optimizations for the much more commonly called functions memcpy(), copy_page(), and clear_page() were already removed years ago by commit c6dbd3e5e69c ("x86/mmx_32: Remove X86_USE_3DNOW").
Remove the MMX optimized XOR code.
--- lib/raid/xor/Makefile | 2 +- lib/raid/xor/x86/xor-mmx.c | 515 ------------------------------------ lib/raid/xor/x86/xor_arch.h | 5 - 3 files changed, 1 insertion(+), 521 deletions(-) delete mode 100644 lib/raid/xor/x86/xor-mmx.c
lib/raid/xor/Makefile +1 -1
@@ -30,7 +30,7 @@ xor-$(CONFIG_RISCV_ISA_V) += riscv/xor.o riscv/xor-glue.o xor-$(CONFIG_SPARC32) += sparc/xor-sparc32.o xor-$(CONFIG_SPARC64) += sparc/xor-sparc64.o sparc/xor-sparc64-glue.o xor-$(CONFIG_S390) += s390/xor.o -xor-$(CONFIG_X86_32) += x86/xor-avx.o x86/xor-sse.o x86/xor-mmx.o +xor-$(CONFIG_X86_32) += x86/xor-avx.o x86/xor-sse.o xor-$(CONFIG_X86_64) += x86/xor-avx.o x86/xor-sse.o x86/xor-avx512.o obj-y += tests/
lib/raid/xor/x86/xor-mmx.c deleted +0 -515
515 lines not on this page · raw message
lib/raid/xor/x86/xor_arch.h +0 -5
@@ -1,8 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ #include <asm/cpufeature.h> -extern struct xor_block_template xor_block_pII_mmx; -extern struct xor_block_template xor_block_p5_mmx;extern struct xor_block_template xor_block_sse;extern struct xor_block_template xor_block_sse_pf64;extern struct xor_block_template xor_block_avx;
@@ -33,9 +31,6 @@ static __always_inline void __init arch_xor_init(void)*/ xor_register (&xor_block_sse);xor_register (&xor_block_sse_pf64); - }else if (boot_cpu_has (X86_FEATURE_MMX )) { -xor_register (&xor_block_pII_mmx); -xor_register (&xor_block_p5_mmx); }else {xor_register (&xor_block_8regs);xor_register (&xor_block_8regs_p);
Signature · 1 line
2.56.0
PATCH 2/3 raid6: remove obsolete MMX optimized code
In reply to Eric BiggersThe MMX optimized RAID6 code is used only on 25-year old 32-bit CPUs that lack SSE2 support -- and only on systems that actually have a RAID array. Those CPUs already have well-tested scalar C fallbacks.
It's also the only remaining MMX optimized code in the kernel. MMX optimizations for the much more commonly called functions memcpy(), copy_page(), and clear_page() were already removed years ago by commit c6dbd3e5e69c ("x86/mmx_32: Remove X86_USE_3DNOW").
Remove the MMX optimized RAID6 code. This includes lib/raid/raid6/x86/sse1.c, which was really an MMX implementation with SSE1 prefetches and non-temporal stores added on top.
--- lib/raid/raid6/Makefile | 4 -- lib/raid/raid6/x86/mmx.c | 118 ------------------------------ lib/raid/raid6/x86/pq_arch.h | 18 ----- lib/raid/raid6/x86/sse1.c | 136 ----------------------------------- 4 files changed, 276 deletions(-) delete mode 100644 lib/raid/raid6/x86/mmx.c delete mode 100644 lib/raid/raid6/x86/sse1.c
lib/raid/raid6/Makefile +0 -4
@@ -38,10 +38,6 @@ raid6_pq-$(CONFIG_RISCV_ISA_V) += riscv/rvv.o \ riscv/recov_rvv.o raid6_pq-$(CONFIG_S390) += s390/s390vx8.o \ s390/recov_s390xc.o -ifeq ($(CONFIG_X86),y) -raid6_pq-$(CONFIG_X86_32) += x86/mmx.o \ - x86/sse1.o -endif raid6_pq-$(CONFIG_X86) += x86/sse2.o \ x86/avx2.o \ x86/avx512.o \
lib/raid/raid6/x86/mmx.c deleted +0 -118
118 lines not on this page · raw message
lib/raid/raid6/x86/pq_arch.h +0 -18
@@ -2,10 +2,6 @@#include <asm/cpufeature.h> -extern const struct raid6_calls raid6_mmxx1; -extern const struct raid6_calls raid6_mmxx2; -extern const struct raid6_calls raid6_sse1x1; -extern const struct raid6_calls raid6_sse1x2;extern const struct raid6_calls raid6_sse2x1;extern const struct raid6_calls raid6_sse2x2;extern const struct raid6_calls raid6_sse2x4;
@@ -50,13 +46,6 @@ static inline bool raid6_has_sse2(void)boot_cpu_has (X86_FEATURE_XMM2 ); } -static inline bool raid6_has_sse1_or_mmxext (void ) -{ -return boot_cpu_has (X86_FEATURE_MMX ) && - (boot_cpu_has (X86_FEATURE_XMM ) || -boot_cpu_has (X86_FEATURE_MMXEXT )); -} - static __always_inline void __init arch_raid6_init(void) {if (raid6_has_avx2 ()) {
@@ -78,13 +67,6 @@ static __always_inline void __init arch_raid6_init(void)raid6_algo_add (&raid6_sse2x4); }else {raid6_algo_add_default (); -if (raid6_has_sse1_or_mmxext ()) { -raid6_algo_add (&raid6_sse1x1); -raid6_algo_add (&raid6_sse1x2); - }else if (boot_cpu_has (X86_FEATURE_MMX )) { -raid6_algo_add (&raid6_mmxx1); -raid6_algo_add (&raid6_mmxx2); - } }if (raid6_has_avx512 ())
lib/raid/raid6/x86/sse1.c deleted +0 -136
136 lines not on this page · raw message
Signature · 1 line
2.56.0
PATCH 3/3 raid6: simplify CPU feature checks
In reply to Eric BiggersRemove 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.
--- lib/raid/raid6/x86/pq_arch.h | 51 ++++++++---------------------------- 1 file changed, 11 insertions(+), 40 deletions(-)
lib/raid/raid6/x86/pq_arch.h +11 -40
@@ -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); }
Signature · 1 line
2.56.0
Re: [PATCH 3/3] raid6: simplify CPU feature checks
Quoted 33 lines · On Sun, 25 Oct 2026 12:12:07 -0700 Eric Biggers <[email protected]> wrote:
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.cwarns 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 <[email protected]>--- lib/raid/raid6/x86/pq_arch.h | 51 ++++++++---------------------------- 1 file changed, 11 insertions(+), 40 deletions(-)lib/raid/raid6/x86/pq_arch.h +1
-2@@ -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 __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 ()) {
lib/raid/raid6/x86/pq_arch.h extern const struct raid6_recov_calls raid6_recov_ssse3; · line 35
Quoted 10 lines
lib/raid/raid6/x86/pq_arch.h +6
-0+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);
Is that right (you haven't changed it)?
You get both the avx2 and axv512 normal algorithms, but only one of the recov ones.
I presume these are added in addition to the generic C code and some startup test decides which is fastest and so used?
David
Quoted 22 lines
lib/raid/raid6/x86/pq_arch.h +4
-8} - }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); }
Re: [PATCH 3/3] raid6: simplify CPU feature checks
Quoted 51 lines · David Laight
Quoted 33 lines · On Sun, 25 Oct 2026 12:12:07 -0700 Eric Biggers <[email protected]> wrote:
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.cwarns 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 <[email protected]>--- lib/raid/raid6/x86/pq_arch.h | 51 ++++++++---------------------------- 1 file changed, 11 insertions(+), 40 deletions(-)lib/raid/raid6/x86/pq_arch.h +1
-2@@ -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 __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 ()) {lib/raid/raid6/x86/pq_arch.h extern const struct raid6_recov_calls raid6_recov_ssse3; · line 35
Quoted 10 lines
lib/raid/raid6/x86/pq_arch.h +6
-0+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);Is that right (you haven't changed it)?
You get both the avx2 and axv512 normal algorithms, but only one of the recov ones.
Quoted 2 lines
I presume these are added in addition to the generic C code and some startup test decides which is fastest and so used?
Yes, it's unchanged from before.
The raid6 library implements runtime benchmark-based selection for struct raid6_algo, but not for struct raid6_recov_algo where only one can be registered. As always, you're welcome to check the code rather than speculate; see lib/raid/raid6/algos.c.
Yes, it's inconsistent. However, changing that is outside the scope of this series. (FWIW, none of the crypto or CRC code uses runtime benchmark-based selection. I think it's not worth it.)
- Eric
Quoted 4 lines · On Sun, 25 Oct 2026 12:12:04 -0700 Eric Biggers <[email protected]> wrote:
This series retires 32-bit MMX optimizations for RAID.
Affected CPUs, such as the Pentium MMX and Pentium II, will just fall back to the existing well-tested scalar code instead.
Seems like a good idea.
I wonder if all that loop unrolling was needed :-)
David
Quoted 29 lines
This was the only remaining MMX optimized code in the kernel. MMX optimizations for the much more commonly called functions
memcpy(),copy_page(), andclear_page()were already removed years ago by commitc6dbd3e5e69c("x86/mmx_32: RemoveX86_USE_3DNOW"). There are zero MMX optimizations for anything else, like crypto or CRC, which left the RAID code as an outlier.Patch 3 also cleans up the CPU feature checks in the RAID6 code.
Eric Biggers (3):
xor: remove MMX optimized code
raid6: remove MMX optimized code
raid6: simplify CPU feature checkslib/raid/raid6/Makefile | 4 - lib/raid/raid6/x86/mmx.c | 118 -------- lib/raid/raid6/x86/pq_arch.h | 69 +---- lib/raid/raid6/x86/sse1.c | 136 --------- lib/raid/xor/Makefile | 2 +- lib/raid/xor/x86/xor-mmx.c | 515 ----------------------------------- lib/raid/xor/x86/xor_arch.h | 5 - 7 files changed, 12 insertions(+), 837 deletions(-) delete mode 100644 lib/raid/raid6/x86/mmx.c delete mode 100644 lib/raid/raid6/x86/sse1.c delete mode 100644 lib/raid/xor/x86/xor-mmx.cbase-commit:
21a7f44fd0765fcc5194130b28767786eba1d1e7
Looks good: