From: Thomas Gleixner <t...@linutronix.de>

commit ccf6bfd49a8a7d25bacc8e84ec5dbdfe513c29c3 in linux-stable-rt

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: 63a759694eed ("debugobject: Prevent init race with static objects")
Reported-by: Ido Schimmel <ido...@nvidia.com>
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Tested-by: Ido Schimmel <ido...@nvidia.com>
Link: https://lore.kernel.org/r/871qk05a9d.ffs@tglx

(cherry picked from commit 0af462f19e635ad522f28981238334620881badc)
Signed-off-by: Joseph Salisbury <joseph.salisb...@canonical.com>
Signed-off-by: Paul Gortmaker <paul.gortma...@windriver.com>
---
 lib/debugobjects.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 579406c1e9ed..4c39678c03ee 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -590,6 +590,16 @@ static struct debug_obj *lookup_object_or_alloc(void 
*addr, struct debug_bucket
        return NULL;
 }
 
+static void debug_objects_fill_pool(void)
+{
+       /*
+        * On RT enabled kernels the pool refill must happen in preemptible
+        * context:
+        */
+       if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible())
+               fill_pool();
+}
+
 static void
 __debug_object_init(void *addr, const struct debug_obj_descr *descr, int 
onstack)
 {
@@ -598,12 +608,7 @@ __debug_object_init(void *addr, const struct 
debug_obj_descr *descr, int onstack
        struct debug_obj *obj;
        unsigned long flags;
 
-       /*
-        * On RT enabled kernels the pool refill must happen in preemptible
-        * context:
-        */
-       if (!IS_ENABLED(CONFIG_PREEMPT_RT) || preemptible())
-               fill_pool();
+       debug_objects_fill_pool();
 
        db = get_bucket((unsigned long) addr);
 
@@ -688,6 +693,8 @@ int debug_object_activate(void *addr, const struct 
debug_obj_descr *descr)
        if (!debug_objects_enabled)
                return 0;
 
+       debug_objects_fill_pool();
+
        db = get_bucket((unsigned long) addr);
 
        raw_spin_lock_irqsave(&db->lock, flags);
@@ -897,6 +904,8 @@ void debug_object_assert_init(void *addr, const struct 
debug_obj_descr *descr)
        if (!debug_objects_enabled)
                return;
 
+       debug_objects_fill_pool();
+
        db = get_bucket((unsigned long) addr);
 
        raw_spin_lock_irqsave(&db->lock, flags);
-- 
2.40.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13405): 
https://lists.yoctoproject.org/g/linux-yocto/message/13405
Mute This Topic: https://lists.yoctoproject.org/mt/103055693/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to