raid6: move to lib/raid/

Move the raid6 code to live in lib/raid/ with the XOR code, and change the
internal organization so that each architecture has a subdirectory similar
to the CRC, crypto and XOR libraries, and fix up the Makefile to only
build files actually needed.

Also move the kunit test case from the history test/ subdirectory to
tests/ and use the normal naming scheme for it.

Link: https://lore.kernel.org/20260518051804.462141-4-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Ard Biesheuvel <ardb@kernel.org> # kunit only on arm64
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Mason <clm@fb.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Li Nan <linan122@huawei.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Song Liu <song@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Christoph Hellwig
2026-05-18 07:17:46 +02:00
committed by Andrew Morton
parent 3d6beb659d
commit 3626738bc7
38 changed files with 149 additions and 131 deletions

View File

@@ -24823,7 +24823,7 @@ F: drivers/md/md*
F: drivers/md/raid*
F: include/linux/raid/
F: include/uapi/linux/raid/
F: lib/raid6/
F: lib/raid/raid6/
SOLIDRUN CLEARFOG SUPPORT
M: Russell King <linux@armlinux.org.uk>

View File

@@ -8,28 +8,6 @@ config BINARY_PRINTF
menu "Library routines"
config RAID6_PQ
tristate
config RAID6_PQ_KUNIT_TEST
tristate "KUnit tests for RAID6 PQ functions" if !KUNIT_ALL_TESTS
depends on KUNIT
depends on RAID6_PQ
default KUNIT_ALL_TESTS
help
Unit tests for the RAID6 PQ library functions.
This is intended to help people writing architecture-specific
optimized versions. If unsure, say N.
config RAID6_PQ_BENCHMARK
bool "Automatically choose fastest RAID6 PQ functions"
depends on RAID6_PQ
default y
help
Benchmark all available RAID6 PQ functions on init and choose the
fastest one.
config LINEAR_RANGES
tristate

View File

@@ -167,7 +167,6 @@ obj-$(CONFIG_LZ4_DECOMPRESS) += lz4/
obj-$(CONFIG_ZSTD_COMPRESS) += zstd/
obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd/
obj-$(CONFIG_XZ_DEC) += xz/
obj-$(CONFIG_RAID6_PQ) += raid6/
lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o

View File

@@ -28,3 +28,25 @@ config XOR_KUNIT_TEST
This is intended to help people writing architecture-specific
optimized versions. If unsure, say N.
config RAID6_PQ
tristate
config RAID6_PQ_KUNIT_TEST
tristate "KUnit tests for RAID6 PQ functions" if !KUNIT_ALL_TESTS
depends on KUNIT
depends on RAID6_PQ
default KUNIT_ALL_TESTS
help
Unit tests for the RAID6 PQ library functions.
This is intended to help people writing architecture-specific
optimized versions. If unsure, say N.
config RAID6_PQ_BENCHMARK
bool "Automatically choose fastest RAID6 PQ functions"
depends on RAID6_PQ
default y
help
Benchmark all available RAID6 PQ functions on init and choose the
fastest one.

View File

@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-y += xor/
obj-y += xor/ raid6/

122
lib/raid/raid6/Makefile Normal file
View File

