diff options
Diffstat (limited to 'lib/raid6')
| -rw-r--r-- | lib/raid6/algos.c | 78 | ||||
| -rw-r--r-- | lib/raid6/avx2.c | 8 | ||||
| -rw-r--r-- | lib/raid6/avx512.c | 6 | ||||
| -rw-r--r-- | lib/raid6/test/Makefile | 4 | ||||
| -rw-r--r-- | lib/raid6/test/test.c | 1 | ||||
| -rw-r--r-- | lib/raid6/vpermxor.uc | 2 | 
6 files changed, 49 insertions, 50 deletions
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index 6d5e5000fdd7..39b74221f4a7 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c @@ -145,13 +145,13 @@ static inline const struct raid6_recov_calls *raid6_choose_recov(void)  static inline const struct raid6_calls *raid6_choose_gen(  	void *(*const dptrs)[RAID6_TEST_DISKS], const int disks)  { -	unsigned long perf, bestgenperf, bestxorperf, j0, j1; +	unsigned long perf, bestgenperf, j0, j1;  	int start = (disks>>1)-1, stop = disks-3;	/* work on the second half of the disks */  	const struct raid6_calls *const *algo;  	const struct raid6_calls *best; -	for (bestgenperf = 0, bestxorperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) { -		if (!best || (*algo)->prefer >= best->prefer) { +	for (bestgenperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) { +		if (!best || (*algo)->priority >= best->priority) {  			if ((*algo)->valid && !(*algo)->valid())  				continue; @@ -180,50 +180,48 @@ static inline const struct raid6_calls *raid6_choose_gen(  			pr_info("raid6: %-8s gen() %5ld MB/s\n", (*algo)->name,  				(perf * HZ * (disks-2)) >>  				(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2)); +		} +	} -			if (!(*algo)->xor_syndrome) -				continue; +	if (!best) { +		pr_err("raid6: Yikes! No algorithm found!\n"); +		goto out; +	} -			perf = 0; +	raid6_call = *best; -			preempt_disable(); -			j0 = jiffies; -			while ((j1 = jiffies) == j0) -				cpu_relax(); -			while (time_before(jiffies, -					    j1 + (1<<RAID6_TIME_JIFFIES_LG2))) { -				(*algo)->xor_syndrome(disks, start, stop, -						      PAGE_SIZE, *dptrs); -				perf++; -			} -			preempt_enable(); - -			if (best == *algo) -				bestxorperf = perf; +	if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) { +		pr_info("raid6: skipped pq benchmark and selected %s\n", +			best->name); +		goto out; +	} -			pr_info("raid6: %-8s xor() %5ld MB/s\n", (*algo)->name, -				(perf * HZ * (disks-2)) >> -				(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2 + 1)); +	pr_info("raid6: using algorithm %s gen() %ld MB/s\n", +		best->name, +		(bestgenperf * HZ * (disks - 2)) >> +		(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2)); + +	if (best->xor_syndrome) { +		perf = 0; + +		preempt_disable(); +		j0 = jiffies; +		while ((j1 = jiffies) == j0) +			cpu_relax(); +		while (time_before(jiffies, +				   j1 + (1 << RAID6_TIME_JIFFIES_LG2))) { +			best->xor_syndrome(disks, start, stop, +					   PAGE_SIZE, *dptrs); +			perf++;  		} -	} +		preempt_enable(); -	if (best) { -		if (IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) { -			pr_info("raid6: using algorithm %s gen() %ld MB/s\n", -				best->name, -				(bestgenperf * HZ * (disks-2)) >> -				(20 - PAGE_SHIFT+RAID6_TIME_JIFFIES_LG2)); -			if (best->xor_syndrome) -				pr_info("raid6: .... xor() %ld MB/s, rmw enabled\n", -					(bestxorperf * HZ * (disks-2)) >> -					(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2 + 1)); -		} else -			pr_info("raid6: skip pq benchmark and using algorithm %s\n", -				best->name); -		raid6_call = *best; -	} else -		pr_err("raid6: Yikes!  No algorithm found!\n"); +		pr_info("raid6: .... xor() %ld MB/s, rmw enabled\n", +			(perf * HZ * (disks - 2)) >> +			(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2 + 1)); +	} +out:  	return best;  } diff --git a/lib/raid6/avx2.c b/lib/raid6/avx2.c index f299476e1d76..059024234dce 100644 --- a/lib/raid6/avx2.c +++ b/lib/raid6/avx2.c @@ -132,7 +132,7 @@ const struct raid6_calls raid6_avx2x1 = {  	raid6_avx21_xor_syndrome,  	raid6_have_avx2,  	"avx2x1", -	1			/* Has cache hints */ +	.priority = 2		/* Prefer AVX2 over priority 1 (SSE2 and others) */  };  /* @@ -262,7 +262,7 @@ const struct raid6_calls raid6_avx2x2 = {  	raid6_avx22_xor_syndrome,  	raid6_have_avx2,  	"avx2x2", -	1			/* Has cache hints */ +	.priority = 2		/* Prefer AVX2 over priority 1 (SSE2 and others) */  };  #ifdef CONFIG_X86_64 @@ -465,6 +465,6 @@ const struct raid6_calls raid6_avx2x4 = {  	raid6_avx24_xor_syndrome,  	raid6_have_avx2,  	"avx2x4", -	1			/* Has cache hints */ +	.priority = 2		/* Prefer AVX2 over priority 1 (SSE2 and others) */  }; -#endif +#endif /* CONFIG_X86_64 */ diff --git a/lib/raid6/avx512.c b/lib/raid6/avx512.c index bb684d144ee2..9c3e822e1adf 100644 --- a/lib/raid6/avx512.c +++ b/lib/raid6/avx512.c @@ -162,7 +162,7 @@ const struct raid6_calls raid6_avx512x1 = {  	raid6_avx5121_xor_syndrome,  	raid6_have_avx512,  	"avx512x1", -	1                       /* Has cache hints */ +	.priority = 2		/* Prefer AVX512 over priority 1 (SSE2 and others) */  };  /* @@ -319,7 +319,7 @@ const struct raid6_calls raid6_avx512x2 = {  	raid6_avx5122_xor_syndrome,  	raid6_have_avx512,  	"avx512x2", -	1                       /* Has cache hints */ +	.priority = 2		/* Prefer AVX512 over priority 1 (SSE2 and others) */  };  #ifdef CONFIG_X86_64 @@ -557,7 +557,7 @@ const struct raid6_calls raid6_avx512x4 = {  	raid6_avx5124_xor_syndrome,  	raid6_have_avx512,  	"avx512x4", -	1                       /* Has cache hints */ +	.priority = 2		/* Prefer AVX512 over priority 1 (SSE2 and others) */  };  #endif diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile index a4c7cd74cff5..4fb7700a741b 100644 --- a/lib/raid6/test/Makefile +++ b/lib/raid6/test/Makefile @@ -4,6 +4,8 @@  # from userspace.  # +pound := \# +  CC	 = gcc  OPTFLAGS = -O2			# Adjust as desired  CFLAGS	 = -I.. -I ../../../include -g $(OPTFLAGS) @@ -42,7 +44,7 @@ else ifeq ($(HAS_NEON),yes)          OBJS   += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o          CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1  else -        HAS_ALTIVEC := $(shell printf '\#include <altivec.h>\nvector int a;\n' |\ +        HAS_ALTIVEC := $(shell printf '$(pound)include <altivec.h>\nvector int a;\n' |\                           gcc -c -x c - >/dev/null && rm ./-.o && echo yes)          ifeq ($(HAS_ALTIVEC),yes)                  CFLAGS += -I../../../arch/powerpc/include diff --git a/lib/raid6/test/test.c b/lib/raid6/test/test.c index a3cf071941ab..841a55242aba 100644 --- a/lib/raid6/test/test.c +++ b/lib/raid6/test/test.c @@ -19,7 +19,6 @@  #define NDISKS		16	/* Including P and Q */  const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -struct raid6_calls raid6_call;  char *dataptrs[NDISKS];  char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); diff --git a/lib/raid6/vpermxor.uc b/lib/raid6/vpermxor.uc index 10475dc423c1..1bfb127fbfe8 100644 --- a/lib/raid6/vpermxor.uc +++ b/lib/raid6/vpermxor.uc @@ -24,9 +24,9 @@  #ifdef CONFIG_ALTIVEC  #include <altivec.h> +#include <asm/ppc-opcode.h>  #ifdef __KERNEL__  #include <asm/cputable.h> -#include <asm/ppc-opcode.h>  #include <asm/switch_to.h>  #endif  |