Debian Codegraph @

vmtest/patches/lib-raid6-add-option-to-skip-algo-benchmarking.patch

raw
1 From be85f93ae2df32dea0b20908316f1d894c3e0f64 Mon Sep 17 00:00:00 2001
2 Message-ID: <be85f93ae2df32dea0b20908316f1d894c3e0f64.1729542372.git.osandov@fb.com>
3 From: Daniel Verkamp <[email protected]>
4 Date: Mon, 12 Nov 2018 15:26:52 -0800
5 Subject: [PATCH] lib/raid6: add option to skip algo benchmarking
6
7 This is helpful for systems where fast startup time is important.
8 It is especially nice to avoid benchmarking RAID functions that are
9 never used (for example, BTRFS selects RAID6_PQ even if the parity RAID
10 mode is not in use).
11
12 This saves 250+ milliseconds of boot time on modern x86 and ARM systems
13 with a dozen or more available implementations.
14
15 The new option is defaulted to 'y' to match the previous behavior of
16 always benchmarking on init.
17
18 Signed-off-by: Daniel Verkamp <[email protected]>
19 Signed-off-by: Shaohua Li <[email protected]>
20 ---
21 include/linux/raid/pq.h | 3 +++
22 lib/Kconfig | 8 ++++++++
23 lib/raid6/algos.c | 5 +++++
24 3 files changed, 16 insertions(+)
25
26 diff --git a/include/linux/raid/pq.h b/include/linux/raid/pq.h
27 index d7c99161bba2..605cf46c17bd 100644
28 --- a/include/linux/raid/pq.h
29 +++ b/include/linux/raid/pq.h
30 @@ -70,6 +70,9 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
31 #define MODULE_DESCRIPTION(desc)
32 #define subsys_initcall(x)
33 #define module_exit(x)
34 +
35 +#define IS_ENABLED(x) (x)
36 +#define CONFIG_RAID6_PQ_BENCHMARK 1
37 #endif /* __KERNEL__ */
38
39 /* Routine choices */
40 diff --git a/lib/Kconfig b/lib/Kconfig
41 index a9965f4af4dd..fcb05305a5a2 100644
42 --- a/lib/Kconfig
43 +++ b/lib/Kconfig
44 @@ -10,6 +10,14 @@ menu "Library routines"
45 config RAID6_PQ
46 tristate
47
48 +config RAID6_PQ_BENCHMARK
49 + bool "Automatically choose fastest RAID6 PQ functions"
50 + depends on RAID6_PQ
51 + default y
52 + help
53 + Benchmark all available RAID6 PQ functions on init and choose the
54 + fastest one.
55 +
56 config BITREVERSE
57 tristate
58
59 diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
60 index a753ff56670f..7e4f7a8ffa8e 100644
61 --- a/lib/raid6/algos.c
62 +++ b/lib/raid6/algos.c
63 @@ -163,6 +163,11 @@ static inline const struct raid6_calls *raid6_choose_gen(
64 if ((*algo)->valid && !(*algo)->valid())
65 continue;
66
67 + if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) {
68 + best = *algo;
69 + break;
70 + }
71 +
72 perf = 0;
73
74 preempt_disable();
75 --
76 2.47.0
77