Skip to content

Commit a2a7023

Browse files
committed
debugobjects: Dont free objects directly on CPU hotplug
Freeing the per CPU pool of the unplugged CPU directly is suboptimal as the objects can be reused in the real pool if there is room. Aside of that this gets the accounting wrong. Use the regular free path, which allows reuse and has the accounting correct. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Zhen Lei <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 3f397bf commit a2a7023

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/debugobjects.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -430,27 +430,28 @@ static void free_object(struct debug_obj *obj)
430430
}
431431

432432
#ifdef CONFIG_HOTPLUG_CPU
433-
static int object_cpu_offline(unsigned int cpu)
433+
static void put_objects(struct hlist_head *list)
434434
{
435-
struct debug_percpu_free *percpu_pool;
436435
struct hlist_node *tmp;
437436
struct debug_obj *obj;
438-
unsigned long flags;
439437

440-
/* Remote access is safe as the CPU is dead already */
441-
percpu_pool = per_cpu_ptr(&percpu_obj_pool, cpu);
442-
hlist_for_each_entry_safe(obj, tmp, &percpu_pool->free_objs, node) {
438+
/*
439+
* Using free_object() puts the objects into reuse or schedules
440+
* them for freeing and it get's all the accounting correct.
441+
*/
442+
hlist_for_each_entry_safe(obj, tmp, list, node) {
443443
hlist_del(&obj->node);
444-
kmem_cache_free(obj_cache, obj);
444+
free_object(obj);
445445
}
446+
}
446447

447-
raw_spin_lock_irqsave(&pool_lock, flags);
448-
obj_pool_used -= percpu_pool->obj_free;
449-
debug_objects_freed += percpu_pool->obj_free;
450-
raw_spin_unlock_irqrestore(&pool_lock, flags);
451-
452-
percpu_pool->obj_free = 0;
448+
static int object_cpu_offline(unsigned int cpu)
449+
{
450+
/* Remote access is safe as the CPU is dead already */
451+
struct debug_percpu_free *pcp = per_cpu_ptr(&percpu_obj_pool, cpu);
453452

453+
put_objects(&pcp->free_objs);
454+
pcp->obj_free = 0;
454455
return 0;
455456
}
456457
#endif

0 commit comments

Comments
 (0)