good explanation of __read_mostly, __init, __exit macros,
Robert P. J. Day
rpjday at crashcourse.ca
Mon Jul 16 08:40:59 EDT 2012
On Mon, 16 Jul 2012, Filipe Rinaldi wrote:
> On 16 July 2012 12:22, Aft nix <aftnix at gmail.com> wrote:
> > Hi,
> >
> > The macro expansion of __read_mostly :
> >
> > #define __read_mostly __attribute__((__section__(".data..read_mostly"))
> >
> > This one is from cache.h
> >
> > __init:
> > #define __init __section(.init.text) __cold notrace
> >
> > from init.h
> >
> > __exit:
> >
> > #define __exit __section(.exit.text) __exitused __cold notrace
> >
> > After searching through net i have not found any good explanation of
> > what is happening there.
> >
> > Additonal question : I have heard about various "linker magic"
> > employed in kernel development. Any information
> > regarding this will be wonderful.
> >
> > cheers
> >
> > --
> > -aft
> >
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
> Hi Aft,
>
> These macros are used to assign a function or initialised variable
> content to a specific section in memory. If you search for the linker
> script of any architecture (*.lds.S files), you will see that these
> variables and functions are placed in specific sections with names
> like "__init_begin" and "__init_end". After the initialisation, Linux
> can re-use for example the "init" memory.
that's what's happening when you see that boot-time message:
"Freeing unused memory ..."
or whatever it is, something to that effect.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the Kernelnewbies
mailing list