mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
lib/raid6: skip benchmark of non-chosen xor_syndrome functions
In commit fe5cbc6e06
("md/raid6 algorithms: delta syndrome functions")
a xor_syndrome() benchmarking was added also to the raid6_choose_gen()
function. However, the results of that benchmarking were intentionally
discarded and did not influence the choice. It picked the
xor_syndrome() variant related to the best performing gen_syndrome().
Reduce runtime of raid6_choose_gen() without modifying its outcome by
only benchmarking the xor_syndrome() of the best gen_syndrome() variant.
For a HZ=250 x86_64 system with avx2 and without avx512 this removes
5 out of 6 xor() benchmarks, saving 340ms of raid6 initialization time.
Signed-off-by: Dirk Müller <dmueller@suse.de>
Signed-off-by: Song Liu <song@kernel.org>
This commit is contained in:
parent
dd3dc5f416
commit
38640c4809
1 changed files with 40 additions and 42 deletions
|
@ -145,12 +145,12 @@ static inline const struct raid6_recov_calls *raid6_choose_recov(void)
|
||||||
static inline const struct raid6_calls *raid6_choose_gen(
|
static inline const struct raid6_calls *raid6_choose_gen(
|
||||||
void *(*const dptrs)[RAID6_TEST_DISKS], const int disks)
|
void *(*const dptrs)[RAID6_TEST_DISKS], const int disks)
|
||||||
{
|
{
|
||||||
unsigned long perf, bestgenperf, bestxorperf, j0, j1;
|
unsigned long perf, bestgenperf, j0, j1;
|
||||||
int start = (disks>>1)-1, stop = disks-3; /* work on the second half of the disks */
|
int start = (disks>>1)-1, stop = disks-3; /* work on the second half of the disks */
|
||||||
const struct raid6_calls *const *algo;
|
const struct raid6_calls *const *algo;
|
||||||
const struct raid6_calls *best;
|
const struct raid6_calls *best;
|
||||||
|
|
||||||
for (bestgenperf = 0, bestxorperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) {
|
for (bestgenperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) {
|
||||||
if (!best || (*algo)->prefer >= best->prefer) {
|
if (!best || (*algo)->prefer >= best->prefer) {
|
||||||
if ((*algo)->valid && !(*algo)->valid())
|
if ((*algo)->valid && !(*algo)->valid())
|
||||||
continue;
|
continue;
|
||||||
|
@ -180,10 +180,28 @@ static inline const struct raid6_calls *raid6_choose_gen(
|
||||||
pr_info("raid6: %-8s gen() %5ld MB/s\n", (*algo)->name,
|
pr_info("raid6: %-8s gen() %5ld MB/s\n", (*algo)->name,
|
||||||
(perf * HZ * (disks-2)) >>
|
(perf * HZ * (disks-2)) >>
|
||||||
(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2));
|
(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(*algo)->xor_syndrome)
|
if (!best) {
|
||||||
continue;
|
pr_err("raid6: Yikes! No algorithm found!\n");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
raid6_call = *best;
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) {
|
||||||
|
pr_info("raid6: skipped pq benchmark and selected %s\n",
|
||||||
|
best->name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
pr_info("raid6: using algorithm %s gen() %ld MB/s\n",
|
||||||
|
best->name,
|
||||||
|
(bestgenperf * HZ * (disks - 2)) >>
|
||||||
|
(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2));
|
||||||
|
|
||||||
|
if (best->xor_syndrome) {
|
||||||
perf = 0;
|
perf = 0;
|
||||||
|
|
||||||
preempt_disable();
|
preempt_disable();
|
||||||
|
@ -191,39 +209,19 @@ static inline const struct raid6_calls *raid6_choose_gen(
|
||||||
while ((j1 = jiffies) == j0)
|
while ((j1 = jiffies) == j0)
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
while (time_before(jiffies,
|
while (time_before(jiffies,
|
||||||
j1 + (1<<RAID6_TIME_JIFFIES_LG2))) {
|
j1 + (1 << RAID6_TIME_JIFFIES_LG2))) {
|
||||||
(*algo)->xor_syndrome(disks, start, stop,
|
best->xor_syndrome(disks, start, stop,
|
||||||
PAGE_SIZE, *dptrs);
|
PAGE_SIZE, *dptrs);
|
||||||
perf++;
|
perf++;
|
||||||
}
|
}
|
||||||
preempt_enable();
|
preempt_enable();
|
||||||
|
|
||||||
if (best == *algo)
|
|
||||||
bestxorperf = perf;
|
|
||||||
|
|
||||||
pr_info("raid6: %-8s xor() %5ld MB/s\n", (*algo)->name,
|
|
||||||
(perf * HZ * (disks-2)) >>
|
|
||||||
(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2 + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (best) {
|
|
||||||
if (IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK)) {
|
|
||||||
pr_info("raid6: using algorithm %s gen() %ld MB/s\n",
|
|
||||||
best->name,
|
|
||||||
(bestgenperf * HZ * (disks-2)) >>
|
|
||||||
(20 - PAGE_SHIFT+RAID6_TIME_JIFFIES_LG2));
|
|
||||||
if (best->xor_syndrome)
|
|
||||||
pr_info("raid6: .... xor() %ld MB/s, rmw enabled\n",
|
pr_info("raid6: .... xor() %ld MB/s, rmw enabled\n",
|
||||||
(bestxorperf * HZ * (disks-2)) >>
|
(perf * HZ * (disks - 2)) >>
|
||||||
(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2 + 1));
|
(20 - PAGE_SHIFT + RAID6_TIME_JIFFIES_LG2 + 1));
|
||||||
} else
|
}
|
||||||
pr_info("raid6: skip pq benchmark and using algorithm %s\n",
|
|
||||||
best->name);
|
|
||||||
raid6_call = *best;
|
|
||||||
} else
|
|
||||||
pr_err("raid6: Yikes! No algorithm found!\n");
|
|
||||||
|
|
||||||
|
out:
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue