Hi,
"Peter Teoh" <[EMAIL PROTECTED]> writes:
> Hi Thomas Petazzoni,
>
> On Fri, Mar 14, 2008 at 10:06 PM, Peter Teoh <[EMAIL PROTECTED]> wrote:
>> >
>> > The tag __initdata is for data used only during initialization (the
>> > data is put in a special ELF section that is discarded after
>> > initialization).
>> >
>> >
>>
>> When is the discarding taking place? Which part of the kernel source
>> code is doing the discarding?
>>
> Just would like ask again does anyone know when is the memory
> discarding (of the ELF section marked as __initdata) taking place?
>
> first, the memory freeing must be triggered only after the __initdata
> functions have been executed - how does the kernel knows that? next,
> this memory freeing MAY be executed while the module is still loaded -
> so someone has to trigger the operation some where. when and where
> -> within the kernel source code -- are these found?
__initdata functions?
As far as I understood it, for modules, it works like this:
When a module is requested to load, the loader parses the ELF file and
allocates memory for the sections and saves pointers to them in a struct
module, including the init section of the module ELF. Then all
init-stuff is and mapped into this executable vmalloc-region. After
->init() has run (defined by module_init()), ->module_init is freed
again. You can see this happen in sys_init_module().
On the other hand, the core kernel init stuff (on x86) is freed in
free_initmem(), called by init_post(), called at the end of
kernel_init() when all __init functions are done.
Hannes
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