aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slub.c
diff options
context:
space:
mode:
authorSatyam Sharma <satyam@infradead.org>2007-10-16 04:24:44 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:42:53 -0400
commit2408c55037c3f7d51a8a100025c47595e71b838c (patch)
tree71940f72dbadf6a6744ffbd062ef4fd8754aa623 /mm/slub.c
parentc92ff1bde06f69d59b40f3194016aee51cc5da55 (diff)
{slub, slob}: use unlikely() for kfree(ZERO_OR_NULL_PTR) check
Considering kfree(NULL) would normally occur only in error paths and kfree(ZERO_SIZE_PTR) is uncommon as well, so let's use unlikely() for the condition check in SLUB's and SLOB's kfree() to optimize for the common case. SLAB has this already. Signed-off-by: Satyam Sharma <satyam@infradead.org> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/slub.c')
-rw-r--r--mm/slub.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mm/slub.c b/mm/slub.c
index edeb942dc8ae..b7d3664fa3a9 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2449,7 +2449,7 @@ size_t ksize(const void *object)
2449 struct page *page; 2449 struct page *page;
2450 struct kmem_cache *s; 2450 struct kmem_cache *s;
2451 2451
2452 if (ZERO_OR_NULL_PTR(object)) 2452 if (unlikely(ZERO_OR_NULL_PTR(object)))
2453 return 0; 2453 return 0;
2454 2454
2455 page = get_object_page(object); 2455 page = get_object_page(object);
@@ -2483,7 +2483,7 @@ void kfree(const void *x)
2483{ 2483{
2484 struct page *page; 2484 struct page *page;
2485 2485
2486 if (ZERO_OR_NULL_PTR(x)) 2486 if (unlikely(ZERO_OR_NULL_PTR(x)))
2487 return; 2487 return;
2488 2488
2489 page = virt_to_head_page(x); 2489 page = virt_to_head_page(x);
@@ -2800,7 +2800,7 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, void *caller)
2800 get_order(size)); 2800 get_order(size));
2801 s = get_slab(size, gfpflags); 2801 s = get_slab(size, gfpflags);
2802 2802
2803 if (ZERO_OR_NULL_PTR(s)) 2803 if (unlikely(ZERO_OR_NULL_PTR(s)))
2804 return s; 2804 return s;
2805 2805
2806 return slab_alloc(s, gfpflags, -1, caller); 2806 return slab_alloc(s, gfpflags, -1, caller);
@@ -2816,7 +2816,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
2816 get_order(size)); 2816 get_order(size));
2817 s = get_slab(size, gfpflags); 2817 s = get_slab(size, gfpflags);
2818 2818
2819 if (ZERO_OR_NULL_PTR(s)) 2819 if (unlikely(ZERO_OR_NULL_PTR(s)))
2820 return s; 2820 return s;
2821 2821
2822 return slab_alloc(s, gfpflags, node, caller); 2822 return slab_alloc(s, gfpflags, node, caller);