Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4703619rdb; Tue, 12 Dec 2023 07:11:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5cwK3C3hRVIAXNyeNo3UB+EcTiCmopxGGHa/8GVecgGznz3brDsmL0n1L8XBjObMk5OUJ X-Received: by 2002:a05:6a00:cc5:b0:6ce:2ec0:636c with SMTP id b5-20020a056a000cc500b006ce2ec0636cmr3240391pfv.17.1702393875026; Tue, 12 Dec 2023 07:11:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702393875; cv=none; d=google.com; s=arc-20160816; b=U8tj/q4NdkPVMkeC9YLRKzYSzG7hBMw765afCF4P4oR7VJytMTpzqIBg4fnpuESzdK rZdFeSQNOFCw/Lj9zoc7mRUr2bTIqXIgiPlOef0/74FiYuMqnW9TTv7LpHSfuzSlXpbk Uaj7s4NnkZXnQZ8HPA1M1FlQGQGuX21BXVpIb4i4bVnjR2nz+ygH8tC//+3ks2XrTtE3 eCkEbEnRIeSbBfJRsoYZL5RR4FChONO2p1TeOEJaZIHkTR70nceW1HpagVRJvXi65zLC rWlEgsOkuljpE3D5vvHc27fMRP/qHU2vjyAd/8tI3/YKUhENXKky6EudMpK4vF4t4C90 E6DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from:cc :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=w8qUhtprYQTQpxUwDm02Gy1rzdvXX8JlnE4iAOO3s14=; fh=5EP3x1uDWWBI9dywppNETb2J5CyUqdqYJErdwPGhe68=; b=qLxUZy9BHhKwfon2Qc36RaNvkDKk7YE1kTPMRygfwxXQJSPt1FpPki4zFBHwwjjkKy Rp/7VHTC46KQCBgzD8enyqko25qi4x9/xsT+z8ohYaRtheqhC0hOqGZvK0pXWp3Gzq74 wcFO16xNO9CngCK9aIbMac9C9LL+m1aD5tlFPQZgcLustOFnSODWuArHfqcSEvUGA1XJ aKd+GBg9QY/dVgjGnPjgiEHO7h2AYBlhnqn+0eCmNqvXBI16EuL/j7TOGiCeTjuwHZkl 53fjWmL1Ji9HzjYRHr75V9l9O3V7ShpRKQSZWXZdUWQGSi76AN9774/4Xucppg2lEhl0 HT5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id h16-20020a056a00219000b006ceda12a350si7606922pfi.227.2023.12.12.07.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 07:11:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DFA9C80A2398; Tue, 12 Dec 2023 07:11:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376469AbjLLPKg (ORCPT + 99 others); Tue, 12 Dec 2023 10:10:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232770AbjLLPKf (ORCPT ); Tue, 12 Dec 2023 10:10:35 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61D64EB; Tue, 12 Dec 2023 07:10:41 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5DFBB143D; Tue, 12 Dec 2023 07:11:27 -0800 (PST) Received: from [192.168.1.3] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB6293F738; Tue, 12 Dec 2023 07:10:35 -0800 (PST) Message-ID: Date: Tue, 12 Dec 2023 15:10:31 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH v1 09/14] perf cpumap: Clean up use of perf_cpu_map__has_any_cpu_or_is_empty Content-Language: en-US To: Ian Rogers References: <20231129060211.1890454-1-irogers@google.com> <20231129060211.1890454-10-irogers@google.com> Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Thomas Gleixner , Darren Hart , Davidlohr Bueso , =?UTF-8?Q?Andr=c3=a9_Almeida?= , 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 From: James Clark In-Reply-To: <20231129060211.1890454-10-irogers@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 07:11:08 -0800 (PST) On 29/11/2023 06:02, Ian Rogers wrote: > 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) > > nodes[node] = set; > > - /* 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); > > if (WARN_ONCE(cpu2node[cpu.cpu] != -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_cpu 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 = perf_cpu_map__min(cpu_map).cpu; > + if (id == -1) > id = cpu.cpu; > - else > - id = perf_cpu_map__cpu(cpu_map, 0).cpu; > > /* 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_requested_cpus)) > + if (!perf_cpu_map__is_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) > nr = perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; > else > nr = 0; > @@ -2289,7 +2288,7 @@ int process_stat_config_event(struct perf_session *session, > > perf_event__read_stat_config(&stat_config, &event->stat_config); > > - if (perf_cpu_map__has_any_cpu_or_is_empty(st->cpus)) { > + if (perf_cpu_map__is_empty(st->cpus)) { > if (st->aggr_mode != AGGR_UNSET) > pr_warning("warning: processing task data, aggregation mode not set\n"); > } else if (st->aggr_mode != 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 = !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus); > + bool per_cpu = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); > > mp->mmap_needed = evsel->needs_auxtrace_mmap; > > @@ -648,7 +648,7 @@ int auxtrace_parse_snapshot_options(struct auxtrace_record *itr, > > static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx) > { > - bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus); > + bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); > > if (per_cpu_mmaps) { > struct perf_cpu evlist_cpu = 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, const char *str) > > evsel = evlist__last(temp_evlist); > > - if (!evlist || perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { > + if (!evlist || perf_cpu_map__is_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { > struct perf_cpu_map *cpus = perf_cpu_map__new_online_cpus(); > > 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; > > - if (perf_cpu_map__has_any_cpu_or_is_empty(cpus)) > + if (perf_cpu_map__is_any_cpu_or_is_empty(cpus)) > return 0; > > if (!mask) {