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: Reuse put_objects() on OOM

Reuse the helper function instead of having a open coded copy.

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

+6 -18
+6 -18
lib/debugobjects.c
··· 429 429 } 430 430 } 431 431 432 - #ifdef CONFIG_HOTPLUG_CPU 433 432 static void put_objects(struct hlist_head *list) 434 433 { 435 434 struct hlist_node *tmp; ··· 444 445 } 445 446 } 446 447 448 + #ifdef CONFIG_HOTPLUG_CPU 447 449 static int object_cpu_offline(unsigned int cpu) 448 450 { 449 451 /* Remote access is safe as the CPU is dead already */ ··· 456 456 } 457 457 #endif 458 458 459 - /* 460 - * We run out of memory. That means we probably have tons of objects 461 - * allocated. 462 - */ 459 + /* Out of memory. Free all objects from hash */ 463 460 static void debug_objects_oom(void) 464 461 { 465 462 struct debug_bucket *db = obj_hash; 466 - struct hlist_node *tmp; 467 463 HLIST_HEAD(freelist); 468 - struct debug_obj *obj; 469 - unsigned long flags; 470 - int i; 471 464 472 465 pr_warn("Out of memory. ODEBUG disabled\n"); 473 466 474 - for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) { 475 - raw_spin_lock_irqsave(&db->lock, flags); 476 - hlist_move_list(&db->list, &freelist); 477 - raw_spin_unlock_irqrestore(&db->lock, flags); 467 + for (int i = 0; i < ODEBUG_HASH_SIZE; i++, db++) { 468 + scoped_guard(raw_spinlock_irqsave, &db->lock) 469 + hlist_move_list(&db->list, &freelist); 478 470 479 - /* Now free them */ 480 - hlist_for_each_entry_safe(obj, tmp, &freelist, node) { 481 - hlist_del(&obj->node); 482 - free_object(obj); 483 - } 471 + put_objects(&freelist); 484 472 } 485 473 } 486 474