Re: [PATCH v1 12/14] perf stat: Remove duplicate cpus_map_matched function

From: James Clark
Date: Tue Dec 12 2023 - 06:28:35 EST




On 29/11/2023 06:02, Ian Rogers wrote:
> Use libperf's perf_cpu_map__equal that performs the same function.
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---

Reviewed-by: James Clark <james.clark@xxxxxxx>

> tools/perf/builtin-stat.c | 22 +---------------------
> 1 file changed, 1 insertion(+), 21 deletions(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index f583027a0639..8e2f90b5c276 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -164,26 +164,6 @@ static struct perf_stat_config stat_config = {
> .iostat_run = false,
> };
>
> -static bool cpus_map_matched(struct evsel *a, struct evsel *b)
> -{
> - if (!a->core.cpus && !b->core.cpus)
> - return true;
> -
> - if (!a->core.cpus || !b->core.cpus)
> - return false;
> -
> - if (perf_cpu_map__nr(a->core.cpus) != perf_cpu_map__nr(b->core.cpus))
> - return false;
> -
> - for (int i = 0; i < perf_cpu_map__nr(a->core.cpus); i++) {
> - if (perf_cpu_map__cpu(a->core.cpus, i).cpu !=
> - perf_cpu_map__cpu(b->core.cpus, i).cpu)
> - return false;
> - }
> -
> - return true;
> -}
> -
> static void evlist__check_cpu_maps(struct evlist *evlist)
> {
> struct evsel *evsel, *warned_leader = NULL;
> @@ -194,7 +174,7 @@ static void evlist__check_cpu_maps(struct evlist *evlist)
> /* Check that leader matches cpus with each member. */
> if (leader == evsel)
> continue;
> - if (cpus_map_matched(leader, evsel))
> + if (perf_cpu_map__equal(leader->core.cpus, evsel->core.cpus))
> continue;
>
> /* If there's mismatch disable the group and warn user. */