linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() for clock events
@ 2018-11-15  9:55 Ravi Bangoria
  2018-11-15  9:55 ` [RFC 2/2] perf stat: Fix shadow stats " Ravi Bangoria
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Ravi Bangoria @ 2018-11-15  9:55 UTC (permalink / raw)
  To: acme, jolsa
  Cc: alexander.shishkin, namhyung, yao.jin, linux-kernel, yuzhoujian,
	tmricht, anton, Ravi Bangoria

We already have function to check if a given event is either
SW_CPU_CLOCK or SW_TASK_CLOCK. Utilize it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/util/stat-shadow.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 8ad32763cfff..f0a8cec55c47 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -212,8 +212,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
 
 	count *= counter->scale;
 
-	if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK) ||
-	    perf_evsel__match(counter, SOFTWARE, SW_CPU_CLOCK))
+	if (perf_evsel__is_clock(counter))
 		update_runtime_stat(st, STAT_NSECS, 0, cpu, count);
 	else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
 		update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFC 2/2] perf stat: Fix shadow stats for clock events
  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 ` Ravi Bangoria
  2018-11-15 14:17   ` Jiri Olsa
  2018-11-15 13:55 ` [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() " Jiri Olsa
  2018-11-22  7:13 ` [tip:perf/core] " tip-bot for Ravi Bangoria
  2 siblings, 1 reply; 13+ messages in thread
From: Ravi Bangoria @ 2018-11-15  9:55 UTC (permalink / raw)
  To: acme, jolsa
  Cc: alexander.shishkin, namhyung, yao.jin, linux-kernel, yuzhoujian,
	tmricht, anton, 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
    <SNIP>
              2.62 msec task-clock:u    #    0.624 CPUs utilized
         2,501,536      cycles:u        # 1250768.000 GHz

Fix this by considering clock events's saved stats in msecs:

  # ./perf stat -e task-clock,cycles ls
    <SNIP>
              2.42 msec task-clock:u    #    0.754 CPUs utilized
         2,338,747      cycles:u        #    1.169 GHz

Note:
The problem with this approach is, we are losing fractional part
while converting nsecs to msecs. This results in a sightly different
values of shadow stats.

Reported-by: Anton Blanchard <anton@samba.org>
Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
---
 tools/perf/util/stat-shadow.c | 13 +++++++------
 tools/perf/util/stat.h        |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index f0a8cec55c47..5b28b278a24e 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <stdio.h>
+#include <linux/time64.h>
 #include "evsel.h"
 #include "stat.h"
 #include "color.h"
@@ -213,7 +214,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
 	count *= counter->scale;
 
 	if (perf_evsel__is_clock(counter))
-		update_runtime_stat(st, STAT_NSECS, 0, cpu, count);
+		update_runtime_stat(st, STAT_MSECS, 0, cpu, count);
 	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))
@@ -873,10 +874,10 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
 	} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) {
 		print_stalled_cycles_backend(config, cpu, evsel, avg, out, st);
 	} else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
-		total = runtime_stat_avg(st, STAT_NSECS, 0, cpu);
+		total = runtime_stat_avg(st, STAT_MSECS, 0, cpu);
 
 		if (total) {
-			ratio = avg / total;
+			ratio = avg / (total * NSEC_PER_MSEC);
 			print_metric(config, ctxp, NULL, "%8.3f", "GHz", ratio);
 		} else {
 			print_metric(config, ctxp, NULL, NULL, "Ghz", 0);
@@ -972,14 +973,14 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config,
 	} else if (evsel->metric_expr) {
 		generic_metric(config, evsel->metric_expr, evsel->metric_events, evsel->name,
 				evsel->metric_name, avg, cpu, out, st);
-	} else if (runtime_stat_n(st, STAT_NSECS, 0, cpu) != 0) {
+	} else if (runtime_stat_n(st, STAT_MSECS, 0, cpu) != 0) {
 		char unit = 'M';
 		char unit_buf[10];
 
-		total = runtime_stat_avg(st, STAT_NSECS, 0, cpu);
+		total = runtime_stat_avg(st, STAT_MSECS, 0, cpu);
 
 		if (total)
-			ratio = 1000.0 * avg / total;
+			ratio = 1000.0 * avg / (total * NSEC_PER_MSEC);
 		if (ratio < 0.001) {
 			ratio *= 1000;
 			unit = 'K';
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h
index 2f9c9159a364..941ad4b0836c 100644
--- a/tools/perf/util/stat.h
+++ b/tools/perf/util/stat.h
@@ -62,7 +62,7 @@ enum {
 
 enum stat_type {
 	STAT_NONE = 0,
-	STAT_NSECS,
+	STAT_MSECS,			/* Milliseconds */
 	STAT_CYCLES,
 	STAT_STALLED_CYCLES_FRONT,
 	STAT_STALLED_CYCLES_BACK,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() for clock events
  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 13:55 ` Jiri Olsa
  2018-11-15 19:22   ` Arnaldo Carvalho de Melo
  2018-11-22  7:13 ` [tip:perf/core] " tip-bot for Ravi Bangoria
  2 siblings, 1 reply; 13+ messages in thread
From: Jiri Olsa @ 2018-11-15 13:55 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: acme, alexander.shishkin, namhyung, yao.jin, linux-kernel,
	yuzhoujian, tmricht, anton

On Thu, Nov 15, 2018 at 03:25:32PM +0530, Ravi Bangoria wrote:
> We already have function to check if a given event is either
> SW_CPU_CLOCK or SW_TASK_CLOCK. Utilize it.
> 
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFC 2/2] perf stat: Fix shadow stats for clock events
  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
  0 siblings, 1 reply; 13+ messages in thread
