Skip to content

Commit a9ee3a6

Browse files
Qian Caitorvalds
authored andcommitted
debugobjects: call debug_objects_mem_init eariler
The current value of the early boot static pool size, 1024 is not big enough for systems with large number of CPUs with timer or/and workqueue objects selected. As the results, systems have 60+ CPUs with both timer and workqueue objects enabled could trigger "ODEBUG: Out of memory. ODEBUG disabled". Some debug objects are allocated during the early boot. Enabling some options like timers or workqueue objects may increase the size required significantly with large number of CPUs. For example, CONFIG_DEBUG_OBJECTS_TIMERS: No. CPUs x 2 (worker pool) objects: start_kernel workqueue_init_early init_worker_pool init_timer_key debug_object_init plus No. CPUs objects (CONFIG_HIGH_RES_TIMERS): sched_init hrtick_rq_init hrtimer_init CONFIG_DEBUG_OBJECTS_WORK: No. CPUs objects: vmalloc_init __init_work plus No. CPUs x 6 (workqueue) objects: workqueue_init_early alloc_workqueue __alloc_workqueue_key alloc_and_link_pwqs init_pwq Also, plus No. CPUs objects: perf_event_init __init_srcu_struct init_srcu_struct_fields init_srcu_struct_nodes __init_work However, none of the things are actually used or required before debug_objects_mem_init() is invoked, so just move the call right before vmalloc_init(). According to tglx, "the reason why the call is at this place in start_kernel() is historical. It's because back in the days when debugobjects were added the memory allocator was enabled way later than today." Link: http://lkml.kernel.org/r/20181126102407.1836-1-cai@gmx.us Signed-off-by: Qian Cai <cai@gmx.us> Suggested-by: Thomas Gleixner <tglx@linutronix.de> Cc: Waiman Long <longman@redhat.com> Cc: Yang Shi <yang.shi@linux.alibaba.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4494ce4 commit a9ee3a6

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎init/main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ static void __init mm_init(void)
521521
mem_init();
522522
kmem_cache_init();
523523
pgtable_init();
524+
debug_objects_mem_init();
524525
vmalloc_init();
525526
ioremap_huge_init();
526527
/* Should be run before the first non-init thread is created */
@@ -697,7 +698,6 @@ asmlinkage __visible void __init start_kernel(void)
697698
#endif
698699
page_ext_init();
699700
kmemleak_init();
700-
debug_objects_mem_init();
701701
setup_per_cpu_pageset();
702702
numa_policy_init();
703703
acpi_early_init();

‎lib/debugobjects.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,11 +1131,10 @@ static int __init debug_objects_replace_static_objects(void)
11311131
}
11321132

11331133
/*
1134-
* When debug_objects_mem_init() is called we know that only
1135-
* one CPU is up, so disabling interrupts is enough
1136-
* protection. This avoids the lockdep hell of lock ordering.
1134+
* debug_objects_mem_init() is now called early that only one CPU is up
1135+
* and interrupts have been disabled, so it is safe to replace the
1136+
* active object references.
11371137
*/
1138-
local_irq_disable();
11391138

11401139
/* Remove the statically allocated objects from the pool */
11411140
hlist_for_each_entry_safe(obj, tmp, &obj_pool, node)
@@ -1156,7 +1155,6 @@ static int __init debug_objects_replace_static_objects(void)
11561155
cnt++;
11571156
}
11581157
}
1159-
local_irq_enable();
11601158

11611159
pr_debug("%d of %d active objects replaced\n",
11621160
cnt, obj_pool_used);

0 commit comments

Comments
 (0)