@@ -429,7 +429,6 @@ static void free_object(struct debug_obj *obj)
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 ;
@@ -445,6 +444,7 @@ static void put_objects(struct hlist_head *list)
445
444
}
446
445
}
447
446
447
+ #ifdef CONFIG_HOTPLUG_CPU
448
448
static int object_cpu_offline (unsigned int cpu )
449
449
{
450
450
/* Remote access is safe as the CPU is dead already */
@@ -456,31 +456,19 @@ static int object_cpu_offline(unsigned int cpu)
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
0 commit comments