<div dir="ltr">Forgot to mention that this 'overlaying' is where 'linker magic' comes into picture. I myself don't know the details though. <br><br><div class="gmail_quote">On Mon, Jul 16, 2012 at 7:56 PM, Gaurav Jain <span dir="ltr"><<a href="mailto:gjainroorkee@gmail.com" target="_blank">gjainroorkee@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">One instance where this 'linker magic' is employed is in the treatment of the variable jiffies. jiffies has been traditionally an 'unsigned long'. Therefore, it occupies 32 bits on 32 bit arch. and 64 bits on 64-bit arch. However, having jiffies just 32-bit long can result in overflows pretty quickly (few days) if the HZ value is large. So, nowadays (2.6 kernel), we have one more variable - jiffies_64, which is 64 bit long. To maintain code compatibility, this 'jiffies_64' is overlayed on the original 'jiffies' variable, so that both variables begin at the same address. Older code can continue to operate as is, while new code can make use of the 'jiffies_64' variable, as and when required.<div>
<br></div><div>Please refer Chapter:11 (Timers and Time Management), Topic: Internal Representation of Jiffies</div><div>Linux Kernel Development, 3rd Edition - Robert Love to read about this.</div><div><br></div><div>Best Regards</div>
<div>Gaurav<div><div class="h5"><br><br><div class="gmail_quote">On Mon, Jul 16, 2012 at 6:10 PM, Robert P. J. Day <span dir="ltr"><<a href="mailto:rpjday@crashcourse.ca" target="_blank">rpjday@crashcourse.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div>On Mon, 16 Jul 2012, Filipe Rinaldi wrote:<br>
<br>
> On 16 July 2012 12:22, Aft nix <<a href="mailto:aftnix@gmail.com" target="_blank">aftnix@gmail.com</a>> wrote:<br>
> > Hi,<br>
> ><br>
> > The macro expansion of __read_mostly :<br>
> ><br>
> > #define __read_mostly __attribute__((__section__(".data..read_mostly"))<br>
> ><br>
> > This one is from cache.h<br>
> ><br>
> > __init:<br>
> > #define __init __section(.init.text) __cold notrace<br>
> ><br>
> > from init.h<br>
> ><br>
> > __exit:<br>
> ><br>
> > #define __exit __section(.exit.text) __exitused __cold notrace<br>
> ><br>
> > After searching through net i have not found any good explanation of<br>
> > what is happening there.<br>
> ><br>
> > Additonal question : I have heard about various "linker magic"<br>
> > employed in kernel development. Any information<br>
> > regarding this will be wonderful.<br>
> ><br>
> > cheers<br>
> ><br>
> > --<br>
> > -aft<br>
> ><br>
> > _______________________________________________<br>
> > Kernelnewbies mailing list<br>
> > <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
> > <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
><br>
> Hi Aft,<br>
><br>
> These macros are used to assign a function or initialised variable<br>
> content to a specific section in memory. If you search for the linker<br>
> script of any architecture (*.lds.S files), you will see that these<br>
> variables and functions are placed in specific sections with names<br>
> like "__init_begin" and "__init_end". After the initialisation, Linux<br>
> can re-use for example the "init" memory.<br>
<br>
</div></div> that's what's happening when you see that boot-time message:<br>
<br>
"Freeing unused memory ..."<br>
<br>
or whatever it is, something to that effect.<br>
<br>
rday<br>
<span><font color="#888888"><br>
--<br>
<br>
========================================================================<br>
Robert P. J. Day Ottawa, Ontario, CANADA<br>
<a href="http://crashcourse.ca" target="_blank">http://crashcourse.ca</a><br>
<br>
Twitter: <a href="http://twitter.com/rpjday" target="_blank">http://twitter.com/rpjday</a><br>
LinkedIn: <a href="http://ca.linkedin.com/in/rpjday" target="_blank">http://ca.linkedin.com/in/rpjday</a><br>
========================================================================<br>
</font></span><div><div><br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr"><font face="arial, helvetica, sans-serif">Gaurav Jain</font><div><font face="arial, helvetica, sans-serif">Associate Software Engineer</font></div>
<div><font face="arial, helvetica, sans-serif">VxVM Escalations Team, SAMG<br></font></div><div><font face="arial, helvetica, sans-serif">Symantec Software India Pvt. Ltd.</font></div><div><font face="arial, helvetica, sans-serif"><br>
<br></font></div></div><br>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font face="arial, helvetica, sans-serif">Gaurav Jain</font><div><font face="arial, helvetica, sans-serif">Associate Software Engineer</font></div>
<div><font face="arial, helvetica, sans-serif">VxVM Escalations Team, SAMG<br></font></div><div><font face="arial, helvetica, sans-serif">Symantec Software India Pvt. Ltd.</font></div><div><font face="arial, helvetica, sans-serif"><br>
<br></font></div></div><br>
</div>