[PATCH 3/5] debugobjects: Don't start fill if there are remaining nodes locally

From: Zhen Lei
Date: Mon Sep 02 2024 - 10:10:03 EST


If the conditions for starting fill are met, it means that all cores that
call fill() later are blocked until the first core completes the fill
operation. But obviously, for a core that has free nodes locally, it does
not need to be blocked. This is good in stress situations.

Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>
---
lib/debugobjects.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index aba3e62a4315f51..fc8224f9f0eda8f 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -130,10 +130,15 @@ static void fill_pool(void)
gfp_t gfp = __GFP_HIGH | __GFP_NOWARN;
struct debug_obj *obj;
unsigned long flags;
+ struct debug_percpu_free *percpu_pool;

if (likely(READ_ONCE(obj_pool_free) >= debug_objects_pool_min_level))
return;

+ percpu_pool = this_cpu_ptr(&percpu_obj_pool);
+ if (likely(obj_cache) && percpu_pool->obj_free > 0)
+ return;
+
/*
* Reuse objs from the global free list; they will be reinitialized
* when allocating.
--
2.34.1