]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lib/raid6: Use strict priority ranking for pq gen() benchmarking
authorDirk Müller <dmueller@suse.de>
Wed, 5 Jan 2022 16:38:47 +0000 (17:38 +0100)
committerSong Liu <song@kernel.org>
Thu, 6 Jan 2022 16:37:03 +0000 (08:37 -0800)
On x86_64, currently 3 variants of AVX512, 3 variants of AVX2
and 3 variants of SSE2 are benchmarked on initialization, taking
between 144-153 jiffies. Testing across a hardware pool of
various generations of intel cpus I could not find a single
case where SSE2 won over AVX2 or AVX512. There are cases where
AVX2 wins over AVX512 however.

Change "prefer" into an integer priority field (similar to
how recov selection works) to have more than one ranking level
available, which is backwards compatible with existing behavior.

Give AVX2/512 variants higher priority over SSE2 in order to skip
SSE testing when AVX is available. in a AVX2/x86_64/HZ=250 case this
saves in the order of 200ms of initialization time.

Signed-off-by: Dirk Müller <dmueller@suse.de>
Acked-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Song Liu <song@kernel.org>
include/linux/raid/pq.h
lib/raid6/algos.c
lib/raid6/avx2.c
lib/raid6/avx512.c

index 154e954b711dbf16fe122c27ab79ddc89148e6ea..d6e5a1feb9476df20312815f57344fbe6cc8a3a0 100644 (file)
@@ -81,7 +81,7 @@ struct raid6_calls {
        void (*xor_syndrome)(int, int, int, size_t, void **);
        int  (*valid)(void);    /* Returns 1 if this routine set is usable */
        const char *name;       /* Name of this routine set */
-       int prefer;             /* Has special performance attribute */
+       int priority;           /* Relative priority ranking if non-zero */
 };
 
 /* Selected algorithm */
index 9b7e8a837b27efb0a9c8e429310272e750fc1335..39b74221f4a7cf5c72d2f409106783fba5b73e89 100644 (file)
@@ -151,7 +151,7 @@ static inline const struct raid6_calls *raid6_choose_gen(
        const struct raid6_calls *best;
 
        for (bestgenperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) {
-               if (!best || (*algo)->prefer >= best->prefer) {
+               if (!best || (*algo)->priority >= best->priority) {
                        if ((*algo)->valid && !(*algo)->valid())
                                continue;
 
index f299476e1d76477355693fbc0dc045b0ccc9715e..059024234dce15bd826afd33428494870b8e93ab 100644 (file)
@@ -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 */
index bb684d144ee2ce586330e8973e68de29e2ea671d..9c3e822e1adf5fc5ddc10ed7f606e77676c89457 100644 (file)
@@ -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