diff mbox series

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

Message ID 20231129060211.1890454-13-irogers@google.com (mailing list archive)
State Not Applicable
Delegated to: BPF
Headers show
Series Clean up libperf cpumap's empty function | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Ian Rogers Nov. 29, 2023, 6:02 a.m. UTC
Use libperf's perf_cpu_map__equal that performs the same function.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/builtin-stat.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

Comments

James Clark Dec. 12, 2023, 11:28 a.m. UTC | #1
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@google.com>
> ---

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

>  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. */
diff mbox series

Patch

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. */