mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Stultz <john.stultz@linaro.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>,
	linux-kernel@vger.kernel.org, Pawel Moll <pawel.moll@arm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Mike Galbraith <efault@gmx.de>, Jiri Olsa <jolsa@redhat.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Stephane Eranian <eranian@google.com>,
	Sonny Rao <sonnyrao@chromium.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] perf: POSIX CLOCK_PERF to report current time value
Date: Wed, 11 Dec 2013 11:37:30 -0800	[thread overview]
Message-ID: <52A8BEFA.8000005@linaro.org> (raw)
In-Reply-To: <20131211120750.GD25541@gmail.com>

On 12/11/2013 04:07 AM, Ingo Molnar wrote:
> * John Stultz <john.stultz@linaro.org> wrote:
>
>> [...]
>>
>> I'd much rather see perf export CLOCK_MONOTONIC_RAW timestamps, 
>> since that clockid is well defined. [...]
> So the problem with that clock is that it does the following for every 
> timestamp:
>
>         cycle_now = clock->read(clock);
>
> ... which is impossibly slow if something like the HPET is used, which 
> is rather common - so this is a non-starter to timestamp perf events 
> with. We use the scheduler clock as a reasonable compromise between 
> scalability and clock globality.
>
> I can see two solutions:
>
> 1)
>
> One approach is what I described in my other reply a few minutes ago: 
> track the flow of GTOD, timestamped with the fast perf timestamps, so 
> that GTOD can be correlated to the perf clock, if user-space so 
> wishes. The correlation is simple so this gets close to the ease of 
> use of being able to timestamp GTOD directly.
>
> (That would be useful for other purposes as well, such as 
> instrumenting GTOD updates.)
>
> 2)
>
> An alternate, rather interesting approach would be to change the 
> scheduler clock offset to be influenced by the above events, so that 
> it quasi-approximates GTOD and emits natural time of day timestamps.
>
> This already happens partially in the sched-clock slow path, 
> kernel/sched/clock.c's sched_clock_local(), it uses scd->tick_gtod 
> timestamps to correlate to the monotonic clock. This could be changed 
> over to use not get_ktime() but getnstimeofday(), to get true TOD 
> timestamps.
>
> The trickier bit is the x86 fast-path, in arch/x86/kernel/tsc.c's 
> native_sched_clock(). That relies on __cycles_2_ns() to transform a 
> CPU cycles timestamp into (boot time offset) nanoseconds. For that it 
> uses the cyc2ns_offset percpu variable. That variable could be updated 
> periodically so that it's TOD offset.
>
> My (strong!) preference would be #2, for the simple reason that it 
> would make perf timestamps instantly usable and tooling wouldn't have 
> to do anything to get true timestamps.

Right. #2 is basically what I was (probably poorly) trying to describe
as my ideal solution, making perf export what is essentially
CLOCK_MONOTONIC_RAW time (using CLOCK_MONOTONIC_RAW is more likely to be
easier to match then CLOCK_REALTIME/getnstimeofday(), since you don't
have to deal with anyone setting the clock, or frequency adjustments
from NTP).

thanks
-john


  reply	other threads:[~2013-12-11 19:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10 20:27 David Ahern
2013-12-10 20:44 ` John Stultz
2013-12-11 12:07   ` Ingo Molnar
2013-12-11 19:37     ` John Stultz [this message]
2013-12-11 11:25 ` Ingo Molnar
2013-12-11 11:40   ` Ingo Molnar

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=52A8BEFA.8000005@linaro.org \
    --to=john.stultz@linaro.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=pawel.moll@arm.com \
    --cc=sonnyrao@chromium.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®