Re: [PATCH] debugobjects: call debug_objects_mem_init eariler

From: Qian Cai
Date: Fri Nov 23 2018 - 21:56:02 EST




> On Nov 23, 2018, at 4:46 PM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> On Thu, 22 Nov 2018, Waiman Long wrote:
>> On 11/22/2018 11:31 PM, Qian Cai wrote:
>>> 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".
>>>
>>> However, none of the things are actually used or required beofre
>
> before
>
>>> debug_objects_mem_init() is invoked.
>>>
>>> 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. So we can just
>>> move the debug_objects_mem_init() call right before sched_init()."
>>>
>>> Afterwards, when calling debug_objects_mem_init(), interrupts have
>>> already been disabled and lockdep_init() will only be called later, so
>>> no need to worry about interrupts in
>>> debug_objects_replace_static_objects().
>
> Just out of curiosity. How many objects are allocated between early and mem
> init?

64-CPU: 68
160-CPU: 164
256-CPU: 260

INIT_WORK(&p->wq, free_work) is called per CPU:

start_kernel
vmalloc_init
__init_work
__debug_object_init

Once debug_objects_mem_init() is moved just before vmalloc_init(), there
is only 1 object.

ODEBUG: 1 of 1 active objects replace

>
>>> diff --git a/lib/debugobjects.c b/lib/debugobjects.c
>>> index 70935ed91125..cc5818ced652 100644
>>> --- a/lib/debugobjects.c
>>> +++ b/lib/debugobjects.c
>>> @@ -1132,13 +1132,6 @@ static int __init debug_objects_replace_static_objects(void)
>>> hlist_add_head(&obj->node, &objects);
>>> }
>>>
>>> - /*
>>> - * 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.
>>> - */
>>> - local_irq_disable();
>>
>> I think you should have a comment saying that debug_objects_mm_init() is
>> called early with only one CPU up and interrupt disabled. So it is safe
>> to replace static objects without any protection.
>
> Yes please.
>
> Thanks,
>
> tglx