Skip to content

Commit 684d28f

Browse files
Zhen LeiKAGA-KOKO
authored andcommitted
debugobjects: Fix conditions in fill_pool()
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: d26bf50 ("debugobjects: Reduce number of pool_lock acquisitions in fill_pool()") Fixes: 36c4ead ("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
1 parent e4757c7 commit 684d28f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/debugobjects.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,14 @@ static void fill_pool(void)
142142
* READ_ONCE()s pair with the WRITE_ONCE()s in pool_lock critical
143143
* sections.
144144
*/
145-
while (READ_ONCE(obj_nr_tofree) && (READ_ONCE(obj_pool_free) < obj_pool_min_free)) {
145+
while (READ_ONCE(obj_nr_tofree) &&
146+
READ_ONCE(obj_pool_free) < debug_objects_pool_min_level) {
146147
raw_spin_lock_irqsave(&pool_lock, flags);
147148
/*
148149
* Recheck with the lock held as the worker thread might have
149150
* won the race and freed the global free list already.
150151
*/
151-
while (obj_nr_tofree && (obj_pool_free < obj_pool_min_free)) {
152+
while (obj_nr_tofree && (obj_pool_free < debug_objects_pool_min_level)) {
152153
obj = hlist_entry(obj_to_free.first, typeof(*obj), node);
153154
hlist_del(&obj->node);
154155
WRITE_ONCE(obj_nr_tofree, obj_nr_tofree - 1);

0 commit comments

Comments
 (0)