Skip to contentSkip to conversation

perf stat: Update event skip condition

PATCH Superseded Namhyung Kim 3 participants 3 messages Dec 5, 2022 – Dec 6, 2022 perf events

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf stat: Update event skip condition

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

---
Athira, could you please check this fixes the problem?

 tools/perf/util/stat-display.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
tools/perf/util/stat-display.c +9 -7
index 847acdb5dc40..6c0de52ac4be 100644
@@ -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;
 
Signature · 1 line
2.39.0.rc0.267.gcb52ba06e7-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 24 lines · Namhyung Kim

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

---
Athira, could you please check this fixes the problem?

tools/perf/util/stat-display.c | 16 +++++++++-------

1 file changed, 9 insertions(+), 7 deletions(-)
tools/perf/util/stat-display.c +0 -0
index 847acdb5dc40..6c0de52ac4be 100644

tools/perf/util/stat-display.c static void print_counter_aggrdata(struct perf_stat_config *config, · line 819

Quoted 7 lines
tools/perf/util/stat-display.c +2 -1
@@ -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;

Hi Namhyung,

Thanks for the fix.

This patch removes the merged_stat checks from print_aggr and print_aggr_cgroup. We also have this check in print_counter which needs to be removed.

With that change,

Quoted 39 lines
tools/perf/util/stat-display.c +7 -6
 	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;
 
Signature · 1 line
2.39.0.rc0.267.gcb52ba06e7-goog
#2 lore raw

Em Tue, Dec 06, 2022 at 07:45:29PM +0530, Athira Rajeev escreveu:

Quoted 34 lines
Quoted 24 lines · Namhyung Kim

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

---
Athira, could you please check this fixes the problem?

tools/perf/util/stat-display.c | 16 +++++++++-------

1 file changed, 9 insertions(+), 7 deletions(-)
tools/perf/util/stat-display.c +0 -0
index 847acdb5dc40..6c0de52ac4be 100644

tools/perf/util/stat-display.c static void print_counter_aggrdata(struct perf_stat_config *config, · line 819

Quoted 7 lines
tools/perf/util/stat-display.c +2 -1
@@ -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;

Hi Namhyung,

Quoted 6 lines

Thanks for the fix.

This patch removes the merged_stat checks from print_aggr and print_aggr_cgroup. We also have this check in print_counter which needs to be removed.

With that change,

Waiting for v2 then.

- Arnaldo

Quoted 41 lines
Quoted 39 lines
tools/perf/util/stat-display.c +7 -6
 	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;
 
Signature · 1 line
2.39.0.rc0.267.gcb52ba06e7-goog
Signature · 1 line
- Arnaldo