mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Drew Richardson <drew.richardson@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	John Stultz <john.stultz@linaro.org>,
	Wade Cherry <Wade.Cherry@arm.com>,
	Pawel Moll <Pawel.Moll@arm.com>
Subject: Re: [PATCH] ftrace: Provide trace clock monotonic raw
Date: Tue, 5 May 2015 07:54:46 -0700	[thread overview]
Message-ID: <20150505145438.GA5145@dreric01-Precision-T1650> (raw)
In-Reply-To: <20150504205748.GB21418@twins.programming.kicks-ass.net>

On Mon, May 04, 2015 at 09:57:48PM +0100, Peter Zijlstra wrote:
> On Mon, May 04, 2015 at 01:05:19PM -0700, Drew Richardson wrote:
> > I'm collecting and merging data from perf, with Android Atrace data
> > (writes to /sys/kernel/debug/tracing/trace_marker) which ends up in
> > the ftrace stream and other measurements collected from
> > userspace. Currently the only clock readable from userspace, supported
> > by perf and by ftrace is CLOCK_MONOTONIC. However this clock is
> > affected by the incremental adjustments performed by adjtime(3) and
> > NTP. 
> 
> Which should not matter at all, right? If both sources are using the
> same clock (they are) then its trivial to merge them and everything
> works as expected.
> 
> > But I'd prefer to use a clock that is advancing at a consistent
> > rate, hence CLOCK_MONOTONIC_RAW.
> 
> Right, Mathieu is asking _why_ you prefer that?
> 

I think John described it well.

On Mon, May 04, 2015 at 09:47:57PM +0100, John Stultz wrote:
> ... [D]uring early initialization, ntp can
> manipulate the CLOCK_MONOTONIC freq more drastically to align time.
> 
> Another more concrete benefit is that since CLOCK_MONOTONIC is
> frequency adjusted, its possible for slight inconsistencies to appear
> when using the lock-free ktime_get_mono_fast_ns() accessor that perf
> uses. With CLOCK_MONOTONIC_RAW, since there are no frequency
> adjustments made, inconsistencies shouldn't occur with the lock-free
> accessor.
>

CLOCK_MONOTONIC_RAW will advance more constantly than CLOCK_MONOTONIC.

Imagine someone is trying to optimize a particular program to reduce
instructions executed for a given workload while minimizing the effect
on runtime. Also suppose that ntp is running and potentially making
larger adjustments to CLOCK_MONOTONIC. If ntp is adjusting
CLOCK_MONOTONIC to advance more rapidly, the program will appear to
use fewer instructions per second but run longer than it would if
CLOCK_MONOTONIC_RAW had been used. The total number of instructions
observed would be the same regardless of the clock source used, but
how it's attributed to time would be affected.

Conversely if ntp is adjusting CLOCK_MONOTONIC to advance more slowly,
the program will appear to use more instructions per second but run
more quickly. Of course there are many sources that can cause jitter
in performance measurements on modern processors, but I'd like to
remove ntp from the list.

Thanks,

Drew

  reply	other threads:[~2015-05-05 16:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 14:41 Drew Richardson
2015-05-04 15:10 ` Mathieu Desnoyers
2015-05-04 20:05   ` Drew Richardson
2015-05-04 20:47     ` John Stultz
2015-05-04 20:57     ` Peter Zijlstra
2015-05-05 14:54       ` Drew Richardson [this message]
2015-05-08  0:42         ` Steven Rostedt
2015-05-08  1:27           ` Mathieu Desnoyers
2015-05-08 14:09         ` Steven Rostedt
2015-05-08 14:29           ` Drew Richardson
2015-05-08 14:30           ` [PATCHv3] " Drew Richardson
2015-05-08 14:41             ` Steven Rostedt
2015-05-08 16:05               ` John Stultz
2015-05-08 16:15                 ` Steven Rostedt
2015-05-08 16:21                   ` John Stultz
2015-05-08 16:11               ` Peter Zijlstra
2015-05-12 14:26               ` Thomas Gleixner
2015-05-12 19:59                 ` Steven Rostedt

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=20150505145438.GA5145@dreric01-Precision-T1650 \
    --to=drew.richardson@arm.com \
    --cc=Pawel.Moll@arm.com \
    --cc=Wade.Cherry@arm.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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®