From: aftnix@gmail.com (Arif Hossain)
To: kernelnewbies@lists.kernelnewbies.org
Subject: good explanation of __read_mostly, __init, __exit macros,
Date: Tue, 17 Jul 2012 17:07:33 +0600 [thread overview]
Message-ID: <1342523253.4679.4.camel@localhost> (raw)
In-Reply-To: <CAGdaadZ73XV4rN9TW_Nk_JtTgsEz9SrLUirP_12TAiFsHfZ4Nw@mail.gmail.com>
On Tue, 2012-07-17 at 02:03 +0700, Mulyadi Santosa wrote:
> Hi :)
>
> On Tue, Jul 17, 2012 at 1:49 AM, Aft nix <aftnix@gmail.com> wrote:
> > This special section, "data..read_mostly" , is it maintained by
> > kernel?
>
> by maintained, you mean allocated? then yes....
>
> > then Linker has to know this information. How that is done?
>
> it is provided by the linker script.... the fastest I can find is in
> directory include/asm-generic/vmlinux.lds.h. This file is not final
> linker script, it's kinda a "template" that will be further modified
> by Kbuild (I guess)
>
> > I mean lets say a.c is compiled into a.o. a.o already has the offsets
> > for its data. Linker resolves the final address. So how the linker is
> > invoked
> > in a way so that this data flagged with __read__mostly will end up in
> > the special section?
>
> it's actually the same like putting your initialized variable in .data
> section, your code in .text and so on. I just get the big picture that
> it is done by creating section in the object file. By section, I think
> it's simply done by creating a mark to denote the section.
>
> please kindly study ELF documentation for further info
>
> > Thing is, i'm getting the idea what these macros mean, but not
> > understanding the mechanisms behind them.
>
> the whole chain is complex actually, but try to get the simple view
> first. it's a grouping, read mostly data into a section/group in a
> file (in this case, kernel image), kernel loaded.....kernel arrange
> itself..put appropriate section into related addresses....done
>
Thanks for the detailed explanation. I've got the idea behind
__read_mostly. I've found a interesting document "Dead code elimination
" which i guess relates to "__init" and "__exit".
Here is the link :
elinux.org/images/2/2d/ELC2010-gc-sections_Denys_Vlasenko.pdf
I'm going to study this post if any question arises.
cheers.
next prev parent reply other threads:[~2012-07-17 11:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 11:22 good explanation of __read_mostly, __init, __exit macros, Aft nix
2012-07-16 12:01 ` Sannu K
2012-07-16 12:29 ` Filipe Rinaldi
2012-07-16 12:40 ` Robert P. J. Day
2012-07-16 14:26 ` Gaurav Jain
2012-07-16 14:27 ` Gaurav Jain
2012-07-16 18:39 ` Mulyadi Santosa
2012-07-16 18:49 ` Aft nix
2012-07-16 19:03 ` Mulyadi Santosa
2012-07-17 11:07 ` Arif Hossain [this message]
2012-07-17 14:19 ` Mulyadi Santosa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342523253.4679.4.camel@localhost \
--to=aftnix@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).