Thread (8 messages) 8 messages, 4 authors, 2011-02-18

some questions about kernel source

From: John Mahoney <hidden>
Date: 2011-02-18 17:16:09

On Fri, Feb 18, 2011 at 9:28 AM, loody [off-list ref] wrote:
hi :


2011/2/18 John Mahoney [off-list ref]:
quoted
On Thu, Feb 17, 2011 at 9:17 AM, loody [off-list ref] wrote:
quoted
hi :-)

2011/2/16 Mulyadi Santosa [off-list ref]:
quoted
Hi :)

On Wed, Feb 16, 2011 at 12:59, Rajat Jain [off-list ref] wrote:
quoted
Hello loody,
quoted
1. in kernel/trace, I always see "__read_mostly" at the end of
parameter is that a compiler optimization parameter?
Yes, it is a hint to the compiler that the parameter is mostly read, thus if the compiler has to make a decision between optimizing one of the read / write paths, it will optimize the read path even at the expense of write path.

To be precise, they will be grouped into same cache line as much as
possible. By doing so, those cache line won't be invalidated so often
(keeping them "hot" :) hehehhe )
I cannot find it on the gcc manual.
is it a option in kernel for kernel usage?
if so, where I can found them.
If not, can I use it on normal user level program?
It is a macro defined for x86 as:

#define __read_mostly __attribute__((__section__(".data..read_mostly")))

http://lxr.linux.no/linux+v2.6.37/arch/x86/include/asm/cache.h
I found where you pointed out but I try to find out where is it in the
mips arch.
It looks pretty new for mips and you may have older code.

$ git log -p cache.h
commit 1befdd5536e1500371f7f884d0f0ae528a519333
Author: David Daney [off-list ref]
Date:   Thu Oct 14 12:36:49 2010 -0700

    MIPS: Implement __read_mostly
commit 1befdd5536e1500371f7f884d0f0ae528a519333
Author: David Daney [off-list ref]
Date:   Thu Oct 14 12:36:49 2010 -0700

    MIPS: Implement __read_mostly

    Just do what everyone else is doing by placing __read_mostly things in
    the .data.read_mostly section.

    mips_io_port_base can not be read-only (const) and writable
    (__read_mostly) at the same time.  One of them has to go, so I chose
    to eliminate the __read_mostly.  It will still get stuck in a portion
    of memory that is not adjacent to things that are written, and thus
    not be on a dirty cache line, for whatever that is worth.

    Signed-off-by: David Daney [off-list ref]
    To: linux-mips at linux-mips.org
    Patchwork: http://patchwork.linux-mips.org/patch/1702/
    Signed-off-by: Ralf Baechle [off-list ref]

As a side note I would not use this just because you think your
variable is read more than written. Premature optimization is a waste
of time, so make sure your on a hot path before even considering
something like this.


--
John
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help