linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Ravi Bangoria <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@kernel.org, linux-kernel@vger.kernel.org,
	tglx@linutronix.de, alexander.shishkin@linux.intel.com,
	namhyung@kernel.org, jolsa@redhat.com,
	ravi.bangoria@linux.ibm.com, yao.jin@linux.intel.com,
	acme@redhat.com, mingo@kernel.org, tmricht@linux.vnet.ibm.com,
	anton@samba.org, hpa@zytor.com
Subject: [tip:perf/core] perf stat: Fix shadow stats for clock events
Date: Fri, 14 Dec 2018 12:19:32 -0800	[thread overview]
Message-ID: <tip-6e269c85dcea8a41faac44dbd5130843080f0576@git.kernel.org> (raw)
In-Reply-To: <20181116042843.24067-1-ravi.bangoria@linux.ibm.com>

Commit-ID:  6e269c85dcea8a41faac44dbd5130843080f0576
Gitweb:     https://git.kernel.org/tip/6e269c85dcea8a41faac44dbd5130843080f0576
Author:     Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate: Fri, 16 Nov 2018 09:58:43 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 29 Nov 2018 20:42:46 -0300

perf stat: Fix shadow stats for clock events

Commit 0aa802a79469 ("perf stat: Get rid of extra clock display
function") introduced scale and unit for clock events. Thus,
perf_stat__update_shadow_stats() now saves scaled values of clock events
in msecs, instead of original nsecs. But while calculating values of
shadow stats we still consider clock event values in nsecs. This results
in a wrong shadow stat values. Ex,

  # ./perf stat -e task-clock,cycles ls
    <SNIP>
              2.60 msec task-clock:u    #    0.877 CPUs utilized
         2,430,564      cycles:u        # 1215282.000 GHz

Fix this by saving original nsec values for clock events in
perf_stat__update_shadow_stats(). After patch:

  # ./perf stat -e task-clock,cycles ls
    <SNIP>
              3.14 msec task-clock:u    #    0.839 CPUs utilized
         3,094,528      cycles:u        #    0.985 GHz

Suggested-by: Jiri Olsa <jolsa@redhat.com>
Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: yuzhoujian@didichuxing.com
Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
Link: http://lkml.kernel.org/r/20181116042843.24067-1-ravi.bangoria@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/stat-shadow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index f0a8cec55c47..3c22c58b3e90 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -209,11 +209,12 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
 				    int cpu, struct runtime_stat *st)
 {
 	int ctx = evsel_context(counter);
+	u64 count_ns = count;
 
 	count *= counter->scale;
 
 	if (perf_evsel__is_clock(counter))
-		update_runtime_stat(st, STAT_NSECS, 0, cpu, count);
+		update_runtime_stat(st, STAT_NSECS, 0, cpu, count_ns);
 	else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
 		update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count);
 	else if (perf_stat_evsel__is(counter, CYCLES_IN_TX))

  parent reply	other threads:[~2018-12-14 20:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-15  9:55 [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() for clock events Ravi Bangoria
2018-11-15  9:55 ` [RFC 2/2] perf stat: Fix shadow stats " Ravi Bangoria
2018-11-15 14:17   ` Jiri Olsa
2018-11-16  4:28     ` [PATCH] " Ravi Bangoria
2018-11-16 13:35       ` Jiri Olsa
2018-11-26 18:45         ` Arnaldo Carvalho de Melo
2018-11-27  8:20         ` Ravi Bangoria
2018-11-27 12:37           ` Arnaldo Carvalho de Melo
2018-12-14 20:19       ` tip-bot for Ravi Bangoria [this message]
2018-12-18 13:46       ` [tip:perf/core] " tip-bot for Ravi Bangoria
2018-11-15 13:55 ` [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() " Jiri Olsa
2018-11-15 19:22   ` Arnaldo Carvalho de Melo
2018-11-22  7:13 ` [tip:perf/core] " tip-bot for Ravi Bangoria

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=tip-6e269c85dcea8a41faac44dbd5130843080f0576@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anton@samba.org \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=ravi.bangoria@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=tmricht@linux.vnet.ibm.com \
    --cc=yao.jin@linux.intel.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;
as well as URLs for NNTP newsgroup(s).