linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix kmem_cache_free performance regression in slab
@ 2007-11-29 19:05 Matthew Wilcox
  2007-11-30  2:45 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2007-11-29 19:05 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds, Pekka Enberg; +Cc: linux-kernel, linux-mm

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.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>

diff --git a/mm/slab.c b/mm/slab.c
index cfa6be4..6e16431 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2881,6 +2881,8 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
 	unsigned int objnr;
 	struct slab *slabp;
 
+	BUG_ON(virt_to_cache(objp) != cachep);
+
 	objp -= obj_offset(cachep);
 	kfree_debugcheck(objp);
 	page = virt_to_head_page(objp);
@@ -3759,8 +3761,6 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
 {
 	unsigned long flags;
 
-	BUG_ON(virt_to_cache(objp) != cachep);
-
 	local_irq_save(flags);
 	debug_check_no_locks_freed(objp, obj_size(cachep));
 	__cache_free(cachep, objp);

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-11-30  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-29 19:05 [PATCH] Fix kmem_cache_free performance regression in slab Matthew Wilcox
2007-11-30  2:45 ` Andrew Morton
2007-11-30  9:14   ` Pekka J Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox