Skip to content

Commit

Permalink
lib/raid6: add option to skip algo benchmarking
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Shaohua Li <[email protected]>
  • Loading branch information
danielverkamp authored and shligit committed Dec 20, 2018
1 parent 0437de4 commit be85f93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/linux/raid/pq.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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 */
Expand Down
8 changes: 8 additions & 0 deletions lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions lib/raid6/algos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit be85f93

Please sign in to comment.