slab: Make allocations with GFP_ZERO slightly more efficient
PATCH 1/1 slab: Make allocations with GFP_ZERO slightly more efficient
Use the likely mechanism already around valid
pointer tests to better choose when to memset
to 0 allocations with __GFP_ZERO
--- mm/slab.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
mm/slab.c +8 -8
@@ -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 [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>
Quoted 3 lines · Joe Perches
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.
--
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>