diff options
author | Matthew Wilcox <matthew@wil.cx> | 2007-11-29 14:05:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-30 11:08:05 -0500 |
commit | 80cbd911ca25535f6bb66bbcbb98950ec328eb40 (patch) | |
tree | 5856978e32c675393bc2cb97e3647fc91e27f3bb | |
parent | e1cca7e8d484390169777b423a7fe46c7021fec1 (diff) |
Fix kmem_cache_free performance regression in slab
The database performance group have found that half the cycles spent
in kmem_cache_free are spent in this one call to BUG_ON. Moving it
into the CONFIG_SLAB_DEBUG-only function cache_free_debugcheck() is a
performance win of almost 0.5% on their particular benchmark.
The call was added as part of commit ddc2e812d592457747c4367fb73edcaa8e1e49ff
with the comment that "overhead should be minimal". It may have been
minimal at the time, but it isn't now.
[ Quoth Pekka Enberg: "I don't think the BUG_ON per se caused the
performance regression but rather the virt_to_head_page() changes to
virt_to_cache() that were added later." ]
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Acked-by: Pekka J Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/slab.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -2881,6 +2881,8 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp, | |||
2881 | unsigned int objnr; | 2881 | unsigned int objnr; |
2882 | struct slab *slabp; | 2882 | struct slab *slabp; |
2883 | 2883 | ||
2884 | BUG_ON(virt_to_cache(objp) != cachep); | ||
2885 | |||
2884 | objp -= obj_offset(cachep); | 2886 | objp -= obj_offset(cachep); |
2885 | kfree_debugcheck(objp); | 2887 | kfree_debugcheck(objp); |
2886 | page = virt_to_head_page(objp); | 2888 | page = virt_to_head_page(objp); |
@@ -3759,8 +3761,6 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp) | |||
3759 | { | 3761 | { |
3760 | unsigned long flags; | 3762 | unsigned long flags; |
3761 | 3763 | ||
3762 | BUG_ON(virt_to_cache(objp) != cachep); | ||
3763 | |||
3764 | local_irq_save(flags); | 3764 | local_irq_save(flags); |
3765 | debug_check_no_locks_freed(objp, obj_size(cachep)); | 3765 | debug_check_no_locks_freed(objp, obj_size(cachep)); |
3766 | __cache_free(cachep, objp); | 3766 | __cache_free(cachep, objp); |