<div dir="ltr">Forgot to mention that this &#39;overlaying&#39; is where &#39;linker magic&#39; comes into picture. I myself don&#39;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">&lt;<a href="mailto:gjainroorkee@gmail.com" target="_blank">gjainroorkee@gmail.com</a>&gt;</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 &#39;linker magic&#39; is employed is in the treatment of the variable jiffies. jiffies has been traditionally an &#39;unsigned long&#39;. 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 &#39;jiffies_64&#39; is overlayed on the original &#39;jiffies&#39; 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 &#39;jiffies_64&#39; 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">&lt;<a href="mailto:rpjday@crashcourse.ca" target="_blank">rpjday@crashcourse.ca</a>&gt;</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>
&gt; On 16 July 2012 12:22, Aft nix &lt;<a href="mailto:aftnix@gmail.com" target="_blank">aftnix@gmail.com</a>&gt; wrote:<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; The macro expansion of __read_mostly :<br>
&gt; &gt;<br>
&gt; &gt; #define __read_mostly __attribute__((__section__(&quot;.data..read_mostly&quot;))<br>
&gt; &gt;<br>
&gt; &gt; This one is from cache.h<br>
&gt; &gt;<br>
&gt; &gt; __init:<br>
&gt; &gt; #define __init          __section(.init.text) __cold notrace<br>
&gt; &gt;<br>
&gt; &gt; from init.h<br>
&gt; &gt;<br>
&gt; &gt; __exit:<br>
&gt; &gt;<br>
&gt; &gt; #define __exit          __section(.exit.text) __exitused __cold notrace<br>
&gt; &gt;<br>
&gt; &gt; After searching through net i have not found any good explanation of<br>
&gt; &gt; what is happening there.<br>
&gt; &gt;<br>
&gt; &gt; Additonal question : I have heard about various &quot;linker magic&quot;<br>
&gt; &gt; employed in kernel development. Any information<br>
&gt; &gt; regarding this will be wonderful.<br>
&gt; &gt;<br>
&gt; &gt; cheers<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; -aft<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; Kernelnewbies mailing list<br>
&gt; &gt; <a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
&gt; &gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
&gt;<br>
&gt;<br>
&gt; Hi Aft,<br>
&gt;<br>
&gt; These macros are used to assign a function or initialised variable<br>
&gt; content to a specific section in memory. If you search for the linker<br>
&gt; script of any architecture (*.lds.S files), you will see that these<br>
&gt; variables and functions are placed in specific sections with names<br>
&gt; like &quot;__init_begin&quot; and &quot;__init_end&quot;. After the initialisation, Linux<br>
&gt; can re-use for example the &quot;init&quot; memory.<br>
<br>
</div></div>  that&#39;s what&#39;s happening when you see that boot-time message:<br>
<br>
&quot;Freeing unused memory ...&quot;<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>