lib/raid6: add option to skip algo benchmarking 99/222799/2
authorDaniel Verkamp <dverkamp@chromium.org>
Mon, 12 Nov 2018 23:26:52 +0000 (15:26 -0800)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Mon, 20 Jan 2020 07:48:13 +0000 (16:48 +0900)
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>
[jhoon20.kim: backport from mainline for the fast kernel startup]

Change-Id: I38c270c413d60de65f27cf9c95d44bb2e2d07ac2
Signed-off-by: Junghoon Kim <jhoon20.kim@samsung.com>
include/linux/raid/pq.h
lib/Kconfig
lib/raid6/algos.c

index ea8505204fdfc6dd17cab030f9ead1af419455ef..faf7a4529a5a20e22438a062f6e80e18fc8c2f41 100644 (file)
@@ -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 */
index a3928d4438b5008c1fa01470de11245d1557bc33..fcb00bc06f1ad2e3260a314321fdc8b4f244264b 100644 (file)
@@ -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
 
index 5065b1e7e32759535942fed1e149079e61c1dcda..c34344902fd2a1d905825dc1da95569544688ce6 100644 (file)
@@ -163,6 +163,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();