All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Kennedy <richard@rsk.demon.co.uk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: John Stultz <johnstul@us.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel/timekeeping:  move xtime_cache to be in the same cache line as the lock
Date: Wed, 27 Jan 2010 12:10:26 +0000	[thread overview]
Message-ID: <1264594226.2059.47.camel@localhost> (raw)
In-Reply-To: <20100126152822.d05b5487.akpm@linux-foundation.org>

On Tue, 2010-01-26 at 15:28 -0800, Andrew Morton wrote:
> On Thu, 21 Jan 2010 15:39:21 +0000
> Richard Kennedy <richard@rsk.demon.co.uk> wrote:
> 
> > move xtime_cache to be in the same cache line as the lock
> >     
> > allowing current_kernel_time() to access only one cache line
> 
> Sentences start with capital letters, please.

Sorry about that, I will try harder in future ;)


> 
> I don't know how reliable this is.  I _think_ the compiler and linker
> are free to place variables of this nature in any old place.  Whether
> any of the current tools actually do that I don't know.  Note that one
> of these variables has file-static scope and the other does not, which
> perhaps increases the risk that the compiler or linker will go and
> fiddle with them.
> 
> To do this reliably one would need to put them in a struct:
> 
> time.h:
> 
> extern struct xtime_stuff {
> 	seqlock_t _xtime_lock,
> 	struct timespec _xtime_cache,
> } xtime_stuff;
> 
> #define xtime_lock xtime_stuff._xtime_lock
> 
> 
> timekeeping.c:
> 
> struct xtime_stuff {
> 	._xtime_lock = __SEQLOCK_UNLOCKED(xtime_stuff._xtime_lock),
> };
Thank you, yes that looks like a much better approach.
I can do this if it's needed, but John Stultz said he's going to kill
the xtime_cache anyway, so it may not be worth it?

However I do wonder if we should move all, or at least some, of the
variables protected by that xtime_lock into that structure? Then we can
manage their placement and they would be easier to find. After only a
brief look I see variables in ntp, tick &  timekeeping that seem to be
protected by that seqlock.

> > BTW on 64 bit timespec is a 16 byte structure so the aligned 16 doesn't
> > do much, and on 32bit timepec is 8bytes so this just seems to spread
> > these variables across more cache lines than necessary. Any ideas what
> > this is here for?
> 
> Dunno.  I had a bit of a peek in the git history but it got complicated
> and people rarely bother explaining things like this anyway :(
> 
regards
Richard


  reply	other threads:[~2010-01-27 12:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-21 15:39 [PATCH] kernel/timekeeping: move xtime_cache to be in the same cache line as the lock Richard Kennedy
2010-01-21 17:19 ` john stultz
2010-01-22 11:10   ` Richard Kennedy
2010-01-26 23:28 ` Andrew Morton
2010-01-27 12:10   ` Richard Kennedy [this message]
2010-01-28 20:16     ` john stultz

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=1264594226.2059.47.camel@localhost \
    --to=richard@rsk.demon.co.uk \
    --cc=akpm@linux-foundation.org \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=schwidefsky@de.ibm.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.