mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
raid6: use static_call for gen_syndrom and xor_syndrom
Avoid indirect calls for P/Q parity generation. Link: https://lore.kernel.org/20260518051804.462141-12-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Ard Biesheuvel <ardb@kernel.org> Tested-by: Ard Biesheuvel <ardb@kernel.org> # kunit only on arm64 Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Arnd Bergmann <arnd@arndb.de> Cc: "Borislav Petkov (AMD)" <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Mason <clm@fb.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: David Sterba <dsterba@suse.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Li Nan <linan122@huawei.com> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Song Liu <song@kernel.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: WANG Xuerui <kernel@xen0n.name> Cc: Will Deacon <will@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
adfcf6e89b
commit
10f4b8e2a1
|
|
@ -14,6 +14,7 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/raid/pq.h>
|
||||
#include <linux/static_call.h>
|
||||
#include <kunit/visibility.h>
|
||||
#include "algos.h"
|
||||
|
||||
|
|
@ -23,7 +24,8 @@ static unsigned int raid6_nr_algos;
|
|||
static const struct raid6_recov_calls *raid6_recov_algo;
|
||||
|
||||
/* Selected algorithm */
|
||||
static struct raid6_calls raid6_call;
|
||||
DEFINE_STATIC_CALL_NULL(raid6_gen_syndrome_impl, *raid6_intx1.gen_syndrome);
|
||||
DEFINE_STATIC_CALL_NULL(raid6_xor_syndrome_impl, *raid6_intx1.xor_syndrome);
|
||||
|
||||
/**
|
||||
* raid6_gen_syndrome - generate RAID6 P/Q parity
|
||||
|
|
@ -48,7 +50,7 @@ void raid6_gen_syndrome(int disks, size_t bytes, void **ptrs)
|
|||
WARN_ON_ONCE(bytes & 511);
|
||||
WARN_ON_ONCE(disks < RAID6_MIN_DISKS);
|
||||
|
||||
raid6_call.gen_syndrome(disks, bytes, ptrs);
|
||||
static_call(raid6_gen_syndrome_impl)(disks, bytes, ptrs);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(raid6_gen_syndrome);
|
||||
|
||||
|
|
@ -85,7 +87,7 @@ void raid6_xor_syndrome(int disks, int start, int stop, size_t bytes,
|
|||
WARN_ON_ONCE(disks < RAID6_MIN_DISKS);
|
||||
WARN_ON_ONCE(stop < start);
|
||||
|
||||
raid6_call.xor_syndrome(disks, start, stop, bytes, ptrs);
|
||||
static_call(raid6_xor_syndrome_impl)(disks, start, stop, bytes, ptrs);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(raid6_xor_syndrome);
|
||||
|
||||
|
|
@ -96,7 +98,7 @@ EXPORT_SYMBOL_GPL(raid6_xor_syndrome);
|
|||
*/
|
||||
bool raid6_can_xor_syndrome(void)
|
||||
{
|
||||
return !!raid6_call.xor_syndrome;
|
||||
return !!static_call_query(raid6_xor_syndrome_impl);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(raid6_can_xor_syndrome);
|
||||
|
||||
|
|
@ -195,7 +197,8 @@ static int raid6_choose_gen(void *(*const dptrs)[RAID6_TEST_DISKS],
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
raid6_call = *best;
|
||||
static_call_update(raid6_gen_syndrome_impl, best->gen_syndrome);
|
||||
static_call_update(raid6_xor_syndrome_impl, best->xor_syndrome);
|
||||
|
||||
pr_info("raid6: using algorithm %s gen() %ld MB/s\n",
|
||||
best->name,
|
||||
|
|
@ -240,7 +243,10 @@ static int __init raid6_select_algo(void)
|
|||
if (!IS_ENABLED(CONFIG_RAID6_PQ_BENCHMARK) || raid6_nr_algos == 1) {
|
||||
pr_info("raid6: skipped pq benchmark and selected %s\n",
|
||||
raid6_algos[raid6_nr_algos - 1]->name);
|
||||
raid6_call = *raid6_algos[raid6_nr_algos - 1];
|
||||
static_call_update(raid6_gen_syndrome_impl,
|
||||
raid6_algos[raid6_nr_algos - 1]->gen_syndrome);
|
||||
static_call_update(raid6_xor_syndrome_impl,
|
||||
raid6_algos[raid6_nr_algos - 1]->xor_syndrome);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user