From: Jiri Olsa @ 2018-11-15 14:17 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: acme, alexander.shishkin, namhyung, yao.jin, linux-kernel,
	yuzhoujian, tmricht, anton

On Thu, Nov 15, 2018 at 03:25:33PM +0530, Ravi Bangoria wrote:
> 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.62 msec task-clock:u    #    0.624 CPUs utilized
>          2,501,536      cycles:u        # 1250768.000 GHz
> 
> Fix this by considering clock events's saved stats in msecs:
> 
>   # ./perf stat -e task-clock,cycles ls
>     <SNIP>
>               2.42 msec task-clock:u    #    0.754 CPUs utilized
>          2,338,747      cycles:u        #    1.169 GHz
> 
> Note:
> The problem with this approach is, we are losing fractional part
> while converting nsecs to msecs. This results in a sightly different
> values of shadow stats.

yea, could we just leave the NSEC instead? like below

jirka


---
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index f4bad808bdd9..da8857df238e 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))

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() for clock events
  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
  0 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-15 19:22 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Ravi Bangoria, alexander.shishkin, namhyung, yao.jin,
	linux-kernel, yuzhoujian, tmricht, anton

Em Thu, Nov 15, 2018 at 02:55:05PM +0100, Jiri Olsa escreveu:
> On Thu, Nov 15, 2018 at 03:25:32PM +0530, Ravi Bangoria wrote:
> > We already have function to check if a given event is either
> > SW_CPU_CLOCK or SW_TASK_CLOCK. Utilize it.
> > 
> > Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> 
> Acked-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied to perf/core.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH] perf stat: Fix shadow stats for clock events
  2018-11-15 14:17   ` Jiri Olsa
@ 2018-11-16  4:28     ` Ravi Bangoria
  2018-11-16 13:35       ` Jiri Olsa
                         ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Ravi Bangoria @ 2018-11-16  4:28 UTC (permalink / raw)
  To: acme, jolsa
  Cc: alexander.shishkin, namhyung, yao.jin, linux-kernel, yuzhoujian,
	tmricht, anton, 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
    <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

Reported-by: Anton Blanchard <anton@samba.org>
Suggested-by: Jiri Olsa <jolsa@redhat.com>
Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.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))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] perf stat: Fix shadow stats for clock events
  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-12-14 20:19       ` [tip:perf/core] " tip-bot for Ravi Bangoria
  2018-12-18 13:46       ` tip-bot for Ravi Bangoria
  2 siblings, 2 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-11-16 13:35 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: acme, alexander.shishkin, namhyung, yao.jin, linux-kernel,
	yuzhoujian, tmricht, anton

On Fri, Nov 16, 2018 at 09:58:43AM +0530, Ravi Bangoria wrote:
> 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
> 
> Reported-by: Anton Blanchard <anton@samba.org>
> Suggested-by: Jiri Olsa <jolsa@redhat.com>
> Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>

Reviewed-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

> ---
>  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))
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tip:perf/core] perf stat: Use perf_evsel__is_clocki() for clock events
  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 13:55 ` [PATCH 1/2] perf stat: Use perf_evsel__is_clocki() " Jiri Olsa
@ 2018-11-22  7:13 ` tip-bot for Ravi Bangoria
  2 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Ravi Bangoria @ 2018-11-22  7:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, jolsa, alexander.shishkin, tglx,
	ravi.bangoria, yao.jin, hpa, tmricht, anton, namhyung, mingo

Commit-ID:  eb08d006054e7e374592068919e32579988602d4
Gitweb:     https://git.kernel.org/tip/eb08d006054e7e374592068919e32579988602d4
Author:     Ravi Bangoria <ravi.bangoria@linux.ibm.com>
AuthorDate: Thu, 15 Nov 2018 15:25:32 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 21 Nov 2018 22:39:57 -0300

perf stat: Use perf_evsel__is_clocki() for clock events

We already have function to check if a given event is either
SW_CPU_CLOCK or SW_TASK_CLOCK. Utilize it.

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anton Blanchard <anton@samba.org>
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
Link: http://lkml.kernel.org/r/20181115095533.16930-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, 1 insertion(+), 2 deletions(-)

diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index 8ad32763cfff..f0a8cec55c47 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -212,8 +212,7 @@ void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 count,
 
 	count *= counter->scale;
 
-	if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK) ||
-	    perf_evsel__match(counter, SOFTWARE, SW_CPU_CLOCK))
+	if (perf_evsel__is_clock(counter))
 		update_runtime_stat(st, STAT_NSECS, 0, cpu, count);
 	else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
 		update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] perf stat: Fix shadow stats for clock events
  2018-11-16 13:35       ` Jiri Olsa
