History

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.

Thomas Gleixner committed 2 years ago

Commit a2a70231 parent 3f397bf1 file · +14 −13Browse files

Showing the changes to lib/debugobjects.c (1 of 1 file). Show all

Unified · Split

lib/debugobjects.c+14−13
@@ -430,27 +430,28 @@ static void free_object(struct debug_obj *obj) · 429 unmodified lines
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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t