Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xor: use static_call for xor_gen

Avoid the indirect call for xor_generation by using a static_call.

Link: https://lkml.kernel.org/r/20260327061704.3707577-28-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Tested-by: Eric Biggers <ebiggers@kernel.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
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 S. Miller <davem@davemloft.net>
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: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Li Nan <linan122@huawei.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Magnus Lindholm <linmag7@gmail.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Song Liu <song@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Ted Ts'o <tytso@mit.edu>
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>

authored by

Christoph Hellwig and committed by
Andrew Morton
a21921dd 80dcf0a7

+11 -11
+11 -11
lib/raid/xor/xor-core.c
··· 11 11 #include <linux/raid/xor.h> 12 12 #include <linux/jiffies.h> 13 13 #include <linux/preempt.h> 14 + #include <linux/static_call.h> 14 15 #include "xor_impl.h" 15 16 16 - /* The xor routine to use. */ 17 - static struct xor_block_template *active_template; 17 + DEFINE_STATIC_CALL_NULL(xor_gen_impl, *xor_block_8regs.xor_gen); 18 18 19 19 /** 20 20 * xor_gen - generate RAID-style XOR information ··· 37 37 WARN_ON_ONCE(bytes == 0); 38 38 WARN_ON_ONCE(bytes & 511); 39 39 40 - active_template->xor_gen(dest, srcs, src_cnt, bytes); 40 + static_call(xor_gen_impl)(dest, srcs, src_cnt, bytes); 41 41 } 42 42 EXPORT_SYMBOL(xor_gen); 43 43 44 44 /* Set of all registered templates. */ 45 45 static struct xor_block_template *__initdata template_list; 46 - static bool __initdata xor_forced = false; 46 + static struct xor_block_template *forced_template; 47 47 48 48 /** 49 49 * xor_register - register a XOR template ··· 69 69 */ 70 70 void __init xor_force(struct xor_block_template *tmpl) 71 71 { 72 - active_template = tmpl; 72 + forced_template = tmpl; 73 73 } 74 74 75 75 #define BENCH_SIZE 4096 ··· 111 111 void *b1, *b2; 112 112 struct xor_block_template *f, *fastest; 113 113 114 - if (xor_forced) 114 + if (forced_template) 115 115 return 0; 116 116 117 117 b1 = (void *) __get_free_pages(GFP_KERNEL, 2); ··· 128 128 if (f->speed > fastest->speed) 129 129 fastest = f; 130 130 } 131 - active_template = fastest; 131 + static_call_update(xor_gen_impl, fastest->xor_gen); 132 132 pr_info("xor: using function: %s (%d MB/sec)\n", 133 133 fastest->name, fastest->speed); 134 134 ··· 156 156 * If this arch/cpu has a short-circuited selection, don't loop through 157 157 * all the possible functions, just use the best one. 158 158 */ 159 - if (active_template) { 159 + if (forced_template) { 160 160 pr_info("xor: automatically using best checksumming function %-10s\n", 161 - active_template->name); 162 - xor_forced = true; 161 + forced_template->name); 162 + static_call_update(xor_gen_impl, forced_template->xor_gen); 163 163 return 0; 164 164 } 165 165 ··· 170 170 * Pick the first template as the temporary default until calibration 171 171 * happens. 172 172 */ 173 - active_template = template_list; 173 + static_call_update(xor_gen_impl, template_list->xor_gen); 174 174 return 0; 175 175 #endif 176 176 }