[v2] perf stat: Update event skip condition

Message ID 20221206175804.391387-1-namhyung@kernel.org
State New
Headers
Series [v2] perf stat: Update event skip condition |

Commit Message

Namhyung Kim Dec. 6, 2022, 5:58 p.m. UTC
  In print_counter_aggrdata(), it skips some events that has no aggregate
count.  It's actually for system-wide per-thread mode and merged uncore
and hybrid events.

Let's update the condition to check them explicitly.

Fixes: 91f85f98da7a ("Display event stats using aggr counts")
Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Acked-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/stat-display.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
  

Comments

Arnaldo Carvalho de Melo Dec. 7, 2022, 5:37 p.m. UTC | #1
Em Tue, Dec 06, 2022 at 09:58:04AM -0800, Namhyung Kim escreveu:
> In print_counter_aggrdata(), it skips some events that has no aggregate
> count.  It's actually for system-wide per-thread mode and merged uncore
> and hybrid events.
> 
> Let's update the condition to check them explicitly.

Thanks, applied.

- Arnaldo

 
> Fixes: 91f85f98da7a ("Display event stats using aggr counts")
> Reported-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> Acked-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  tools/perf/util/stat-display.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 847acdb5dc40..a45aacc9df64 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -814,7 +814,8 @@ static void print_counter_aggrdata(struct perf_stat_config *config,
>  	os->nr = aggr->nr;
>  	os->evsel = counter;
>  
> -	if (counter->supported && aggr->nr == 0)
> +	/* Skip already merged uncore/hybrid events */
> +	if (counter->merged_stat)
>  		return;
>  
>  	uniquify_counter(config, counter);
> @@ -823,6 +824,13 @@ static void print_counter_aggrdata(struct perf_stat_config *config,
>  	ena = aggr->counts.ena;
>  	run = aggr->counts.run;
>  
> +	/*
> +	 * Skip value 0 when enabling --per-thread globally, otherwise it will
> +	 * have too many 0 output.
> +	 */
> +	if (val == 0 && config->aggr_mode == AGGR_THREAD && config->system_wide)
> +		return;
> +
>  	if (!metric_only) {
>  		if (config->json_output)
>  			fputc('{', output);
> @@ -899,9 +907,6 @@ static void print_aggr(struct perf_stat_config *config,
>  		print_metric_begin(config, evlist, os, s);
>  
>  		evlist__for_each_entry(evlist, counter) {
> -			if (counter->merged_stat)
> -				continue;
> -
>  			print_counter_aggrdata(config, counter, s, os);
>  		}
>  		print_metric_end(config, os);
> @@ -928,9 +933,6 @@ static void print_aggr_cgroup(struct perf_stat_config *config,
>  			print_metric_begin(config, evlist, os, s);
>  
>  			evlist__for_each_entry(evlist, counter) {
> -				if (counter->merged_stat)
> -					continue;
> -
>  				if (counter->cgrp != os->cgrp)
>  					continue;
>  
> @@ -950,9 +952,6 @@ static void print_counter(struct perf_stat_config *config,
>  	if (!config->aggr_map)
>  		return;
>  
> -	if (counter->merged_stat)
> -		return;
> -
>  	for (s = 0; s < config->aggr_map->nr; s++) {
>  		print_counter_aggrdata(config, counter, s, os);
>  	}
> -- 
> 2.39.0.rc0.267.gcb52ba06e7-goog
  

Patch

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 847acdb5dc40..a45aacc9df64 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -814,7 +814,8 @@  static void print_counter_aggrdata(struct perf_stat_config *config,
 	os->nr = aggr->nr;
 	os->evsel = counter;
 
-	if (counter->supported && aggr->nr == 0)
+	/* Skip already merged uncore/hybrid events */
+	if (counter->merged_stat)
 		return;
 
 	uniquify_counter(config, counter);
@@ -823,6 +824,13 @@  static void print_counter_aggrdata(struct perf_stat_config *config,
 	ena = aggr->counts.ena;
 	run = aggr->counts.run;
 
+	/*
+	 * Skip value 0 when enabling --per-thread globally, otherwise it will
+	 * have too many 0 output.
+	 */
+	if (val == 0 && config->aggr_mode == AGGR_THREAD && config->system_wide)
+		return;
+
 	if (!metric_only) {
 		if (config->json_output)
 			fputc('{', output);
@@ -899,9 +907,6 @@  static void print_aggr(struct perf_stat_config *config,
 		print_metric_begin(config, evlist, os, s);
 
 		evlist__for_each_entry(evlist, counter) {
-			if (counter->merged_stat)
-				continue;
-
 			print_counter_aggrdata(config, counter, s, os);
 		}
 		print_metric_end(config, os);
@@ -928,9 +933,6 @@  static void print_aggr_cgroup(struct perf_stat_config *config,
 			print_metric_begin(config, evlist, os, s);
 
 			evlist__for_each_entry(evlist, counter) {
-				if (counter->merged_stat)
-					continue;
-
 				if (counter->cgrp != os->cgrp)
 					continue;
 
@@ -950,9 +952,6 @@  static void print_counter(struct perf_stat_config *config,
 	if (!config->aggr_map)
 		return;
 
-	if (counter->merged_stat)
-		return;
-
 	for (s = 0; s < config->aggr_map->nr; s++) {
 		print_counter_aggrdata(config, counter, s, os);
 	}