All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Perf, AMD: Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb()
@ 2010-10-30 19:06 Jesper Juhl
  2010-11-01 17:55 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2010-10-30 19:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, Thomas Gleixner, H. Peter Anvin


Hi,

I believe this would be an improvement?

Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb().


Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 perf_event_amd.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
index 46d5844..a3787b2 100644
--- a/arch/x86/kernel/cpu/perf_event_amd.c
+++ b/arch/x86/kernel/cpu/perf_event_amd.c
@@ -280,11 +280,10 @@ static struct amd_nb *amd_alloc_nb(int cpu, int nb_id)
 	struct amd_nb *nb;
 	int i;
 
-	nb = kmalloc(sizeof(struct amd_nb), GFP_KERNEL);
+	nb = kzalloc(sizeof(struct amd_nb), GFP_KERNEL);
 	if (!nb)
 		return NULL;
 
-	memset(nb, 0, sizeof(*nb));
 	nb->nb_id = nb_id;
 
 	/*


-- 
Jesper Juhl <jj@chaosbits.net>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html


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

* Re: [PATCH] Perf, AMD: Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb()
  2010-10-30 19:06 [PATCH] Perf, AMD: Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb() Jesper Juhl
@ 2010-11-01 17:55 ` Peter Zijlstra
  2010-11-01 17:57   ` Jesper Juhl
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2010-11-01 17:55 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-kernel, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, Thomas Gleixner, H. Peter Anvin,
	Stephane Eranian, robert.richter, Andreas Herrmann,
	Borislav Petkov

On Sat, 2010-10-30 at 21:06 +0200, Jesper Juhl wrote:
> Hi,
> 
> I believe this would be an improvement?
> 
> Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb().
> 
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---


I've changed it to..

---
Subject: perf, amd: Use kmalloc_node(,__GFP_ZERO) for northbridge structure allocation
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Mon Nov 01 18:52:05 CET 2010

Jasper suggested we use the zeroing capability of the allocators
instead of calling memset ourselves. Add node affinity while we're at
it.

Reported-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
Index: linux-2.6/arch/x86/kernel/cpu/perf_event_amd.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/cpu/perf_event_amd.c
+++ linux-2.6/arch/x86/kernel/cpu/perf_event_amd.c
@@ -280,11 +280,10 @@ static struct amd_nb *amd_alloc_nb(int c
 	struct amd_nb *nb;
 	int i;
 
-	nb = kmalloc(sizeof(struct amd_nb), GFP_KERNEL);
+	nb = kmalloc_node(sizeof(struct amd_nb), GFP_KERNEL | __GFP_ZERO, nb_id);
 	if (!nb)
 		return NULL;
 
-	memset(nb, 0, sizeof(*nb));
 	nb->nb_id = nb_id;
 
 	/*


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

* Re: [PATCH] Perf, AMD: Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb()
  2010-11-01 17:55 ` Peter Zijlstra
@ 2010-11-01 17:57   ` Jesper Juhl
  2010-11-02 14:08     ` Stephane Eranian
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2010-11-01 17:57 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, Thomas Gleixner, H. Peter Anvin,
	Stephane Eranian, robert.richter, Andreas Herrmann,
	Borislav Petkov

On Mon, 1 Nov 2010, Peter Zijlstra wrote:

> On Sat, 2010-10-30 at 21:06 +0200, Jesper Juhl wrote:
> > Hi,
> > 
> > I believe this would be an improvement?
> > 
> > Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb().
> > 
> > 
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> > ---
> 
> 
> I've changed it to..
> 
> ---
> Subject: perf, amd: Use kmalloc_node(,__GFP_ZERO) for northbridge structure allocation
> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Date: Mon Nov 01 18:52:05 CET 2010
> 
> Jasper suggested we use the zeroing capability of the allocators
> instead of calling memset ourselves. Add node affinity while we're at
> it.
> 
> Reported-by: Jesper Juhl <jj@chaosbits.net>
> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

Fine by me.

-- 
Jesper Juhl <jj@chaosbits.net>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html


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

* Re: [PATCH] Perf, AMD: Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb()
  2010-11-01 17:57   ` Jesper Juhl
@ 2010-11-02 14:08     ` Stephane Eranian
  0 siblings, 0 replies; 4+ messages in thread
From: Stephane Eranian @ 2010-11-02 14:08 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Peter Zijlstra, linux-kernel, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo, Thomas Gleixner, H. Peter Anvin,
	robert.richter, Andreas Herrmann, Borislav Petkov

On Mon, Nov 1, 2010 at 6:57 PM, Jesper Juhl <jj@chaosbits.net> wrote:
> On Mon, 1 Nov 2010, Peter Zijlstra wrote:
>
>> On Sat, 2010-10-30 at 21:06 +0200, Jesper Juhl wrote:
>> > Hi,
>> >
>> > I believe this would be an improvement?
>> >
>> > Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb().
>> >
>> >
>> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
>> > ---
>>
>>
>> I've changed it to..
>>
>> ---
>> Subject: perf, amd: Use kmalloc_node(,__GFP_ZERO) for northbridge structure allocation
>> From: Peter Zijlstra <a.p.zijlstra@chello.nl>
>> Date: Mon Nov 01 18:52:05 CET 2010
>>
>> Jasper suggested we use the zeroing capability of the allocators
>> instead of calling memset ourselves. Add node affinity while we're at
>> it.
>>
>> Reported-by: Jesper Juhl <jj@chaosbits.net>
>> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
>
> Fine by me.
>
Works for me.

Acked-by: Stephane Eranian <eranian@google.com>

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

end of thread, other threads:[~2010-11-02 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-30 19:06 [PATCH] Perf, AMD: Prefer kzalloc() over kmalloc()+memset() in amd_alloc_nb() Jesper Juhl
2010-11-01 17:55 ` Peter Zijlstra
2010-11-01 17:57   ` Jesper Juhl
2010-11-02 14:08     ` Stephane Eranian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.