Re: __initdata query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 15 Mar 2008, Peter Teoh wrote:

> Hi Thomas Petazzoni,
>
> On Fri, Mar 14, 2008 at 10:06 PM, Peter Teoh <htmldeveloper@xxxxxxxxx> 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?

the ELF section is actually named ".init.data", i think, not
"__initdata".  anything tagged as __initdata is *placed* in the
.init.data section.

> first, the memory freeing must be triggered only after the __initdata
> functions have been executed - how does the kernel knows that?

i'm assuming you meant "after the **__init** functions have been
executed", right?

> 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?

i believe all of that is done in the module loader code in
kernel/module.c.  specifically this section:

      DEBUGP("Core section allocation order:\n");
        for (m = 0; m < ARRAY_SIZE(masks); ++m) {
                for (i = 0; i < hdr->e_shnum; ++i) {
                        Elf_Shdr *s = &sechdrs[i];

                        if ((s->sh_flags & masks[m][0]) != masks[m][0]
                            || (s->sh_flags & masks[m][1])
                            || s->sh_entsize != ~0UL
                            || strncmp(secstrings + s->sh_name,
                                       ".init", 5) == 0)    <------
                                continue;
                        s->sh_entsize = get_offset(&mod->core_size, s);
                        DEBUGP("\t%s\n", secstrings + s->sh_name);
                }
                if (m == 0)
                        mod->core_text_size = mod->core_size;


and a very similar chunk of code immediately after that.  i haven't
looked at it carefully, but it certainly seems that any section whose
name starts with ".init" is being bypassed for normal processing.

rday

p.s.  what is the difference between those two code chunks?  the first
refers to "Core section allocation order" while the second is "Init
section allocation order".  can someone explain that so i can be lazy
and not have to read it myself?

--

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
    Have classroom, will lecture.

http://crashcourse.ca                          Waterloo, Ontario, CANADA
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux