Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5087c822 authored by Joe Perches's avatar Joe Perches Committed by Pekka Enberg
Browse files

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

Acked-by: default avatarChristoph Lameter <cl@linux.com>
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarPekka Enberg <penberg@kernel.org>
parent 8fc9cf42
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -3278,11 +3278,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))
		if (unlikely(flags & __GFP_ZERO))
			memset(ptr, 0, cachep->object_size);
	}

	return ptr;
}
@@ -3343,11 +3343,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))
		if (unlikely(flags & __GFP_ZERO))
			memset(objp, 0, cachep->object_size);
	}

	return objp;
}