From: Daniel Verkamp Date: Mon, 12 Nov 2018 23:26:52 +0000 (-0800) Subject: lib/raid6: add option to skip algo benchmarking X-Git-Tag: submit/tizen/20210107.224559~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c36dd28ce193905f18e2436cd8ecdd304a1c39c3;p=platform%2Fkernel%2Flinux-amlogic.git lib/raid6: add option to skip algo benchmarking This is helpful for systems where fast startup time is important. It is especially nice to avoid benchmarking RAID functions that are never used (for example, BTRFS selects RAID6_PQ even if the parity RAID mode is not in use). This saves 250+ milliseconds of boot time on modern x86 and ARM systems with a dozen or more available implementations. The new option is defaulted to 'y' to match the previous behavior of always benchmarking on init. Signed-off-by: Daniel Verkamp Signed-off-by: Shaohua Li [sw0312.kim: cherry-pick mainline commit be85f93ae2df to skip unnecessary raid6 benchmark during booting] Signed-off-by: Seung-Woo Kim Change-Id: I70256f5cbfb61c0033a16d2eb57e10e0dd1e6768 --- diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h index 4d57bbaaa1bf..872fd309b798 100644 --- a/include/linux/raid/pq.h +++ b/include/linux/raid/pq.h @@ -67,6 +67,9 @@ extern const char raid6_empty_zero_page[PAGE_SIZE]; #define MODULE_DESCRIPTION(desc) #define subsys_initcall(x) #define module_exit(x) + +#define IS_ENABLED(x) (x) +#define CONFIG_RAID6_PQ_BENCHMARK 1 #endif /* __KERNEL__ */ /* Routine choices */ diff --git a/lib/Kconfig b/lib/Kconfig index 8deab4f7e81a..261475342f5b 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -10,6 +10,14 @@ menu "Library routines" config RAID6_PQ tristate +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 BITREVERSE tristate diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index 7857049fd7d3..62aeb8d3b3ea 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c @@ -159,6 +159,11 @@ static inline const struct raid6_calls *raid6_choose_gen( if ((*algo)->valid && !(*algo)->valid()) continue; + if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) { + best = *algo; + break; + } + perf = 0; preempt_disable();