All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Saumil Merchant <msaumil@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: perf trace timestamps
Date: Fri, 16 Nov 2012 07:39:40 -0700	[thread overview]
Message-ID: <50A6502C.9030900@gmail.com> (raw)
In-Reply-To: <loom.20121116T140608-755@post.gmane.org>

On 11/16/12 6:07 AM, Saumil Merchant wrote:
> Hi,
> I am trying to understand the origin of the timestamps in the trace output.
> Here is an example trace of a sample C code.
>
> /> perf sched record -a ./a.out
> /> perf script
>
> [ ... ]
> a.out 29311 [000] 1746678.549886: sched_stat_runtime: comm=a.out pid=29311
> runtime=310028 [ns] vruntime=159246710291986646 [ns]
> a.out 29311 [000] 1746678.550885: sched_stat_runtime: comm=a.out pid=29311
> runtime=998470 [ns] vruntime=159246710292985116 [ns]
> a.out 29311 [000] 1746678.550895: sched_stat_runtime: comm=a.out pid=29311
> runtime=11039 [ns] vruntime=159246710292996155 [ns]
> [ ... ]
>
> My original impression was that this timestamp (eg, 1746678.550895) would align
> with time reported clk_gettime(MONOTONIC,...) function, but it does not. My C
> function above prints out timestamps from clk_gettime(MONOTONIC,..)  function
> and there is a delta of >15 mins.
>
> Here is the printout on console:
> CLKTIME (MONOTONIC):  1748132.102228068

At one time many, many releases ago perf timestamps did align with the 
monotonic clock. I have tried (unsuccessfully) to get an option into 
perf to correlate perf events with time-of-day stamps.

>
> This delta has been varying from 5 mins to 15+ mins.  My objective is to
> correlate events in a kernel trace with the execution of our user program.  My
> understanding is that both perf and clk_gettime functions on newer x86 systems
> use TSC as the clock source and hence I was confused why they do not align.
>
> Can someone please help?

See John's explanations in this thread:
https://lkml.org/lkml/2012/10/16/173

David

  reply	other threads:[~2012-11-16 14:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16 13:07 perf trace timestamps Saumil Merchant
2012-11-16 14:39 ` David Ahern [this message]
2012-11-20 11:33   ` Saumil Merchant
2012-11-21 15:54     ` David Ahern
2012-11-27  1:37       ` 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=50A6502C.9030900@gmail.com \
    --to=dsahern@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=msaumil@gmail.com \
    /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.