Skip to content

Commit d3f661d

Browse files
Christoph Lameterpenberg
authored andcommitted
slub: Get rid of slab_free_hook_irq()
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 <[email protected]> Signed-off-by: Pekka Enberg <[email protected]>
1 parent 1a757fe commit d3f661d

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

mm/slub.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -807,14 +807,24 @@ static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, void
807807
static inline void slab_free_hook(struct kmem_cache *s, void *x)
808808
{
809809
kmemleak_free_recursive(x, s->flags);
810-
}
811810

812-
static inline void slab_free_hook_irq(struct kmem_cache *s, void *object)
813-
{
814-
kmemcheck_slab_free(s, object, s->objsize);
815-
debug_check_no_locks_freed(object, s->objsize);
816-
if (!(s->flags & SLAB_DEBUG_OBJECTS))
817-
debug_check_no_obj_freed(object, s->objsize);
811+
/*
812+
* Trouble is that we may no longer disable interupts in the fast path
813+
* So in order to make the debug calls that expect irqs to be
814+
* disabled we need to disable interrupts temporarily.
815+
*/
816+
#if defined(CONFIG_KMEMCHECK) || defined(CONFIG_LOCKDEP)
817+
{
818+
unsigned long flags;
819+
820+
local_irq_save(flags);
821+
kmemcheck_slab_free(s, x, s->objsize);
822+
debug_check_no_locks_freed(x, s->objsize);
823+
if (!(s->flags & SLAB_DEBUG_OBJECTS))
824+
debug_check_no_obj_freed(x, s->objsize);
825+
local_irq_restore(flags);
826+
}
827+
#endif
818828
}
819829

820830
/*
@@ -1101,9 +1111,6 @@ static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags,
11011111

11021112
static inline void slab_free_hook(struct kmem_cache *s, void *x) {}
11031113

1104-
static inline void slab_free_hook_irq(struct kmem_cache *s,
1105-
void *object) {}
1106-
11071114
#endif /* CONFIG_SLUB_DEBUG */
11081115

11091116
/*
@@ -1909,8 +1916,6 @@ static __always_inline void slab_free(struct kmem_cache *s,
19091916
local_irq_save(flags);
19101917
c = __this_cpu_ptr(s->cpu_slab);
19111918

1912-
slab_free_hook_irq(s, x);
1913-
19141919
if (likely(page == c->page && c->node != NUMA_NO_NODE)) {
19151920
set_freepointer(s, object, c->freelist);
19161921
c->freelist = object;

0 commit comments

Comments
 (0)