@@ -0,0 +1,122 @@
# SPDX-License-Identifier: GPL-2.0
ccflags-y += -I $(src)
obj-$(CONFIG_RAID6_PQ) += raid6_pq.o tests/
raid6_pq-y += algos.o tables.o
# generic integer generation and recovery implementation
raid6_pq-y += int1.o int2.o int4.o int8.o
raid6_pq-y += recov.o
# architecture-specific generation and recovery implementations:
raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += arm/neon.o \
arm/neon1.o \
arm/neon2.o \
arm/neon4.o \
arm/neon8.o \
arm/recov_neon.o \
arm/recov_neon_inner.o
raid6_pq-$(CONFIG_LOONGARCH) += loongarch/loongarch_simd.o \
loongarch/recov_loongarch_simd.o
raid6_pq-$(CONFIG_ALTIVEC) += powerpc/altivec1.o \
powerpc/altivec2.o \
powerpc/altivec4.o \
powerpc/altivec8.o \
powerpc/vpermxor1.o \
powerpc/vpermxor2.o \
powerpc/vpermxor4.o \
powerpc/vpermxor8.o
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 \
x86/recov_ssse3.o \
x86/recov_avx2.o \
x86/recov_avx512.o
hostprogs += mktables
CFLAGS_arm/neon1.o += $(CC_FLAGS_FPU)
CFLAGS_arm/neon2.o += $(CC_FLAGS_FPU)
CFLAGS_arm/neon4.o += $(CC_FLAGS_FPU)
CFLAGS_arm/neon8.o += $(CC_FLAGS_FPU)
CFLAGS_arm/recov_neon_inner.o += $(CC_FLAGS_FPU)
CFLAGS_REMOVE_arm/neon1.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_arm/neon2.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_arm/neon4.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_arm/neon8.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_arm/recov_neon_inner.o += $(CC_FLAGS_NO_FPU)
ifeq ($(CONFIG_ALTIVEC),y)
altivec_flags := -maltivec $(call cc-option,-mabi=altivec)
# Enable <altivec.h>
altivec_flags += -isystem $(shell $(CC) -print-file-name=include)
CFLAGS_powerpc/altivec1.o += $(altivec_flags)
CFLAGS_powerpc/altivec2.o += $(altivec_flags)
CFLAGS_powerpc/altivec4.o += $(altivec_flags)
CFLAGS_powerpc/altivec8.o += $(altivec_flags)
CFLAGS_powerpc/vpermxor1.o += $(altivec_flags)
CFLAGS_powerpc/vpermxor2.o += $(altivec_flags)
CFLAGS_powerpc/vpermxor4.o += $(altivec_flags)
CFLAGS_powerpc/vpermxor8.o += $(altivec_flags)
ifdef CONFIG_CC_IS_CLANG
# clang ppc port does not yet support -maltivec when -msoft-float is
# enabled. A future release of clang will resolve this
# https://llvm.org/pr31177
CFLAGS_REMOVE_powerpc/altivec1.o += -msoft-float
CFLAGS_REMOVE_powerpc/altivec2.o += -msoft-float
CFLAGS_REMOVE_powerpc/altivec4.o += -msoft-float
CFLAGS_REMOVE_powerpc/altivec8.o += -msoft-float
CFLAGS_REMOVE_powerpc/vpermxor1.o += -msoft-float
CFLAGS_REMOVE_powerpc/vpermxor2.o += -msoft-float
CFLAGS_REMOVE_powerpc/vpermxor4.o += -msoft-float
CFLAGS_REMOVE_powerpc/vpermxor8.o += -msoft-float
endif # CONFIG_CC_IS_CLANG
endif # CONFIG_ALTIVEC
quiet_cmd_mktable = TABLE $@
cmd_mktable = $(obj)/mktables > $@
targets += tables.c
$(obj)/tables.c: $(obj)/mktables FORCE
$(call if_changed,mktable)
quiet_cmd_unroll = UNROLL $@
cmd_unroll = $(AWK) -v N=$* -f $(src)/unroll.awk < $< > $@
targets += int1.c int2.c int4.c int8.c
$(obj)/int%.c: $(src)/int.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
targets += arm/neon1.c arm/neon2.c arm/neon4.c arm/neon8.c
$(obj)/arm/neon%.c: $(src)/arm/neon.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
targets += powerpc/altivec1.c \
powerpc/altivec2.c \
powerpc/altivec4.c \
powerpc/altivec8.c
$(obj)/powerpc/altivec%.c: $(src)/powerpc/altivec.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
targets += powerpc/vpermxor1.c \
powerpc/vpermxor2.c \
powerpc/vpermxor4.c \
powerpc/vpermxor8.c
$(obj)/powerpc/vpermxor%.c: $(src)/powerpc/vpermxor.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
targets += s390/s390vx8.c
$(obj)/s390/s390vx%.c: $(src)/s390/s390vx.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)

View File

@@ -25,7 +25,7 @@
*/
#include <arm_neon.h>
#include "neon.h"
#include "arm/neon.h"
typedef uint8x16_t unative_t;

View File

@@ -6,7 +6,7 @@
#include <linux/raid/pq.h>
#include <asm/simd.h>
#include "neon.h"
#include "arm/neon.h"
static int raid6_has_neon(void)
{

View File

@@ -5,7 +5,7 @@
*/
#include <arm_neon.h>
#include "neon.h"
#include "arm/neon.h"
#ifdef CONFIG_ARM
/*

View File

@@ -24,8 +24,6 @@
#include <linux/raid/pq.h>
#ifdef CONFIG_ALTIVEC
#include <altivec.h>
#include <asm/cputable.h>
#include <asm/switch_to.h>
@@ -122,5 +120,3 @@ const struct raid6_calls raid6_altivec$# = {
"altivecx$#",
0
};
#endif /* CONFIG_ALTIVEC */

View File

@@ -21,8 +21,6 @@
*/
#include <linux/raid/pq.h>
#ifdef CONFIG_ALTIVEC
#include <altivec.h>
#include <asm/ppc-opcode.h>
#include <asm/cputable.h>
@@ -95,4 +93,3 @@ const struct raid6_calls raid6_vpermxor$# = {
"vpermxor$#",
0
};
#endif

