diff options
author | Joe Perches <joe@perches.com> | 2013-09-10 20:02:51 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2014-02-08 05:19:02 -0500 |
commit | 5087c8229986cc502c807a15f8ea416b0ef22346 (patch) | |
tree | ad1380499f4d5b8e732fef94ebc8fa248f374a38 /mm/slab.c | |
parent | 8fc9cf420b369ad1d8c2e66fb552a985c4676073 (diff) |
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: Christoph Lameter <cl@linux.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -3278,11 +3278,11 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid, | |||
3278 | kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags, | 3278 | kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags, |
3279 | flags); | 3279 | flags); |
3280 | 3280 | ||
3281 | if (likely(ptr)) | 3281 | if (likely(ptr)) { |
3282 | kmemcheck_slab_alloc(cachep, flags, ptr, cachep->object_size); | 3282 | kmemcheck_slab_alloc(cachep, flags, ptr, cachep->object_size); |
3283 | 3283 | if (unlikely(flags & __GFP_ZERO)) | |
3284 | if (unlikely((flags & __GFP_ZERO) && ptr)) | 3284 | memset(ptr, 0, cachep->object_size); |
3285 | memset(ptr, 0, cachep->object_size); | 3285 | } |
3286 | 3286 | ||
3287 | return ptr; | 3287 | return ptr; |
3288 | } | 3288 | } |
@@ -3343,11 +3343,11 @@ slab_alloc(struct kmem_cache *cachep, gfp_t flags, unsigned long caller) | |||
3343 | flags); | 3343 | flags); |
3344 | prefetchw(objp); | 3344 | prefetchw(objp); |
3345 | 3345 | ||
3346 | if (likely(objp)) | 3346 | if (likely(objp)) { |
3347 | kmemcheck_slab_alloc(cachep, flags, objp, cachep->object_size); | 3347 | kmemcheck_slab_alloc(cachep, flags, objp, cachep->object_size); |
3348 | 3348 | if (unlikely(flags & __GFP_ZERO)) | |
3349 | if (unlikely((flags & __GFP_ZERO) && objp)) | 3349 | memset(objp, 0, cachep->object_size); |
3350 | memset(objp, 0, cachep->object_size); | 3350 | } |
3351 | 3351 | ||
3352 | return objp; | 3352 | return objp; |
3353 | } | 3353 | } |