Skip to content

Commit 0af462f

Browse files
committed
debugobject: Ensure pool refill (again)
The recent fix to ensure atomicity of lookup and allocation inadvertently broke the pool refill mechanism. Prior to that change debug_objects_activate() and debug_objecs_assert_init() invoked debug_objecs_init() to set up the tracking object for statically initialized objects. That's not longer the case and debug_objecs_init() is now the only place which does pool refills. Depending on the number of statically initialized objects this can be enough to actually deplete the pool, which was observed by Ido via a debugobjects OOM warning. Restore the old behaviour by adding explicit refill opportunities to debug_objects_activate() and debug_objecs_assert_init(). Fixes: 63a7596 ("debugobject: Prevent init race with static objects") Reported-by: Ido Schimmel <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Ido Schimmel <[email protected]> Link: https://lore.kernel.org/r/871qk05a9d.ffs@tglx
1 parent 63a7596 commit 0af462f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/debugobjects.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ static struct debug_obj *lookup_object_or_alloc(void *addr, struct debug_bucket
587587
return NULL;
588588
}
589589

590+
static void debug_objects_fill_pool(void)
591+
{
592+
/*
593+
* On RT enabled kernels the pool refill must happen in preemptible
594+
* context:
595+
*/
596+
if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible())
597+
fill_pool();
598+
}
599+
590600
static void
591601
__debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack)
592602
{
@@ -595,12 +605,7 @@ __debug_object_init(void *addr, const struct debug_obj_descr *descr, int onstack
595605
struct debug_obj *obj;
596606
unsigned long flags;
597607

598-
/*
599-
* On RT enabled kernels the pool refill must happen in preemptible
600-
* context:
601-
*/
602-
if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible())
603-
fill_pool();
608+
debug_objects_fill_pool();
604609

605610
db = get_bucket((unsigned long) addr);
606611

@@ -685,6 +690,8 @@ int debug_object_activate(void *addr, const struct debug_obj_descr *descr)
685690
if (!debug_objects_enabled)
686691
return 0;
687692

693+
debug_objects_fill_pool();
694+
688695
db = get_bucket((unsigned long) addr);
689696

690697
raw_spin_lock_irqsave(&db->lock, flags);
@@ -894,6 +901,8 @@ void debug_object_assert_init(void *addr, const struct debug_obj_descr *descr)
894901
if (!debug_objects_enabled)
895902
return;
896903

904+
debug_objects_fill_pool();
905+
897906
db = get_bucket((unsigned long) addr);
898907

899908
raw_spin_lock_irqsave(&db->lock, flags);

0 commit comments

Comments
 (0)