Re: [RFC PATCH 24/25] perf stat: Add check to ensure correctness in platform that does not support hardware-grouping

From: Liang, Kan
Date: Tue Sep 26 2023 - 12:39:09 EST




On 2023-09-25 2:18 a.m., weilin.wang@xxxxxxxxx wrote:
> From: Weilin Wang <weilin.wang@xxxxxxxxx>
>
> Add check and return with -EINVAL when event json files do not support
> hardware aware grouping so that the program could successfully fall back to
> normal grouping without segfault.

Seems another bug fix. Please merge it with the patch which introduce
the feature/bug.

Thanks,
Kan
>
> Signed-off-by: Weilin Wang <weilin.wang@xxxxxxxxx>
> ---
> tools/perf/util/metricgroup.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
> index 6a4404226..1c89c9371 100644
> --- a/tools/perf/util/metricgroup.c
> +++ b/tools/perf/util/metricgroup.c
> @@ -1684,6 +1684,8 @@ static int metricgroup__add_metric_event_callback(const struct pmu_event *pe,
> struct metricgroup__add_metric_event_data *d = data;
>
> if (!strcasecmp(pe->name, d->event_name)) {
> + if (!pe->counter)
> + return -EINVAL;
> event = event_info__new(d->event_id, pe->pmu, pe->counter,
> pe->taken_alone, /*free_counter=*/false);
> if (!event)