Skip to content

Commit 524ccdb

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: xor - defer load time benchmark to a later time
Currently, the XOR module performs its boot time benchmark at core initcall time when it is built-in, to ensure that the RAID code can make use of it when it is built-in as well. Let's defer this to a later stage during the boot, to avoid impacting the overall boot time of the system. Instead, just pick an arbitrary implementation from the list, and use that as the preliminary default. Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 2fcb4cc commit 524ccdb

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

crypto/xor.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,28 @@ EXPORT_SYMBOL(xor_blocks);
5454
/* Set of all registered templates. */
5555
static struct xor_block_template *__initdata template_list;
5656

57+
#ifndef MODULE
58+
static void __init do_xor_register(struct xor_block_template *tmpl)
59+
{
60+
tmpl->next = template_list;
61+
template_list = tmpl;
62+
}
63+
64+
static int __init register_xor_blocks(void)
65+
{
66+
active_template = XOR_SELECT_TEMPLATE(NULL);
67+
68+
if (!active_template) {
69+
#define xor_speed do_xor_register
70+
// register all the templates and pick the first as the default
71+
XOR_TRY_TEMPLATES;
72+
#undef xor_speed
73+
active_template = template_list;
74+
}
75+
return 0;
76+
}
77+
#endif
78+
5779
#define BENCH_SIZE (PAGE_SIZE)
5880

5981
static void __init
@@ -129,6 +151,7 @@ calibrate_xor_blocks(void)
129151
#define xor_speed(templ) do_xor_speed((templ), b1, b2)
130152

131153
printk(KERN_INFO "xor: measuring software checksum speed\n");
154+
template_list = NULL;
132155
XOR_TRY_TEMPLATES;
133156
fastest = template_list;
134157
for (f = fastest; f; f = f->next)
@@ -150,6 +173,10 @@ static __exit void xor_exit(void) { }
150173

151174
MODULE_LICENSE("GPL");
152175

176+
#ifndef MODULE
153177
/* when built-in xor.o must initialize before drivers/md/md.o */
154-
core_initcall(calibrate_xor_blocks);
178+
core_initcall(register_xor_blocks);
179+
#endif
180+
181+
module_init(calibrate_xor_blocks);
155182
module_exit(xor_exit);

0 commit comments

Comments
 (0)