Re: [patch 03/25] debugobjects: Dont destroy kmem cache in init()
From: Leizhen (ThunderTown)
Date: Fri Oct 11 2024 - 21:51:01 EST
On 2024/10/12 4:37, Thomas Gleixner wrote:
> On Thu, Oct 10 2024 at 21:31, Leizhen wrote:
>> On 2024/10/10 19:46, Thomas Gleixner wrote:
>>> On Thu, Oct 10 2024 at 10:14, Leizhen wrote:
>>>> On 2024/10/8 0:49, Thomas Gleixner wrote:
>>>>> - if (!obj_cache || debug_objects_replace_static_objects()) {
>>>>> + if (!cache || !debug_objects_replace_static_objects(cache)) {
>>>>> debug_objects_enabled = 0;
>>>>> - kmem_cache_destroy(obj_cache);
>>>>
>>>> kmem_cache_destroy(cache) should be kept, or move it into debug_objects_replace_static_objects()
>>>> and place it above 'return false'.
>>>
>>> At that point it can't be destroyed. See the backtrace.
>>>
>>> So we just give the objects back and leak the kmem_cache.
>>
>> Oh, sorry, I didn't figure it out before, but now I do.
>> But shouldn't we add kmemleak_ignore(cache) ?
>
> I don't know if it's worth the trouble. With the follow up changes the
> only reason why this can happen is that the static object conversion
> cannot allocate memory. Leaking the kmemcache in that case is the least
> of the worries.
>
> I just tripped over that back trace because I intentionally triggered
> the error path.
Yes, that's an error path that almost never goes to.
OK, so keep it still.
>
> Thanks,
>
> tglx
>
>
> .
>
--
Regards,
Zhen Lei