linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] Little memset_explicit optimisation
@ 2018-11-28  6:32 David CARLIER
  2018-11-28  7:02 ` Joey Pabalinas
  0 siblings, 1 reply; 8+ messages in thread
From: David CARLIER @ 2018-11-28  6:32 UTC (permalink / raw)
  To: alexander.shishkin, Joey Pabalinas, linux-kernel

Bad entrance with bad idea I m afraid :-) sorry for the noise.

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

* Re: [PATCH] Little memset_explicit optimisation
  2018-11-28  6:32 [PATCH] Little memset_explicit optimisation David CARLIER
@ 2018-11-28  7:02 ` Joey Pabalinas
  0 siblings, 0 replies; 8+ messages in thread
From: Joey Pabalinas @ 2018-11-28  7:02 UTC (permalink / raw)
  To: David CARLIER; +Cc: alexander.shishkin, Joey Pabalinas, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 203 bytes --]

On Wed, Nov 28, 2018 at 06:32:27AM +0000, David CARLIER wrote:
> Bad entrance with bad idea I m afraid :-) sorry for the noise.

We all start somewhere, no worries :)

-- 
Cheers,
Joey Pabalinas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] Little memset_explicit optimisation
  2018-11-26 11:37 ` Joey Pabalinas
@ 2018-11-26 19:36   ` David CARLIER
  0 siblings, 0 replies; 8+ messages in thread
From: David CARLIER @ 2018-11-26 19:36 UTC (permalink / raw)
  To: joeypabalinas, linux-kernel, alexander.shishkin, gregkh,
	andriy.shevchenko, aryabinin

Sorry I m not used yet at all to LKML rules.

So here a slight difference in assembly generated between the two
versions (amd64) :
`
     .loc 1 7 7
     leaq    -12(%rbp), %rax
     movq    %rax, -8(%rbp)
-    .loc 1 11 2
+    .loc 1 9 6
     movq    -8(%rbp), %rax
     movl    $4, %edx
     movl    $0, %esi
     movq    %rax, %rdi
     call    memset@PLT
+    movq    %rax, -8(%rbp)
     .loc 1 13 23
     movq    -8(%rbp), %rax
     movl    (%rax), %eax
`
On Mon, 26 Nov 2018 at 11:37, Joey Pabalinas <joeypabalinas@gmail.com> wrote:
>
> On Sat, Nov 24, 2018 at 12:35:43PM +0000, David CARLIER wrote:
> > Using the return value of memset for save/load sake.
> >
> > Signed-off-by: David Carlier <devnexen@gmail.com>
> > ---
> >  lib/string.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/string.c b/lib/string.c
> > index 38e4ca08e757..92da04a0213b 100644
> > --- a/lib/string.c
> > +++ b/lib/string.c
> > @@ -720,7 +720,7 @@ EXPORT_SYMBOL(memset);
> >   */
> >  void memzero_explicit(void *s, size_t count)
> >  {
> > -       memset(s, 0, count);
> > +       s = memset(s, 0, count);
> >         barrier_data(s);
> >  }
> >  EXPORT_SYMBOL(memzero_explicit);
>
> Could you elaborate on the optimization that this patch performs?
>
> --
> Cheers,
> Joey Pabalinas

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

