Skip to content

Commit 4ef3f5a

Browse files
committed
mm/slub: convert object_map_lock to non-raw spinlock
The only remaining user of object_map_lock is list_slab_objects(). Obtaining the lock there used to happen under slab_lock() which implied disabling irqs on PREEMPT_RT, thus it's a raw_spinlock. With the slab_lock() removed, we can convert it to a normal spinlock. Also remove the get_map()/put_map() wrappers as list_slab_objects() became their only remaining user. Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: David Rientjes <rientjes@google.com> Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
1 parent 41bec7c commit 4ef3f5a

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

mm/slub.c

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static inline bool cmpxchg_double_slab(struct kmem_cache *s, struct slab *slab,
565565

566566
#ifdef CONFIG_SLUB_DEBUG
567567
static unsigned long object_map[BITS_TO_LONGS(MAX_OBJS_PER_PAGE)];
568-
static DEFINE_RAW_SPINLOCK(object_map_lock);
568+
static DEFINE_SPINLOCK(object_map_lock);
569569

570570
static void __fill_map(unsigned long *obj_map, struct kmem_cache *s,
571571
struct slab *slab)
@@ -599,30 +599,6 @@ static bool slab_add_kunit_errors(void)
599599
static inline bool slab_add_kunit_errors(void) { return false; }
600600
#endif
601601

602-
/*
603-
* Determine a map of objects in use in a slab.
604-
*
605-
* Node listlock must be held to guarantee that the slab does
606-
* not vanish from under us.
607-
*/
608-
static unsigned long *get_map(struct kmem_cache *s, struct slab *slab)
609-
__acquires(&object_map_lock)
610-
{
611-
VM_BUG_ON(!irqs_disabled());
612-
613-
raw_spin_lock(&object_map_lock);
614-
615-
__fill_map(object_map, s, slab);
616-
617-
return object_map;
618-
}
619-
620-
static void put_map(unsigned long *map) __releases(&object_map_lock)
621-
{
622-
VM_BUG_ON(map != object_map);
623-
raw_spin_unlock(&object_map_lock);
624-
}
625-
626602
static inline unsigned int size_from_object(struct kmem_cache *s)
627603
{
628604
if (s->flags & SLAB_RED_ZONE)
@@ -4368,21 +4344,21 @@ static void list_slab_objects(struct kmem_cache *s, struct slab *slab,
43684344
{
43694345
#ifdef CONFIG_SLUB_DEBUG
43704346
void *addr = slab_address(slab);
4371-
unsigned long flags;
4372-
unsigned long *map;
43734347
void *p;
43744348

43754349
slab_err(s, slab, text, s->name);
43764350

4377-
map = get_map(s, slab);
4351+
spin_lock(&object_map_lock);
4352+
__fill_map(object_map, s, slab);
4353+
43784354
for_each_object(p, s, addr, slab->objects) {
43794355

4380-
if (!test_bit(__obj_to_index(s, addr, p), map)) {
4356+
if (!test_bit(__obj_to_index(s, addr, p), object_map)) {
43814357
pr_err("Object 0x%p @offset=%tu\n", p, p - addr);
43824358
print_tracking(s, p);
43834359
}
43844360
}
4385-
put_map(map);
4361+
spin_unlock(&object_map_lock);
43864362
#endif
43874363
}
43884364

0 commit comments

Comments
 (0)