Re: [PATCH v4 15/25] perf stat: Filter out unmatched aggregation for hybrid event

Jiri Olsa
2021-04-21T18:30:39Z

On Fri, Apr 16, 2021 at 10:05:07PM +0800, Jin Yao wrote:

SNIP

> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 5255d78b1c30..15eafd249e46 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -643,6 +643,20 @@ static void aggr_cb(struct perf_stat_config *config,
> }
> }
>
> +static bool aggr_id_hybrid_matched(struct perf_stat_config *config,
> + struct evsel *counter, struct aggr_cpu_id id)
> +{
> + struct aggr_cpu_id s;
> +
> + for (int i = 0; i < evsel__nr_cpus(counter); i++) {
> + s = config->aggr_get_id(config, evsel__cpus(counter), i);
> + if (cpu_map__compare_aggr_cpu_id(s, id))
> + return true;
> + }
> +
> + return false;
> +}
> +
> static void print_counter_aggrdata(struct perf_stat_config *config,
> struct evsel *counter, int s,
> char *prefix, bool metric_only,
> @@ -656,6 +670,12 @@ static void print_counter_aggrdata(struct perf_stat_config *config,
> double uval;
>
> ad.id = id = config->aggr_map->map[s];
> +
> + if (perf_pmu__has_hybrid() &&
> + !aggr_id_hybrid_matched(config, counter, id)) {
> + return;
> + }
> +
> ad.val = ad.ena = ad.run = 0;
> ad.nr = 0;
> if (!collect_data(config, counter, aggr_cb, &ad))

there's same check in aggr_cb, so it seems like we could just make check in here:

if (perf_pmu__has_hybrid() && ad.ena == 0)
return;

without another extra loop

jirka