@ 2018-11-26 18:45         ` Arnaldo Carvalho de Melo
  2018-11-27  8:20         ` Ravi Bangoria
  1 sibling, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-26 18:45 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Ravi Bangoria, alexander.shishkin, namhyung, yao.jin,
	linux-kernel, yuzhoujian, tmricht, anton

Em Fri, Nov 16, 2018 at 02:35:55PM +0100, Jiri Olsa escreveu:
> On Fri, Nov 16, 2018 at 09:58:43AM +0530, Ravi Bangoria wrote:
> > 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
> > 
> > Reported-by: Anton Blanchard <anton@samba.org>
> > Suggested-by: Jiri Olsa <jolsa@redhat.com>
> > Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
> > Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> 
> Reviewed-by: Jiri Olsa <jolsa@kernel.org>

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] perf stat: Fix shadow stats for clock events
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Ravi Bangoria @ 2018-11-27  8:20 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, alexander.shishkin, namhyung, yao.jin, linux-kernel,
	yuzhoujian, tmricht, anton, Ravi Bangoria



On 11/16/18 7:05 PM, Jiri Olsa wrote:
> On Fri, Nov 16, 2018 at 09:58:43AM +0530, Ravi Bangoria wrote:
>> 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
>>
>> Reported-by: Anton Blanchard <anton@samba.org>
>> Suggested-by: Jiri Olsa <jolsa@redhat.com>
>> Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
>> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> 
> Reviewed-by: Jiri Olsa <jolsa@kernel.org>

Hi Arnaldo, Please pull this.

Thanks.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] perf stat: Fix shadow stats for clock events
  2018-11-27  8:20         ` Ravi Bangoria
@ 2018-11-27 12:37           ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-11-27 12:37 UTC (permalink / raw)
  To: Ravi Bangoria
  Cc: Jiri Olsa, alexander.shishkin, namhyung, yao.jin, linux-kernel,
	yuzhoujian, tmricht, anton

Em Tue, Nov 27, 2018 at 01:50:44PM +0530, Ravi Bangoria escreveu:
> 
> 
> On 11/16/18 7:05 PM, Jiri Olsa wrote:
> > On Fri, Nov 16, 2018 at 09:58:43AM +0530, Ravi Bangoria wrote:
> >> 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
> >>
> >> Reported-by: Anton Blanchard <anton@samba.org>
> >> Suggested-by: Jiri Olsa <jolsa@redhat.com>
> >> Fixes: 0aa802a79469 ("perf stat: Get rid of extra clock display function")
> >> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> > 
> > Reviewed-by: Jiri Olsa <jolsa@kernel.org>
> 
> Hi Arnaldo, Please pull this.

I did it yesterday, its just that I installed a new notebook and the
MTA was down :-\ All should be fixed by now and the patch should go
Ingo's way soon.

- Arnaldo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tip:perf/core] perf stat: Fix shadow stats for clock events
  2018-11-16  4:28     ` [PATCH] " Ravi Bangoria
  2018-11-16 13:35       ` Jiri Olsa
@ 2018-12-14 20:19       ` tip-bot for Ravi Bangoria
  2018-12-18 13:46       ` tip-bot for Ravi Bangoria
  2 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Ravi Bangoria @ 2018-12-14 20:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, linux-kernel, tglx, alexander.shishkin, namhyung, jolsa,
	ravi.bangoria, yao.jin, acme, mingo, tmricht, anton, hpa

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))

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [tip:perf/core] perf stat: Fix shadow stats for clock events
  2018-11-16  4:28     ` [PATCH] " Ravi Bangoria
  2018-11-16 13:35       ` Jiri Olsa
  2018-12-14 20:19       ` [tip:perf/core] " tip-bot for Ravi Bangoria
@ 2018-12-18 13:46       ` tip-bot for Ravi Bangoria
  2 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Ravi Bangoria @ 2018-12-18 13:46 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, linux-kernel, tmricht, mingo, yao.jin, namhyung, jolsa,
	alexander.shishkin, hpa, acme, ravi.bangoria, tglx, anton

Commit-ID:  57ddf09173c1e7d0511ead8924675c7198e56545
Gitweb:     https://git.kernel.org/tip/57ddf09173c1e7d0511ead8924675c7198e56545
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: Mon, 17 Dec 2018 14:53:30 -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))

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-12-18 13:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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:perf/core] " tip-bot for Ravi Bangoria
2018-12-18 13:46       ` 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

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).