linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] slab: Make allocations with GFP_ZERO slightly more efficient
@ 2013-09-11  0:02 Joe Perches
  2013-09-11 14:17 ` Christoph Lameter
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2013-09-11  0:02 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, Matt Mackall; +Cc: linux-mm, LKML

Use the likely mechanism already around valid
pointer tests to better choose when to memset
to 0 allocations with __GFP_ZERO

Signed-off-by: Joe Perches <joe@perches.com>
---
 mm/slab.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 2580db0..94e7e54 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3392,11 +3392,11 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
 	kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
 				 flags);
 
-	if (likely(ptr))
+	if (likely(ptr)) {
 		kmemcheck_slab_alloc(cachep, flags, ptr, cachep->object_size);
-
-	if (unlikely((flags & __GFP_ZERO) && ptr))
-		memset(ptr, 0, cachep->object_size);
+		if (unlikely(flags & __GFP_ZERO))
+			memset(ptr, 0, cachep->object_size);
+	}
 
 	return ptr;
 }
@@ -3457,11 +3457,11 @@ slab_alloc(struct kmem_cache *cachep, gfp_t flags, unsigned long caller)
 				 flags);
 	prefetchw(objp);
 
-	if (likely(objp))
+	if (likely(objp)) {
 		kmemcheck_slab_alloc(cachep, flags, objp, cachep->object_size);
-
-	if (unlikely((flags & __GFP_ZERO) && objp))
-		memset(objp, 0, cachep->object_size);
+		if (unlikely(flags & __GFP_ZERO))
+			memset(objp, 0, cachep->object_size);
+	}
 
 	return objp;
 }


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] slab: Make allocations with GFP_ZERO slightly more efficient
  2013-09-11  0:02 [PATCH] slab: Make allocations with GFP_ZERO slightly more efficient Joe Perches
@ 2013-09-11 14:17 ` Christoph Lameter
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Lameter @ 2013-09-11 14:17 UTC (permalink / raw)
  To: Joe Perches; +Cc: Pekka Enberg, Matt Mackall, linux-mm, LKML

On Tue, 10 Sep 2013, Joe Perches wrote:

> Use the likely mechanism already around valid
> pointer tests to better choose when to memset
> to 0 allocations with __GFP_ZERO

Ok but that is not that important since the first ptr check is only for
debuggin.

Acked-by: Christoph Lameter <cl@linux.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-09-11 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11  0:02 [PATCH] slab: Make allocations with GFP_ZERO slightly more efficient Joe Perches
2013-09-11 14:17 ` Christoph Lameter

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