View File

@@ -1,5 +1,3 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_RAID6_PQ_KUNIT_TEST) += raid6_kunit.o
raid6_kunit-y += test.o

View File

@@ -11,8 +11,6 @@
* MMX implementation of RAID-6 syndrome functions
*/
#ifdef CONFIG_X86_32
#include <linux/raid/pq.h>
#include <asm/fpu/api.h>
@@ -135,5 +133,3 @@ const struct raid6_calls raid6_mmxx2 = {
"mmxx2",
0
};
#endif

View File

@@ -16,8 +16,6 @@
* worthwhile as a separate implementation.
*/
#ifdef CONFIG_X86_32
#include <linux/raid/pq.h>
#include <asm/fpu/api.h>
@@ -155,5 +153,3 @@ const struct raid6_calls raid6_sse1x2 = {
"sse1x2",
1 /* Has cache hints */
};
#endif

View File

@@ -1,83 +0,0 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_RAID6_PQ) += raid6_pq.o test/
raid6_pq-y += algos.o recov.o tables.o int1.o int2.o int4.o \
int8.o
raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o avx512.o recov_avx512.o
raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o \
vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o
raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
raid6_pq-$(CONFIG_S390) += s390vx8.o recov_s390xc.o
raid6_pq-$(CONFIG_LOONGARCH) += loongarch_simd.o recov_loongarch_simd.o
raid6_pq-$(CONFIG_RISCV_ISA_V) += rvv.o recov_rvv.o
hostprogs += mktables
ifeq ($(CONFIG_ALTIVEC),y)
altivec_flags := -maltivec $(call cc-option,-mabi=altivec)
# Enable <altivec.h>
altivec_flags += -isystem $(shell $(CC) -print-file-name=include)
ifdef CONFIG_CC_IS_CLANG
# clang ppc port does not yet support -maltivec when -msoft-float is
# enabled. A future release of clang will resolve this
# https://llvm.org/pr31177
CFLAGS_REMOVE_altivec1.o += -msoft-float
CFLAGS_REMOVE_altivec2.o += -msoft-float
CFLAGS_REMOVE_altivec4.o += -msoft-float
CFLAGS_REMOVE_altivec8.o += -msoft-float
CFLAGS_REMOVE_vpermxor1.o += -msoft-float
CFLAGS_REMOVE_vpermxor2.o += -msoft-float
CFLAGS_REMOVE_vpermxor4.o += -msoft-float
CFLAGS_REMOVE_vpermxor8.o += -msoft-float
endif
endif
quiet_cmd_unroll = UNROLL $@
cmd_unroll = $(AWK) -v N=$* -f $(src)/unroll.awk < $< > $@
targets += int1.c int2.c int4.c int8.c
$(obj)/int%.c: $(src)/int.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
CFLAGS_altivec1.o += $(altivec_flags)
CFLAGS_altivec2.o += $(altivec_flags)
CFLAGS_altivec4.o += $(altivec_flags)
CFLAGS_altivec8.o += $(altivec_flags)
targets += altivec1.c altivec2.c altivec4.c altivec8.c
$(obj)/altivec%.c: $(src)/altivec.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
CFLAGS_vpermxor1.o += $(altivec_flags)
CFLAGS_vpermxor2.o += $(altivec_flags)
CFLAGS_vpermxor4.o += $(altivec_flags)
CFLAGS_vpermxor8.o += $(altivec_flags)
targets += vpermxor1.c vpermxor2.c vpermxor4.c vpermxor8.c
$(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
CFLAGS_neon1.o += $(CC_FLAGS_FPU)
CFLAGS_neon2.o += $(CC_FLAGS_FPU)
CFLAGS_neon4.o += $(CC_FLAGS_FPU)
CFLAGS_neon8.o += $(CC_FLAGS_FPU)
CFLAGS_recov_neon_inner.o += $(CC_FLAGS_FPU)
CFLAGS_REMOVE_neon1.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_neon2.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_neon4.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_neon8.o += $(CC_FLAGS_NO_FPU)
CFLAGS_REMOVE_recov_neon_inner.o += $(CC_FLAGS_NO_FPU)
targets += neon1.c neon2.c neon4.c neon8.c
$(obj)/neon%.c: $(src)/neon.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
targets += s390vx8.c
$(obj)/s390vx%.c: $(src)/s390vx.uc $(src)/unroll.awk FORCE
$(call if_changed,unroll)
quiet_cmd_mktable = TABLE $@
cmd_mktable = $(obj)/mktables > $@
targets += tables.c
$(obj)/tables.c: $(obj)/mktables FORCE
$(call if_changed,mktable)

View File

@@ -1,3 +0,0 @@
/int.uc
/neon.uc
/raid6test