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: Provide and use free_object_list()

Move the loop to free a list of objects into a helper function so it can be
reused later.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241007164913.453912357@linutronix.de

+16 -6
+16 -6
lib/debugobjects.c
··· 125 125 [ODEBUG_STATE_NOTAVAILABLE] = "not available", 126 126 }; 127 127 128 + static void free_object_list(struct hlist_head *head) 129 + { 130 + struct hlist_node *tmp; 131 + struct debug_obj *obj; 132 + int cnt = 0; 133 + 134 + hlist_for_each_entry_safe(obj, tmp, head, node) { 135 + hlist_del(&obj->node); 136 + kmem_cache_free(obj_cache, obj); 137 + cnt++; 138 + } 139 + debug_objects_freed += cnt; 140 + } 141 + 128 142 static void fill_pool(void) 129 143 { 130 144 gfp_t gfp = __GFP_HIGH | __GFP_NOWARN; ··· 300 286 */ 301 287 static void free_obj_work(struct work_struct *work) 302 288 { 303 - struct hlist_node *tmp; 304 289 struct debug_obj *obj; 305 290 unsigned long flags; 306 291 HLIST_HEAD(tofree); ··· 336 323 */ 337 324 if (obj_nr_tofree) { 338 325 hlist_move_list(&obj_to_free, &tofree); 339 - debug_objects_freed += obj_nr_tofree; 340 326 WRITE_ONCE(obj_nr_tofree, 0); 341 327 } 342 328 raw_spin_unlock_irqrestore(&pool_lock, flags); 343 329 344 - hlist_for_each_entry_safe(obj, tmp, &tofree, node) { 345 - hlist_del(&obj->node); 346 - kmem_cache_free(obj_cache, obj); 347 - } 330 + free_object_list(&tofree); 348 331 } 349 332 350 333 static void __free_object(struct debug_obj *obj) ··· 1343 1334 } 1344 1335 return true; 1345 1336 free: 1337 + /* Can't use free_object_list() as the cache is not populated yet */ 1346 1338 hlist_for_each_entry_safe(obj, tmp, &objects, node) { 1347 1339 hlist_del(&obj->node); 1348 1340 kmem_cache_free(cache, obj);