linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto/xor.c: use 2 pages for xor speed testing
@ 2014-06-05  1:11 Amos Kong
  2014-06-05 21:57 ` Marek Vasut
  0 siblings, 1 reply; 4+ messages in thread
From: Amos Kong @ 2014-06-05  1:11 UTC (permalink / raw)
  To: linux-crypto; +Cc: herbert, davem, marex

In crypto/xor.c: calibrate_xor_blocks(), we allocated total 4 pages to
do xor speed testing, the BENCH_SIZE is 1 page, and we skipped 2 pages
when we set b2.

It seems that total 2 pages are enough without skipping 2 pages.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 crypto/xor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/crypto/xor.c b/crypto/xor.c
index 35d6b3a..609dfb5 100644
--- a/crypto/xor.c
+++ b/crypto/xor.c
@@ -114,12 +114,12 @@ calibrate_xor_blocks(void)
 	 * test the XOR speed, we don't really want kmemcheck to warn about
 	 * reading uninitialized bytes here.
 	 */
-	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 2);
+	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 1);
 	if (!b1) {
 		printk(KERN_WARNING "xor: Yikes!  No memory available.\n");
 		return -ENOMEM;
 	}
-	b2 = b1 + 2*PAGE_SIZE + BENCH_SIZE;
+	b2 = b1 + BENCH_SIZE;
 
 	/*
 	 * If this arch/cpu has a short-circuited selection, don't loop through
@@ -154,7 +154,7 @@ calibrate_xor_blocks(void)
 #undef xor_speed
 
  out:
-	free_pages((unsigned long)b1, 2);
+	free_pages((unsigned long)b1, 1);
 
 	active_template = fastest;
 	return 0;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto/xor.c: use 2 pages for xor speed testing
  2014-06-05  1:11 [PATCH] crypto/xor.c: use 2 pages for xor speed testing Amos Kong
@ 2014-06-05 21:57 ` Marek Vasut
  2014-06-17  7:16   ` Amos Kong
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2014-06-05 21:57 UTC (permalink / raw)
  To: Amos Kong; +Cc: linux-crypto, herbert, davem

On Thursday, June 05, 2014 at 03:11:33 AM, Amos Kong wrote:
> In crypto/xor.c: calibrate_xor_blocks(), we allocated total 4 pages to
> do xor speed testing, the BENCH_SIZE is 1 page, and we skipped 2 pages
> when we set b2.
> 
> It seems that total 2 pages are enough without skipping 2 pages.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  crypto/xor.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/crypto/xor.c b/crypto/xor.c
> index 35d6b3a..609dfb5 100644
> --- a/crypto/xor.c
> +++ b/crypto/xor.c
> @@ -114,12 +114,12 @@ calibrate_xor_blocks(void)
>  	 * test the XOR speed, we don't really want kmemcheck to warn about
>  	 * reading uninitialized bytes here.
>  	 */
> -	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 2);
> +	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 1);
>  	if (!b1) {
>  		printk(KERN_WARNING "xor: Yikes!  No memory available.\n");
>  		return -ENOMEM;
>  	}
> -	b2 = b1 + 2*PAGE_SIZE + BENCH_SIZE;
> +	b2 = b1 + BENCH_SIZE;
> 
>  	/*
>  	 * If this arch/cpu has a short-circuited selection, don't loop through
> @@ -154,7 +154,7 @@ calibrate_xor_blocks(void)
>  #undef xor_speed
> 
>   out:
> -	free_pages((unsigned long)b1, 2);
> +	free_pages((unsigned long)b1, 1);
> 
>  	active_template = fastest;
>  	return 0;

I think this does make sense, but I am not 100% sure, sorry.

...

While looking at this code, can anyone explain to me why we have this stuff in 
crypto/xor.c please ?

135 #define xor_speed(templ)        do_xor_speed((templ), b1, b2)
136 
137         if (fastest) {
138                 printk(KERN_INFO "xor: automatically using best "
139                                  "checksumming function:\n");
140                 xor_speed(fastest);
141                 goto out;
142         } else {
[...]
149         }
150 
151         printk(KERN_INFO "xor: using function: %s (%d.%03d MB/sec)\n",
152                fastest->name, fastest->speed / 1000, fastest->speed % 1000);
153 
154 #undef xor_speed

Why do we not call do_xor_speed(fastest, b1, b2); right away , but we #define 
xor_speed() instead ? This looks like some remnant or nonsense to me. Shall I 
remove that with a patch ?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto/xor.c: use 2 pages for xor speed testing
  2014-06-05 21:57 ` Marek Vasut
@ 2014-06-17  7:16   ` Amos Kong
  2014-06-25 19:59     ` Marek Vasut
  0 siblings, 1 reply; 4+ messages in thread
