[cpuops cmpxchg double V1 3/4] slub: Get rid of slab_free_hook_irq()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Christoph Lameter
Date: Tuesday, December 14, 2010 - 10:48 am

The following patch will make the fastpaths lockless and will no longer
require interrupts to be disabled. Calling the free hook with irq disabled
will no longer be possible.

Move the slab_free_hook_irq() logic into slab_free_hook. Only disable
interrupts if the features are selected that require callbacks with
interrupts off and reenable after calls have been made.

Signed-off-by: Christoph Lameter <cl@linux.com>

---
 mm/slub.c |   29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c	2010-12-14 10:45:11.000000000 -0600
+++ linux-2.6/mm/slub.c	2010-12-14 10:46:40.000000000 -0600
@@ -805,14 +805,24 @@ static inline void slab_post_alloc_hook(
 static inline void slab_free_hook(struct kmem_cache *s, void *x)
 {
 	kmemleak_free_recursive(x, s->flags);
-}
 
-static inline void slab_free_hook_irq(struct kmem_cache *s, void *object)
-{
-	kmemcheck_slab_free(s, object, s->objsize);
-	debug_check_no_locks_freed(object, s->objsize);
-	if (!(s->flags & SLAB_DEBUG_OBJECTS))
-		debug_check_no_obj_freed(object, s->objsize);
+	/*
+	 * Trouble is that we may no longer disable interupts in the fast path
+	 * So in order to make the debug calls that expect irqs to be
+	 * disabled we need to disable interrupts temporarily.
+	 */
+#if defined(CONFIG_KMEMCHECK) || defined(CONFIG_LOCKDEP)
+	{
+		unsigned long flags;
+
+		local_irq_save(flags);
+		kmemcheck_slab_free(s, x, s->objsize);
+		debug_check_no_locks_freed(x, s->objsize);
+		if (!(s->flags & SLAB_DEBUG_OBJECTS))
+			debug_check_no_obj_freed(x, s->objsize);
+		local_irq_restore(flags);
+	}
+#endif
 }
 
 /*
@@ -1099,9 +1109,6 @@ static inline void slab_post_alloc_hook(
 
 static inline void slab_free_hook(struct kmem_cache *s, void *x) {}
 
-static inline void slab_free_hook_irq(struct kmem_cache *s,
-		void *object) {}
-
 #endif /* CONFIG_SLUB_DEBUG */
 
 /*
@@ -1893,8 +1900,6 @@ static __always_inline void slab_free(st
 	local_irq_save(flags);
 	c = __this_cpu_ptr(s->cpu_slab);
 
-	slab_free_hook_irq(s, x);
-
 	if (likely(page == c->page && c->node != NUMA_NO_NODE)) {
 		set_freepointer(s, object, c->freelist);
 		c->freelist = object;

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[cpuops cmpxchg double V1 0/4] this_cpu_cmpxchg_double support, Christoph Lameter, (Tue Dec 14, 10:48 am)
[cpuops cmpxchg double V1 1/4] Generic support for this_cp ..., Christoph Lameter, (Tue Dec 14, 10:48 am)
[cpuops cmpxchg double V1 2/4] x86: this_cpu_cmpxchg_doubl ..., Christoph Lameter, (Tue Dec 14, 10:48 am)
[cpuops cmpxchg double V1 3/4] slub: Get rid of slab_free_ ..., Christoph Lameter, (Tue Dec 14, 10:48 am)
[cpuops cmpxchg double V1 4/4] Lockless (and preemptless) ..., Christoph Lameter, (Tue Dec 14, 10:48 am)
Re: [cpuops cmpxchg double V1 2/4] x86: this_cpu_cmpxchg_d ..., Christoph Lameter, (Wed Dec 15, 9:12 am)
Re: [cpuops cmpxchg double V1 2/4] x86: this_cpu_cmpxchg_d ..., Christoph Lameter, (Wed Dec 15, 9:20 am)
Re: [cpuops cmpxchg double V1 2/4] x86: this_cpu_cmpxchg_d ..., Christoph Lameter, (Wed Dec 15, 9:41 am)
Re: [cpuops cmpxchg double V1 2/4] x86: this_cpu_cmpxchg_d ..., Christoph Lameter, (Wed Dec 15, 10:53 am)
Re: [cpuops cmpxchg double V1 1/4] Generic support for thi ..., Christoph Lameter, (Tue Dec 21, 3:36 pm)
Re: [cpuops cmpxchg double V1 1/4] Generic support for thi ..., Christoph Lameter, (Thu Dec 23, 5:16 pm)
Re: [cpuops cmpxchg double V1 1/4] Generic support for thi ..., Christoph Lameter, (Fri Dec 24, 9:53 pm)
Re: [cpuops cmpxchg double V1 1/4] Generic support for thi ..., Christoph Lameter, (Sat Dec 25, 4:55 pm)