Re: [PATCH 1/5] debugobjects: Fix the misuse of global variables in fill_pool()
From: Thomas Gleixner
Date: Mon Sep 02 2024 - 12:22:55 EST
On Mon, Sep 02 2024 at 22:05, Zhen Lei wrote:
> The global variable 'obj_pool_min_free' records the lowest historical
> value of the number of nodes in the global list 'obj_pool', instead of
> being used as the lowest threshold value. This may be a mistake and
Maybe? It's either a bug or not.
> should be replaced with variable 'debug_objects_pool_min_level'.
And if it's a bug then it has to be replaced.
This misses another minor issue:
static int obj_pool_min_free = ODEBUG_POOL_SIZE;
static int __data_racy debug_objects_pool_min_level __read_mostly
= ODEBUG_POOL_MIN_LEVEL;
As debug_objects_pool_min_level is the minimum level to keep around and
obj_pool_min_free is a statistics mechanism, __data_racy is misplaced
too. The variables should swap their position, because
debug_objects_pool_min_level is functional, but obj_pool_min_free is
pure stats.
Also debug_objects_pool_min_level and debug_objects_pool_size should
be __ro_after_init.
> Fixes: d26bf5056fc0 ("debugobjects: Reduce number of pool_lock acquisitions in fill_pool()")
> Fixes: 36c4ead6f6df ("debugobjects: Add global free list and the counter")
Nice detective work!
Thanks,
tglx