From: Amos Kong @ 2014-06-17  7:16 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-crypto, herbert, davem

On Thu, Jun 05, 2014 at 11:57:55PM +0200, Marek Vasut wrote:
> On Thursday, June 05, 2014 at 03:11:33 AM, Amos Kong wrote:
> > In crypto/xor.c: calibrate_xor_blocks(), we allocated total 4 pages to
> > do xor speed testing, the BENCH_SIZE is 1 page, and we skipped 2 pages
> > when we set b2.
> > 
> > It seems that total 2 pages are enough without skipping 2 pages.
> > 
> > Signed-off-by: Amos Kong <akong@redhat.com>
> > ---
> >  crypto/xor.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/crypto/xor.c b/crypto/xor.c
> > index 35d6b3a..609dfb5 100644
> > --- a/crypto/xor.c
> > +++ b/crypto/xor.c
> > @@ -114,12 +114,12 @@ calibrate_xor_blocks(void)
> >  	 * test the XOR speed, we don't really want kmemcheck to warn about
> >  	 * reading uninitialized bytes here.
> >  	 */
> > -	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 2);
> > +	b1 = (void *) __get_free_pages(GFP_KERNEL | __GFP_NOTRACK, 1);
> >  	if (!b1) {
> >  		printk(KERN_WARNING "xor: Yikes!  No memory available.\n");
> >  		return -ENOMEM;
> >  	}
> > -	b2 = b1 + 2*PAGE_SIZE + BENCH_SIZE;
> > +	b2 = b1 + BENCH_SIZE;
> > 
> >  	/*
> >  	 * If this arch/cpu has a short-circuited selection, don't loop through
> > @@ -154,7 +154,7 @@ calibrate_xor_blocks(void)
> >  #undef xor_speed
> > 
> >   out:
> > -	free_pages((unsigned long)b1, 2);
> > +	free_pages((unsigned long)b1, 1);
> > 
> >  	active_template = fastest;
> >  	return 0;
> 
> I think this does make sense, but I am not 100% sure, sorry.
> 
> ...
> 
> While looking at this code, can anyone explain to me why we have this stuff in 
> crypto/xor.c please ?
> 
> 135 #define xor_speed(templ)        do_xor_speed((templ), b1, b2)
> 136 
> 137         if (fastest) {
> 138                 printk(KERN_INFO "xor: automatically using best "
> 139                                  "checksumming function:\n");
> 140                 xor_speed(fastest);
> 141                 goto out;
> 142         } else {
> [...]
> 149         }
> 150 
> 151         printk(KERN_INFO "xor: using function: %s (%d.%03d MB/sec)\n",
> 152                fastest->name, fastest->speed / 1000, fastest->speed % 1000);
> 153 
> 154 #undef xor_speed
> 
> Why do we not call do_xor_speed(fastest, b1, b2); right away , but we #define 
> xor_speed() instead ? This looks like some remnant or nonsense to me. Shall I 
> remove that with a patch ?

You are right.
 
> Best regards,
> Marek Vasut

-- 
			Amos.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto/xor.c: use 2 pages for xor speed testing
  2014-06-17  7:16   ` Amos Kong
@ 2014-06-25 19:59     ` Marek Vasut
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2014-06-25 19:59 UTC (permalink / raw)
  To: Amos Kong; +Cc: linux-crypto, herbert, davem

On Tuesday, June 17, 2014 at 09:16:03 AM, Amos Kong wrote:
[...]
> > While looking at this code, can anyone explain to me why we have this
> > stuff in crypto/xor.c please ?
> > 
> > 135 #define xor_speed(templ)        do_xor_speed((templ), b1, b2)
> > 136
> > 137         if (fastest) {
> > 138                 printk(KERN_INFO "xor: automatically using best "
> > 139                                  "checksumming function:\n");
> > 140                 xor_speed(fastest);
> > 141                 goto out;
> > 142         } else {
> > [...]
> > 149         }
> > 150
> > 151         printk(KERN_INFO "xor: using function: %s (%d.%03d
> > MB/sec)\n", 152                fastest->name, fastest->speed / 1000,
> > fastest->speed % 1000); 153
> > 154 #undef xor_speed
> > 
> > Why do we not call do_xor_speed(fastest, b1, b2); right away , but we
> > #define xor_speed() instead ? This looks like some remnant or nonsense
> > to me. Shall I remove that with a patch ?
> 
> You are right.

I'm wrong. The XOR_TRY_TEMPLATES needs this #define xor_speed , so there's no 
patch happening here. Sorry.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-25 19:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-05  1:11 [PATCH] crypto/xor.c: use 2 pages for xor speed testing Amos Kong
2014-06-05 21:57 ` Marek Vasut
2014-06-17  7:16   ` Amos Kong
2014-06-25 19:59     ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).