From nobody Mon Dec 29 11:19:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0F6C07CB1 for ; Wed, 29 Nov 2023 06:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377077AbjK2GCy (ORCPT ); Wed, 29 Nov 2023 01:02:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377017AbjK2GCe (ORCPT ); Wed, 29 Nov 2023 01:02:34 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01E061BD1 for ; Tue, 28 Nov 2023 22:02:37 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-da07b5e6f75so518882276.0 for ; Tue, 28 Nov 2023 22:02:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701237756; x=1701842556; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=uG9dHqe+W7QKF/tqT6hMSrmaRYWeZm2ANVmXQYyVcMw=; b=MBY45QlVN+VLPP18MF80I+TOuNvbEVxLQXwYNqvHMktrELL/abBHP+Q5kA5CnVRIQR mJLH0YtVeHKd8ruEswkwl2IJx4tBEzzjqhUCFnAQ8qHCZajJGwVvdCSVebNySoPeCf6V INWDBPUK0Phkoe6v3gfYnHubHHoc7jaR6U9EIcLGyLAqUErf9r2/zaoE947hrC2IWLjf dcroVHPNUhVXDg6rpt1fYKTk5Ee+5rpRY5AZJPHQDKI+L7XLqSayZ3v+S8ttqVPnhl9m yN3kLHsHebcO8oEQfXV/JTfk7qAHLx732RrijpmdXnFLCUTGuyYtUaPxsbF7x68sDaDq 6H/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701237756; x=1701842556; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uG9dHqe+W7QKF/tqT6hMSrmaRYWeZm2ANVmXQYyVcMw=; b=Cvph0P3FYrY24r/VtC4M8HGJkPCGa1mio4nW/j5+1ETJiv9cO5pdM/L+HAkXySsD0s IJ/VT8w035dSCczzcgnZLagO+CAh6pArebC7p6a9GY2rwpZslIFOw0klepJslSwb3BHW wtuBURoG66iCWEyqazIfMD+/L2RghGBbQvEaXFa5XUdn1djA+YbJfMvA/l0SnH4SNLKd fmG6Xn8yj/IcA2FEWBoq7tNbd26+GcXvtLH+NgvPm7VAMoQKJTyEo5UTHI2aukYSMwkA C/WlEggDyr18w12Quuyo+gVD0mgrFqyGmVnMCS0bMCJYd48bjlG7ffQhPIZdVG7wR/In KJ7A== X-Gm-Message-State: AOJu0YyIWf3Xe+zTepbYVMMBVOwrScv2TzrK7o2JhYqJZQdizUMWpehf uU5muz2QFHXEFOupfjQqEvwsag8RFXKA X-Google-Smtp-Source: AGHT+IHZ7VKuLrd0RTaphxrTR9JPVsSgxwODprHGGe8tro5qukldPn6DgcQliDLHW2yuWD/XgfiuGYaXrgpT X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:763b:80fa:23ca:96f8]) (user=irogers job=sendgmr) by 2002:a25:aa49:0:b0:d89:42d7:e72d with SMTP id s67-20020a25aa49000000b00d8942d7e72dmr669750ybi.3.1701237756399; Tue, 28 Nov 2023 22:02:36 -0800 (PST) Date: Tue, 28 Nov 2023 22:02:06 -0800 In-Reply-To: <20231129060211.1890454-1-irogers@google.com> Message-Id: <20231129060211.1890454-10-irogers@google.com> Mime-Version: 1.0 References: <20231129060211.1890454-1-irogers@google.com> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog Subject: [PATCH v1 09/14] perf cpumap: Clean up use of perf_cpu_map__has_any_cpu_or_is_empty From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , John Garry , Will Deacon , Thomas Gleixner , Darren Hart , Davidlohr Bueso , "=?UTF-8?q?Andr=C3=A9=20Almeida?=" , Kan Liang , K Prateek Nayak , Sean Christopherson , Paolo Bonzini , Kajol Jain , Athira Rajeev , Andrew Jones , Alexandre Ghiti , Atish Patra , "Steinar H. Gunderson" , Yang Jihong , Yang Li , Changbin Du , Sandipan Das , Ravi Bangoria , Paran Lee , Nick Desaulniers , Huacai Chen , Yanteng Si , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Most uses of what was perf_cpu_map__empty but is now perf_cpu_map__has_any_cpu_or_is_empty want to do something with the CPU map if it contains CPUs. Replace uses of perf_cpu_map__has_any_cpu_or_is_empty with other helpers so that CPUs within the map can be handled. Signed-off-by: Ian Rogers Reviewed-by: James Clark --- tools/perf/builtin-c2c.c | 6 +----- tools/perf/builtin-stat.c | 9 ++++----- tools/perf/util/auxtrace.c | 4 ++-- tools/perf/util/record.c | 2 +- tools/perf/util/stat.c | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index f78eea9e2153..ef7ed53a4b4e 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2319,11 +2319,7 @@ static int setup_nodes(struct perf_session *session) =20 nodes[node] =3D set; =20 - /* empty node, skip */ - if (perf_cpu_map__has_any_cpu_or_is_empty(map)) - continue; - - perf_cpu_map__for_each_cpu(cpu, idx, map) { + perf_cpu_map__for_each_cpu_skip_any(cpu, idx, map) { __set_bit(cpu.cpu, set); =20 if (WARN_ONCE(cpu2node[cpu.cpu] !=3D -1, "node/cpu topology bug")) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3303aa20f326..f583027a0639 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1316,10 +1316,9 @@ static int cpu__get_cache_id_from_map(struct perf_cp= u cpu, char *map) * be the first online CPU in the cache domain else use the * first online CPU of the cache domain as the ID. */ - if (perf_cpu_map__has_any_cpu_or_is_empty(cpu_map)) + id =3D perf_cpu_map__min(cpu_map).cpu; + if (id =3D=3D -1) id =3D cpu.cpu; - else - id =3D perf_cpu_map__cpu(cpu_map, 0).cpu; =20 /* Free the perf_cpu_map used to find the cache ID */ perf_cpu_map__put(cpu_map); @@ -1622,7 +1621,7 @@ static int perf_stat_init_aggr_mode(void) * taking the highest cpu number to be the size of * the aggregation translate cpumap. */ - if (!perf_cpu_map__has_any_cpu_or_is_empty(evsel_list->core.user_requeste= d_cpus)) + if (!perf_cpu_map__is_any_cpu_or_is_empty(evsel_list->core.user_requested= _cpus)) nr =3D perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; else nr =3D 0; @@ -2289,7 +2288,7 @@ int process_stat_config_event(struct perf_session *se= ssion, =20 perf_event__read_stat_config(&stat_config, &event->stat_config); =20 - if (perf_cpu_map__has_any_cpu_or_is_empty(st->cpus)) { + if (perf_cpu_map__is_empty(st->cpus)) { if (st->aggr_mode !=3D AGGR_UNSET) pr_warning("warning: processing task data, aggregation mode not set\n"); } else if (st->aggr_mode !=3D AGGR_UNSET) { diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 3684e6009b63..6b1d4bafad59 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -174,7 +174,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap= _params *mp, struct evlist *evlist, struct evsel *evsel, int idx) { - bool per_cpu =3D !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user= _requested_cpus); + bool per_cpu =3D !perf_cpu_map__has_any_cpu(evlist->core.user_requested_c= pus); =20 mp->mmap_needed =3D evsel->needs_auxtrace_mmap; =20 @@ -648,7 +648,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_rec= ord *itr, =20 static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *e= vsel, int idx) { - bool per_cpu_mmaps =3D !perf_cpu_map__has_any_cpu_or_is_empty(evlist->cor= e.user_requested_cpus); + bool per_cpu_mmaps =3D !perf_cpu_map__has_any_cpu(evlist->core.user_reque= sted_cpus); =20 if (per_cpu_mmaps) { struct perf_cpu evlist_cpu =3D perf_cpu_map__cpu(evlist->core.all_cpus, = idx); diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 87e817b3cf7e..e867de8ddaaa 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -237,7 +237,7 @@ bool evlist__can_select_event(struct evlist *evlist, co= nst char *str) =20 evsel =3D evlist__last(temp_evlist); =20 - if (!evlist || perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_re= quested_cpus)) { + if (!evlist || perf_cpu_map__is_any_cpu_or_is_empty(evlist->core.user_req= uested_cpus)) { struct perf_cpu_map *cpus =3D perf_cpu_map__new_online_cpus(); =20 if (cpus) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 012c4946b9c4..915808a6211a 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -315,7 +315,7 @@ static int check_per_pkg(struct evsel *counter, struct = perf_counts_values *vals, if (!counter->per_pkg) return 0; =20 - if (perf_cpu_map__has_any_cpu_or_is_empty(cpus)) + if (perf_cpu_map__is_any_cpu_or_is_empty(cpus)) return 0; =20 if (!mask) { --=20 2.43.0.rc1.413.gea7ed67945-goog