From patchwork Wed Nov 29 06:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 171087 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp144052vqn; Tue, 28 Nov 2023 22:03:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiuX3oGhgTFLihiFVh3ILewYsfzcqMHCb4eC9yM9FXpTqhO72/592XhyrC9XlvGkMyx9GC X-Received: by 2002:a05:6359:1019:b0:168:e78c:e3a7 with SMTP id ib25-20020a056359101900b00168e78ce3a7mr11585305rwb.18.1701237794145; Tue, 28 Nov 2023 22:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701237794; cv=none; d=google.com; s=arc-20160816; b=fl7+PzAfVNVnFX+vGPH1kicah+elsNUg+SgtG2zrcPqqqPSQ4Bo7Ewq2a0IwsP9F2H OmKtCEHNVr3MWezfQAAyn7Apzb036PFKtaYUrD1SsGrUT3PYhOYCPEeYIe8tXL8vFjK5 4HWYtFQdJ8HQKfBCwGOHNOpcPk05FK5wLC/BXsKhGHOgNQJndobz56FNzeCskJMpJyVc TuHc2nwdR6ZMsK+oLAX8JSQ8SO0jHsZI5kYGgnKfg1NZG7VRoLenaDL/WiCtvH3PntHd PzOiwR2t7BpoeG6wZ895pXWyY7e8cPwTENXJjWUBrqrYq2EgqXofbJtXuHSi8dic+bcC LOPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=uG9dHqe+W7QKF/tqT6hMSrmaRYWeZm2ANVmXQYyVcMw=; fh=uYKNI4aCUAMYZ/8oQVBIse94GgoxWIIZr1zaTbrWG7c=; b=alnuqiTLi2Q3G3+dNP7XBz9mYNvpXNerhl3QM4zgdRqv8bzhpmnac/uI2YDkQ7KsX/ EhK/HxhBa4oMMFnvaZXZjSbLbd+VLXio3hOsiQB8BO/oDFqyESmpmStJ+c93/sgCl7Bz Zw2yJHhyf3QoV6tgMK0AsxrQcCtg5kVFEY0ggH4z71l//FxH/7bD/F1PMfpinT4bqlTu 8/QYG83xCfh2YWv+aQniEsZ4IhCLKALZ/Zdzd+I7qB2/ZjkTHy3FemDUsqxOAGY38ZFK IvQ2bMD7HJcUAcvHGdT81r/GH78Nf6/1hyZLGvPr4eV0cByR2NAJ5Mx2HPvNREzs1eEq 5vRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MBY45QlV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id 17-20020a630a11000000b005be1ee5be76si13746729pgk.373.2023.11.28.22.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 22:03:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=MBY45QlV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B7BBC80481BE; Tue, 28 Nov 2023 22:03:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377076AbjK2GCw (ORCPT + 99 others); Wed, 29 Nov 2023 01:02:52 -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-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_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 X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 28 Nov 2023 22:03:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783877121131679713 X-GMAIL-MSGID: 1783877121131679713 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) {