From 3e9abf79027946f403651629354aa5834d66f96b Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 19 Aug 2016 14:19:30 +0200 Subject: crypto: xor - skip speed test if the xor function is selected automatically If the architecture selected the xor function with XOR_SELECT_TEMPLATE the speed result of the do_xor_speed benchmark is of limited value. The speed measurement increases the bootup time a little, which can makes a difference for kernels used in container like virtual machines. Signed-off-by: Martin Schwidefsky Signed-off-by: Herbert Xu --- crypto/xor.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'crypto/xor.c') diff --git a/crypto/xor.c b/crypto/xor.c index 35d6b3ad..b8975d92 100644 --- a/crypto/xor.c +++ b/crypto/xor.c @@ -109,6 +109,18 @@ calibrate_xor_blocks(void) void *b1, *b2; struct xor_block_template *f, *fastest; + fastest = NULL; + +#ifdef XOR_SELECT_TEMPLATE + fastest = XOR_SELECT_TEMPLATE(fastest); + if (fastest) { + printk(KERN_INFO "xor: automatically using best " + "checksumming function %-10s\n", + fastest->name); + goto out; + } +#endif + /* * Note: Since the memory is not actually used for _anything_ but to * test the XOR speed, we don't really want kmemcheck to warn about @@ -126,36 +138,22 @@ calibrate_xor_blocks(void) * all the possible functions, just test the best one */ - fastest = NULL; - -#ifdef XOR_SELECT_TEMPLATE - fastest = XOR_SELECT_TEMPLATE(fastest); -#endif - #define xor_speed(templ) do_xor_speed((templ), b1, b2) - if (fastest) { - printk(KERN_INFO "xor: automatically using best " - "checksumming function:\n"); - xor_speed(fastest); - goto out; - } else { - printk(KERN_INFO "xor: measuring software checksum speed\n"); - XOR_TRY_TEMPLATES; - fastest = template_list; - for (f = fastest; f; f = f->next) - if (f->speed > fastest->speed) - fastest = f; - } + printk(KERN_INFO "xor: measuring software checksum speed\n"); + XOR_TRY_TEMPLATES; + fastest = template_list; + for (f = fastest; f; f = f->next) + if (f->speed > fastest->speed) + fastest = f; printk(KERN_INFO "xor: using function: %s (%d.%03d MB/sec)\n", fastest->name, fastest->speed / 1000, fastest->speed % 1000); #undef xor_speed - out: free_pages((unsigned long)b1, 2); - +out: active_template = fastest; return 0; } -- cgit v1.2.3 From 30809d18f22ad1b4ed32b4d885a55f0abcadeb86 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 26 Aug 2016 23:19:39 +0800 Subject: crypto: xor - Fix warning when XOR_SELECT_TEMPLATE is unset This patch fixes an unused label warning triggered when the macro XOR_SELECT_TEMPLATE is not set. Fixes: 3e9abf790279 ("crypto: xor - skip speed test if the xor...") Reported-by: Stephen Rothwell Suggested-by: Stephen Rothwell Signed-off-by: Herbert Xu --- crypto/xor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'crypto/xor.c') diff --git a/crypto/xor.c b/crypto/xor.c index b8975d92..263af9fb 100644 --- a/crypto/xor.c +++ b/crypto/xor.c @@ -24,6 +24,10 @@ #include #include +#ifndef XOR_SELECT_TEMPLATE +#define XOR_SELECT_TEMPLATE(x) (x) +#endif + /* The xor routines to use. */ static struct xor_block_template *active_template; @@ -109,17 +113,14 @@ calibrate_xor_blocks(void) void *b1, *b2; struct xor_block_template *f, *fastest; - fastest = NULL; + fastest = XOR_SELECT_TEMPLATE(NULL); -#ifdef XOR_SELECT_TEMPLATE - fastest = XOR_SELECT_TEMPLATE(fastest); if (fastest) { printk(KERN_INFO "xor: automatically using best " "checksumming function %-10s\n", fastest->name); goto out; } -#endif /* * Note: Since the memory is not actually used for _anything_ but to -- cgit v1.2.3