]> Gentwo Git Trees - linux/.git/commitdiff
debugobjects: Fix conditions in fill_pool()
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 4 Sep 2024 13:39:40 +0000 (21:39 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 9 Sep 2024 14:40:25 +0000 (16:40 +0200)
fill_pool() uses 'obj_pool_min_free' to decide whether objects should be
handed back to the kmem cache. But 'obj_pool_min_free' records the lowest
historical value of the number of objects in the object pool and not the
minimum number of objects which should be kept in the pool.

Use 'debug_objects_pool_min_level' instead, which holds the minimum number
which was scaled to the number of CPUs at boot time.

[ tglx: Massage change log ]

Fixes: d26bf5056fc0 ("debugobjects: Reduce number of pool_lock acquisitions in fill_pool()")
Fixes: 36c4ead6f6df ("debugobjects: Add global free list and the counter")
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20240904133944.2124-3-thunder.leizhen@huawei.com
lib/debugobjects.c

index 7226fdb5e129a79cebf006821bcdcde0c7d62788..6329a86edcf12ac14bc0094c34d4518feff03fe9 100644 (file)
@@ -142,13 +142,14 @@ static void fill_pool(void)
         * READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical
         * sections.
         */
-       while (READ_ONCE(obj_nr_tofree) && (READ_ONCE(obj_pool_free) < obj_pool_min_free)) {
+       while (READ_ONCE(obj_nr_tofree) &&
+              READ_ONCE(obj_pool_free) < debug_objects_pool_min_level) {
                raw_spin_lock_irqsave(&pool_lock, flags);
                /*
                 * Recheck with the lock held as the worker thread might have
                 * won the race and freed the global free list already.
                 */
-               while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) {
+               while (obj_nr_tofree && (obj_pool_free < debug_objects_pool_min_level)) {
                        obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
                        hlist_del(&obj->node);
                        WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1);