Skip to content

Commit

Permalink
debugobjects: call debug_objects_mem_init eariler
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Qian Cai <[email protected]>
Suggested-by: Thomas Gleixner <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Catalin Marinas <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Qian Cai authored and torvalds committed Dec 28, 2018
1 parent 4494ce4 commit a9ee3a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ static void __init mm_init(void)
mem_init();
kmem_cache_init();
pgtable_init();
debug_objects_mem_init();
vmalloc_init();
ioremap_huge_init();
/* Should be run before the first non-init thread is created */
Expand Down Expand Up @@ -697,7 +698,6 @@ asmlinkage __visible void __init start_kernel(void)
#endif
page_ext_init();
kmemleak_init();
debug_objects_mem_init();
setup_per_cpu_pageset();
numa_policy_init();
acpi_early_init();
Expand Down
8 changes: 3 additions & 5 deletions lib/debugobjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1131,11 +1131,10 @@ static int __init debug_objects_replace_static_objects(void)
}

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

/* Remove the statically allocated objects from the pool */
hlist_for_each_entry_safe(obj, tmp, &obj_pool, node)
Expand All @@ -1156,7 +1155,6 @@ static int __init debug_objects_replace_static_objects(void)
cnt++;
}
}
local_irq_enable();

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

0 comments on commit a9ee3a6

Please sign in to comment.