* Re: [PATCH] Little memset_explicit optimisation
  2018-11-24 12:35 David CARLIER
  2018-11-26 11:29 ` Andy Shevchenko
@ 2018-11-26 11:37 ` Joey Pabalinas
  2018-11-26 19:36   ` David CARLIER
  1 sibling, 1 reply; 8+ messages in thread
From: Joey Pabalinas @ 2018-11-26 11:37 UTC (permalink / raw)
  To: David CARLIER
  Cc: linux-kernel, alexander.shishkin, gregkh, andriy.shevchenko,
	aryabinin, Joey Pabalinas

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

On Sat, Nov 24, 2018 at 12:35:43PM +0000, David CARLIER wrote:
> Using the return value of memset for save/load sake.
> 
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
>  lib/string.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/string.c b/lib/string.c
> index 38e4ca08e757..92da04a0213b 100644
> --- a/lib/string.c
> +++ b/lib/string.c
> @@ -720,7 +720,7 @@ EXPORT_SYMBOL(memset);
>   */
>  void memzero_explicit(void *s, size_t count)
>  {
> -       memset(s, 0, count);
> +       s = memset(s, 0, count);
>         barrier_data(s);
>  }
>  EXPORT_SYMBOL(memzero_explicit);

Could you elaborate on the optimization that this patch performs?

-- 
Cheers,
Joey Pabalinas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] Little memset_explicit optimisation
  2018-11-24 15:35 David CARLIER
@ 2018-11-26 11:32 ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2018-11-26 11:32 UTC (permalink / raw)
  To: David CARLIER; +Cc: linux-kernel, alexander.shishkin, aryabinin, gregkh

On Sat, Nov 24, 2018 at 03:35:05PM +0000, David CARLIER wrote:
> Subject: [PATCH] memzero_explicit, optimisation for size.
> 
> 
> Using the return value of memset for save/load sake.


It's mangled, you, perhaps, need to use

  `git format-patch ...; git send-email ...`

for sake of correctness.

On top of that, same comment as per previous attempt.
Btw, you need to use versioning (hint: `git format-patch -v ` IIRC).

> 
> 
> Signed-off-by: David Carlier <devnexen@gmail.com>
> 
> ---
> 
>  lib/string.c | 2 +-
> 
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> diff --git a/lib/string.c b/lib/string.c
> 
> index 38e4ca08e757..92da04a0213b 100644
> 
> --- a/lib/string.c
> 
> +++ b/lib/string.c
> 
> @@ -720,7 +720,7 @@ EXPORT_SYMBOL(memset);
> 
>   */
> 
>  void memzero_explicit(void *s, size_t count)
> 
>  {
> 
> - memset(s, 0, count);
> 
> + s = memset(s, 0, count);
> 
>   barrier_data(s);
> 
>  }
> 
>  EXPORT_SYMBOL(memzero_explicit);
> 
> -- 
> 
> 2.19.1

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] Little memset_explicit optimisation
  2018-11-24 12:35 David CARLIER
@ 2018-11-26 11:29 ` Andy Shevchenko
  2018-11-26 11:37 ` Joey Pabalinas
  1 sibling, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2018-11-26 11:29 UTC (permalink / raw)
  To: David CARLIER; +Cc: linux-kernel, alexander.shishkin, gregkh, aryabinin

On Sat, Nov 24, 2018 at 12:35:43PM +0000, David CARLIER wrote:
> 

Hmm... Can we see the difference in assembly generation?


-- 
With Best Regards,
Andy Shevchenko



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

* [PATCH] Little memset_explicit optimisation
@ 2018-11-24 15:35 David CARLIER
  2018-11-26 11:32 ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: David CARLIER @ 2018-11-24 15:35 UTC (permalink / raw)
  To: linux-kernel, alexander.shishkin, aryabinin, gregkh, andriy.shevchenko

Subject: [PATCH] memzero_explicit, optimisation for size.


Using the return value of memset for save/load sake.


Signed-off-by: David Carlier <devnexen@gmail.com>

---

 lib/string.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/lib/string.c b/lib/string.c

index 38e4ca08e757..92da04a0213b 100644

--- a/lib/string.c

+++ b/lib/string.c

@@ -720,7 +720,7 @@ EXPORT_SYMBOL(memset);

  */

 void memzero_explicit(void *s, size_t count)

 {

- memset(s, 0, count);

+ s = memset(s, 0, count);

  barrier_data(s);

 }

 EXPORT_SYMBOL(memzero_explicit);

-- 

2.19.1

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

* [PATCH] Little memset_explicit optimisation
@ 2018-11-24 12:35 David CARLIER
  2018-11-26 11:29 ` Andy Shevchenko
  2018-11-26 11:37 ` Joey Pabalinas
  0 siblings, 2 replies; 8+ messages in thread
From: David CARLIER @ 2018-11-24 12:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: alexander.shishkin, gregkh, andriy.shevchenko, aryabinin

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-memzero_explicit-optimisation-for-size.patch --]
[-- Type: application/octet-stream, Size: 720 bytes --]

From c6bb758902b3b358de9a98bb4156c306685f59d7 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen@gmail.com>
Date: Sat, 17 Nov 2018 14:13:13 +0000
Subject: [PATCH] memzero_explicit, optimisation for size.

Using the return value of memset for save/load sake.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 lib/string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/string.c b/lib/string.c
index 38e4ca08e757..92da04a0213b 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -720,7 +720,7 @@ EXPORT_SYMBOL(memset);
  */
 void memzero_explicit(void *s, size_t count)
 {
-	memset(s, 0, count);
+	s = memset(s, 0, count);
 	barrier_data(s);
 }
 EXPORT_SYMBOL(memzero_explicit);
-- 
2.19.1


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

end of thread, other threads:[~2018-11-28  7:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28  6:32 [PATCH] Little memset_explicit optimisation David CARLIER
2018-11-28  7:02 ` Joey Pabalinas
  -- strict thread matches above, loose matches on Subject: below --
2018-11-24 15:35 David CARLIER
2018-11-26 11:32 ` Andy Shevchenko
2018-11-24 12:35 David CARLIER
2018-11-26 11:29 ` Andy Shevchenko
2018-11-26 11:37 ` Joey Pabalinas
2018-11-26 19:36   ` David CARLIER

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).