[lkml]   [2018]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 02/75] perf stat: Fix shadow stats for clock events
From: Ravi Bangoria <>

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
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
3.14 msec task-clock:u # 0.839 CPUs utilized
3,094,528 cycles:u # 0.985 GHz

Suggested-by: Jiri Olsa <>
Reported-by: Anton Blanchard <>
Signed-off-by: Ravi Bangoria <>
Reviewed-by: Jiri Olsa <>
Cc: Alexander Shishkin <>
Cc: Jin Yao <>
Cc: Namhyung Kim <>
Cc: Thomas Richter <>
Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
Signed-off-by: Arnaldo Carvalho de Melo <>
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))
 \ /
  Last update: 2018-12-06 22:56    [W:0.020 / U:2.784 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site