[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <459684e7-73bf-fbfb-c666-cc16299d858b@csgroup.eu>
Date: Fri, 5 Nov 2021 18:23:54 +0100
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Andrew Morton <akpm@...ux-foundation.org>,
Daniel Axtens <dja@...ens.net>
Cc: arnd@...db.de, linux-arch@...r.kernel.org,
linux-s390@...r.kernel.org,
Kefeng Wang <wangkefeng.wang@...wei.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Gerald Schaefer <gerald.schaefer@...ux.ibm.com>,
linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v3 2/4] mm: Make generic arch_is_kernel_initmem_freed() do
what it says
Le 04/11/2021 à 22:44, Andrew Morton a écrit :
> On Fri, 01 Oct 2021 17:14:41 +1000 Daniel Axtens <dja@...ens.net> wrote:
>
>>> #ifdef __KERNEL__
>>> +/*
>>> + * Check if an address is part of freed initmem. After initmem is freed,
>>> + * memory can be allocated from it, and such allocations would then have
>>> + * addresses within the range [_stext, _end].
>>> + */
>>> +#ifndef arch_is_kernel_initmem_freed
>>> +static int arch_is_kernel_initmem_freed(unsigned long addr)
>>> +{
>>> + if (system_state < SYSTEM_FREEING_INITMEM)
>>> + return 0;
>>> +
>>> + return init_section_contains((void *)addr, 1);
>>
>> Is init_section_contains sufficient here?
>>
>> include/asm-generic/sections.h says:
>> * [__init_begin, __init_end]: contains .init.* sections, but .init.text.*
>> * may be out of this range on some architectures.
>> * [_sinittext, _einittext]: contains .init.text.* sections
>>
>> init_section_contains only checks __init_*:
>> static inline bool init_section_contains(void *virt, size_t size)
>> {
>> return memory_contains(__init_begin, __init_end, virt, size);
>> }
>>
>> Do we need to check against _sinittext and _einittext?
>>
>> Your proposed generic code will work for powerpc and s390 because those
>> archs only test against __init_* anyway. I don't know if any platform
>> actually does place .init.text outside of __init_begin=>__init_end, but
>> the comment seems to suggest that they could.
>>
>
> Christophe?
>
Sorry for answering late.
I've been thorugh free_initmem() in each architecture. The only sections
involved in the freeing actions are [__init_begin, __init_end], so I
think checking against __init_being, __init_end is enough.
If some architecture has init text outside of this section, then it is
not freed hence not necessary to check.
Christophe
Powered by blists - more mailing lists