Skip to content

Commit e4757c7

Browse files
Zhen LeiKAGA-KOKO
authored andcommitted
debugobjects: Fix the compilation attributes of some global variables
1. Both debug_objects_pool_min_level and debug_objects_pool_size are read-only after initialization, change attribute '__read_mostly' to '__ro_after_init', and remove '__data_racy'. 2. Many global variables are read in the debug_stats_show() function, but didn't mask KCSAN's detection. Add '__data_racy' for them. Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20240904133944.2124-2-thunder.leizhen@huawei.com
1 parent 431c164 commit e4757c7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/debugobjects.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ static HLIST_HEAD(obj_to_free);
7070
* made at debug_stats_show(). Both obj_pool_min_free and obj_pool_max_used
7171
* can be off.
7272
*/
73-
static int obj_pool_min_free = ODEBUG_POOL_SIZE;
74-
static int obj_pool_free = ODEBUG_POOL_SIZE;
73+
static int __data_racy obj_pool_min_free = ODEBUG_POOL_SIZE;
74+
static int __data_racy obj_pool_free = ODEBUG_POOL_SIZE;
7575
static int obj_pool_used;
76-
static int obj_pool_max_used;
76+
static int __data_racy obj_pool_max_used;
7777
static bool obj_freeing;
7878
/* The number of objs on the global free list */
7979
static int obj_nr_tofree;
@@ -84,9 +84,9 @@ static int __data_racy debug_objects_fixups __read_mostly;
8484
static int __data_racy debug_objects_warnings __read_mostly;
8585
static int __data_racy debug_objects_enabled __read_mostly
8686
= CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT;
87-
static int __data_racy debug_objects_pool_size __read_mostly
87+
static int debug_objects_pool_size __ro_after_init
8888
= ODEBUG_POOL_SIZE;
89-
static int __data_racy debug_objects_pool_min_level __read_mostly
89+
static int debug_objects_pool_min_level __ro_after_init
9090
= ODEBUG_POOL_MIN_LEVEL;
9191

9292
static const struct debug_obj_descr *descr_test __read_mostly;
@@ -95,8 +95,8 @@ static struct kmem_cache *obj_cache __ro_after_init;
9595
/*
9696
* Track numbers of kmem_cache_alloc()/free() calls done.
9797
*/
98-
static int debug_objects_allocated;
99-
static int debug_objects_freed;
98+
static int __data_racy debug_objects_allocated;
99+
static int __data_racy debug_objects_freed;
100100

101101
static void free_obj_work(struct work_struct *work);
102102
static DECLARE_DELAYED_WORK(debug_obj_work, free_obj_work);

0 commit comments

Comments
 (0)