Skip to contentSkip to conversation

Zero memory more efficiently in mm/percpu.c::pcpu_mem_alloc()

PATCH New Jesper Juhl 2 participants 3 messages Oct 29, 2010 – Oct 30, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Zero memory more efficiently in mm/percpu.c::pcpu_mem_alloc()

Don't do vmalloc() + memset() when vzalloc() will do.

---
 percpu.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
mm/percpu.c +1 -3
index efe8168..8d75223 100644
@@ -294,9 +294,7 @@ static void *pcpu_mem_alloc(size_t size)
 	if (size <= PAGE_SIZE)
 		return kzalloc(size, GFP_KERNEL);
 	else {
-		void *ptr = vmalloc(size);
-		if (ptr)
-			memset(ptr, 0, size);
+		void *ptr = vzalloc(size);
 		return ptr;
 	}
 }
Signature · 9 lines
Jesper Juhl <[email protected]>             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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer
#1 lore raw

PATCH 1/1 percpu: zero memory more efficiently in mm/percpu.c::pcpu_mem_alloc()

Don't do vmalloc() + memset() when vzalloc() will do.

tj: dropped unnecessary temp variable ptr.

---
Applied with slight modification. Thank you.

 mm/percpu.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
mm/percpu.c +2 -6
index efe8168..9e16d1c 100644
@@ -293,12 +293,8 @@ static void *pcpu_mem_alloc(size_t size)
 
 	if (size <= PAGE_SIZE)
 		return kzalloc(size, GFP_KERNEL);
-	else {
-		void *ptr = vmalloc(size);
-		if (ptr)
-			memset(ptr, 0, size);
-		return ptr;
-	}
+	else
+		return vzalloc(size);
 }
 
 /**
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

Re: [PATCH] percpu: zero memory more efficiently in mm/percpu.c::pcpu_mem_alloc()

Quoted 4 lines · Tejun Heo

Don't do vmalloc() + memset() when vzalloc() will do.

tj: dropped unnecessary temp variable ptr.

I must be needing glasses, I should have seen that initially. Thanks for fixing that up :)

Signature · 3 lines
Jesper Juhl <[email protected]>             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