From: Peter Zijlstra <peterz@infradead.org>
To: John Stultz <john.stultz@linaro.org>
Cc: "Paweł Moll" <pawel.moll@arm.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Ingo Molnar" <mingo@kernel.org>,
"Stephane Eranian" <eranian@google.com>,
lkml <linux-kernel@vger.kernel.org>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"David Ahern" <dsahern@gmail.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Jiri Olsa" <jolsa@redhat.com>,
"Namhyung Kim" <namhyung@gmail.com>,
"Paul Mackerras" <paulus@samba.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Sonny Rao" <sonnyrao@chromium.org>,
"ak@linux.intel.com" <ak@linux.intel.com>,
vincent.weaver@maine.edu
Subject: Re: [RFC][PATCH 1/2] time: Add ktime_get_mono_raw_fast_ns()
Date: Fri, 20 Feb 2015 21:11:37 +0100 [thread overview]
Message-ID: <20150220201137.GE23367@worktop.ger.corp.intel.com> (raw)
In-Reply-To: <CALAqxLUH0-L+NiDS7175Edt8NpOCskmgf6KPfGzafVpxTEBnaw@mail.gmail.com>
On Fri, Feb 20, 2015 at 11:49:49AM -0800, John Stultz wrote:
> On Fri, Feb 20, 2015 at 6:29 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> > +u64 notrace ktime_get_mono_raw_fast_ns(void)
> > +{
> > + struct tk_read_base *tkr;
> > + unsigned int seq;
> > + u64 now;
> > +
> > + do {
> > + seq = raw_read_seqcount(&tk_fast_mono_raw.seq);
> > + tkr = tk_fast_mono_raw.base + (seq & 0x01);
> > + now = ktime_to_ns(tkr->base_mono) + timekeeping_get_ns(tkr);
>
>
> So this doesn't look right. I think you want to use tk->base_raw and
> timekeeping_get_ns_raw() here?
No, the problem is that timekeeping_get_ns_raw() dereferences
tkr->clock. The idea was to, like ktime_get_mono_fast_ns() only touch
the _1_ cacheline.
Clearly I've messed it up, but I didn't want it to go dereference
tkr->clock and pull all kinds of stuff from that second line.
> > + tkr = tk->tkr;
> > + tkr.mult = tk->tkr.clock->mult;
> > + tkr.shift = tk->tkr.clock->shift;
> > + update_fast_timekeeper(&tk_fast_mono_raw, &tkr);
>
> So this is sort of sneaky and subtle here, which will surely cause
> problems later on. You're copying the original mult/shift pair into a
> copy of the tkr, so you get similar results from timekeeping_get_ns()
> as you'd want from timekeeping_get_ns_raw(). This results in multiple
> ways of getting the raw clock.
>
> I think it would be better to either add a new tkr structure for the
> raw clock in the timekeeper, so you can directly copy it over,
OK, this then.
> or
> extend the tkr structure so it can contain the raw values as well.
Can't it would push tk_fast over the _1_ cacheline.
> Also, there's no real reason to have fast/non-fast versions of the raw
> clock. Since it isn't affected by frequency changes, it can't have the
> inconsistency issues the monotonic clock can see (which are documented
> in the comment near ktime_get_mono_fast_ns()). So we can probably
> condense these and avoid duplicative code.
The typical timekeeping_get_ns_raw() still got a seqcount around it
which can fail from NMI (inf loop for all).
So we do nee the tk_fast dual copy seqcount thing just the same, also as
per the above, cacheline cacheline cacheline :)
But yes, I think you're right in that we should be able to condense that
somewhat.
next prev parent reply other threads:[~2015-02-20 20:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-20 14:29 [RFC][PATCH 0/2] On perf and clocks Peter Zijlstra
2015-02-20 14:29 ` [RFC][PATCH 1/2] time: Add ktime_get_mono_raw_fast_ns() Peter Zijlstra
2015-02-20 19:49 ` John Stultz
2015-02-20 20:11 ` Peter Zijlstra [this message]
2015-03-17 11:24 ` Peter Zijlstra
2015-03-18 19:48 ` John Stultz
2015-02-20 14:29 ` [RFC][PATCH 2/2] perf: Add per event clockid support Peter Zijlstra
2015-02-20 15:28 ` Pawel Moll
2015-02-20 16:01 ` Peter Zijlstra
2015-02-23 8:13 ` Adrian Hunter
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=20150220201137.GE23367@worktop.ger.corp.intel.com \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=john.stultz@linaro.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=pawel.moll@arm.com \
--cc=rostedt@goodmis.org \
--cc=sonnyrao@chromium.org \
--cc=tglx@linutronix.de \
--cc=vincent.weaver@maine.edu \
/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
Powered by JetHome