Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

debugobjects: Use static key for boot pool selection

Get rid of the conditional in the hot path.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Zhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/all/20241007164914.077247071@linutronix.de

+11 -8
+11 -8
lib/debugobjects.c
··· 7 7 8 8 #define pr_fmt(fmt) "ODEBUG: " fmt 9 9 10 + #include <linux/cpu.h> 10 11 #include <linux/debugobjects.h> 11 - #include <linux/interrupt.h> 12 + #include <linux/debugfs.h> 13 + #include <linux/hash.h> 14 + #include <linux/kmemleak.h> 12 15 #include <linux/sched.h> 13 16 #include <linux/sched/task_stack.h> 14 17 #include <linux/seq_file.h> 15 - #include <linux/debugfs.h> 16 18 #include <linux/slab.h> 17 - #include <linux/hash.h> 18 - #include <linux/kmemleak.h> 19 - #include <linux/cpu.h> 19 + #include <linux/static_key.h> 20 20 21 21 #define ODEBUG_HASH_BITS 14 22 22 #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS) ··· 102 102 103 103 static void free_obj_work(struct work_struct *work); 104 104 static DECLARE_DELAYED_WORK(debug_obj_work, free_obj_work); 105 + 106 + static DEFINE_STATIC_KEY_FALSE(obj_cache_enabled); 105 107 106 108 static int __init enable_object_debug(char *str) 107 109 { ··· 345 343 { 346 344 struct debug_obj *obj; 347 345 348 - if (likely(obj_cache)) 346 + if (static_branch_likely(&obj_cache_enabled)) 349 347 obj = pcpu_alloc(); 350 348 else 351 349 obj = __alloc_object(&pool_boot); ··· 395 393 static void __free_object(struct debug_obj *obj) 396 394 { 397 395 guard(irqsave)(); 398 - if (likely(obj_cache)) 396 + if (static_branch_likely(&obj_cache_enabled)) 399 397 pcpu_free(obj); 400 398 else 401 399 hlist_add_head(&obj->node, &pool_boot); ··· 574 572 575 573 static void debug_objects_fill_pool(void) 576 574 { 577 - if (unlikely(!obj_cache)) 575 + if (!static_branch_likely(&obj_cache_enabled)) 578 576 return; 579 577 580 578 if (likely(!pool_should_refill(&pool_global))) ··· 1380 1378 1381 1379 /* Everything worked. Expose the cache */ 1382 1380 obj_cache = cache; 1381 + static_branch_enable(&obj_cache_enabled); 1383 1382 1384 1383 #ifdef CONFIG_HOTPLUG_CPU 1385 1384 cpuhp_setup_state_nocalls(CPUHP_DEBUG_OBJ_DEAD, "object:offline", NULL,