aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2018-11-12 18:26:52 -0500
committerShaohua Li <shli@fb.com>2018-12-20 11:53:23 -0500
commitbe85f93ae2df32dea0b20908316f1d894c3e0f64 (patch)
tree83da6e27e6ab8e949115a5a690af009c69912da3
parent0437de4fa09fe59b57d12b785e4afb73b0f34c05 (diff)
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 <dverkamp@chromium.org> Signed-off-by: Shaohua Li <shli@fb.com>
-rw-r--r--include/linux/raid/pq.h3
-rw-r--r--lib/Kconfig8
-rw-r--r--lib/raid6/algos.c5
3 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h
index d7c99161bba2..605cf46c17bd 100644
--- a/include/linux/raid/pq.h
+++ b/include/linux/raid/pq.h
@@ -70,6 +70,9 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
70#define MODULE_DESCRIPTION(desc) 70#define MODULE_DESCRIPTION(desc)
71#define subsys_initcall(x) 71#define subsys_initcall(x)
72#define module_exit(x) 72#define module_exit(x)
73
74#define IS_ENABLED(x) (x)
75#define CONFIG_RAID6_PQ_BENCHMARK 1
73#endif /* __KERNEL__ */ 76#endif /* __KERNEL__ */
74 77
75/* Routine choices */ 78/* Routine choices */
diff --git a/lib/Kconfig b/lib/Kconfig
index a9965f4af4dd..fcb05305a5a2 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -10,6 +10,14 @@ menu "Library routines"
10config RAID6_PQ 10config RAID6_PQ
11 tristate 11 tristate
12 12
13config RAID6_PQ_BENCHMARK
14 bool "Automatically choose fastest RAID6 PQ functions"
15 depends on RAID6_PQ
16 default y
17 help
18 Benchmark all available RAID6 PQ functions on init and choose the
19 fastest one.
20
13config BITREVERSE 21config BITREVERSE
14 tristate 22 tristate
15 23
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index a753ff56670f..7e4f7a8ffa8e 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -163,6 +163,11 @@ static inline const struct raid6_calls *raid6_choose_gen(
163 if ((*algo)->valid && !(*algo)->valid()) 163 if ((*algo)->valid && !(*algo)->valid())
164 continue; 164 continue;
165 165
166 if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) {
167 best = *algo;
168 break;
169 }
170
166 perf = 0; 171 perf = 0;
167 172
168 preempt_disable(); 173 preempt_disable();