[RFC PATCH 19/25] perf stat: Handle grouping method fall back in hardware-grouping

weilin.wang
2023-09-25T06:21:09Z

Add fall back to normal grouping when hardware aware grouping return with
err so that perf stat still executes and returns with correct result.

Signed-off-by: Weilin Wang <weilin.wang@intel.com>
---
tools/perf/util/metricgroup.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 1086da84c..c027c0351 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -2054,7 +2054,7 @@ static int create_grouping(struct list_head *pmu_info_list,
LIST_HEAD(groups);
char *bit_buf = malloc(NR_COUNTERS);

- //TODO: for each new core group, we should consider to add events that uses fixed counters
+ //TODO: for each new core group, we could consider to add events that uses fixed counters
list_for_each_entry(e, event_info_list, nd) {
bitmap_scnprintf(e->counters, NR_COUNTERS, bit_buf, NR_COUNTERS);
pr_debug("Event name %s, [pmu]=%s, [counters]=%s, [taken_alone]=%d\n",
@@ -2573,13 +2573,15 @@ int metricgroup__parse_groups(struct evlist *perf_evlist,
if (!table)
return -EINVAL;
if (hardware_aware_grouping) {
+ int ret;
pr_debug("Use hardware aware grouping instead of traditional metric grouping method\n");
- return hw_aware_parse_groups(perf_evlist, pmu, str,
+ ret = hw_aware_parse_groups(perf_evlist, pmu, str,
metric_no_threshold, user_requested_cpu_list, system_wide,
/*fake_pmu=*/NULL, metric_events, table);
+ if (!ret)
+ return 0;
}

-
return parse_groups(perf_evlist, pmu, str, metric_no_group, metric_no_merge,
metric_no_threshold, user_requested_cpu_list, system_wide,
/*fake_pmu=*/NULL, metric_events, table);
--
2.39.3