mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: eranian@google.com
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, paulus@samba.org,
	davem@davemloft.net, fweisbec@gmail.com,
	perfmon2-devel@lists.sf.net, eranian@gmail.com,
	robert.richter@amd.com
Subject: Re: [PATCH] perf_events: fix bogus context time tracking
Date: Fri, 15 Oct 2010 15:54:48 +0200	[thread overview]
Message-ID: <1287150888.29097.1516.camel@twins> (raw)
In-Reply-To: <4cb856dc.51edd80a.5ae0.38fb@mx.google.com>

On Fri, 2010-10-15 at 15:26 +0200, Stephane Eranian wrote:
> You can only call update_context_time() when the context
> is active, i.e., the thread it is attached to is still running.
> 
> However, perf_event_read() can be called even when the context
> is inactive, e.g., user read() the counters. The call to
> update_context_time() must be conditioned on the status of
> the context, otherwise, bogus time_enabled, time_running may
> be returned. Here is an example on AMD64. The task program
> is an example from libpfm4. The -p prints deltas every 1s.
> 
> $ task -p -e cpu_clk_unhalted sleep 5
>     2,266,610 cpu_clk_unhalted (0.00% scaling, ena=2,158,982, run=2,158,982)
> 	    0 cpu_clk_unhalted (0.00% scaling, ena=2,158,982, run=2,158,982)
> 	    0 cpu_clk_unhalted (0.00% scaling, ena=2,158,982, run=2,158,982)
> 	    0 cpu_clk_unhalted (0.00% scaling, ena=2,158,982, run=2,158,982)
> 	    0 cpu_clk_unhalted (0.00% scaling, ena=2,158,982, run=2,158,982)
> 5,242,358,071 cpu_clk_unhalted (99.95% scaling, ena=5,000,359,984, run=2,319,270)
> 
> Whereas if you don't read deltas, e.g., no call to perf_event_read() until
> the process terminates:
> 
> $ task -e cpu_clk_unhalted sleep 5
>     2,497,783 cpu_clk_unhalted (0.00% scaling, ena=2,376,899, run=2,376,899)
> 
> Notice that time_enable, time_running are bogus in the first example
> causing bogus scaling.
> 
> This patch fixes the problem, by conditionally calling update_context_time()
> in perf_event_read().
> 
> Signed-off-by: Stephane Eranian <eranian@google.com>

Thanks, tagged it for -stable as well.

  reply	other threads:[~2010-10-15 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15 13:26 Stephane Eranian
2010-10-15 13:54 ` Peter Zijlstra [this message]
2010-10-18 19:17 ` [tip:perf/core] perf_events: Fix " tip-bot for Stephane Eranian

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=1287150888.29097.1516.camel@twins \
    --to=peterz@infradead.org \
    --cc=davem@davemloft.net \
    --cc=eranian@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=perfmon2-devel@lists.sf.net \
    --cc=robert.richter@amd.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 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®