From nobody Sun May 10 14:12:26 2026 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 69EE8C433EF for ; Tue, 3 May 2022 04:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbiECEVu (ORCPT ); Tue, 3 May 2022 00:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbiECEVh (ORCPT ); Tue, 3 May 2022 00:21:37 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B79B138D89 for ; Mon, 2 May 2022 21:18:05 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f902276272so43806197b3.21 for ; Mon, 02 May 2022 21:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QD3DUc26sP7ykTIj1yIZzampBuXqJbDmnGb6bGuMDs8=; b=NokXk5/xkNo3NQGuTnByEoO+krhLeXfq6JfjcXwcJSXmHhFSlGr5vRf/0GOE4udOzy 4RYauE/Js0/9tqje5oT7v/+DN6B6Xl92kuCM2uE+HkPHs7a6czXX0Dsix0YBr2SQcS/p jsY2zfQ2xqQcLNpIMzKxTNlXx5berGEtzw/44QEhwX2e+EKNK53Ru8GD5Io2fU6rXyXG DSlVLV0BXwhk1HmhOmfPz1cmG1pfNMxwyeiNLztlR0wcfmyBTmUc6XoTTdjzQZqKlF/H /kmwY7mJjAub22Ax0TLQ8nRtmnVZYw6YxcRwqEf0PGJUe8StZ/OaYjjk3bWVU49oluZC EQVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QD3DUc26sP7ykTIj1yIZzampBuXqJbDmnGb6bGuMDs8=; b=ETDfKPoCrvoi1GGnQcYe6N76hmuCpvLq3Fasf+h3KMSraxNXUwYj3jvR/L34ZIc3Yg 6aPBHQonnRrKJCEGfBXjRddz24TL8ssh44ASNe38sWGLO987ub0cd+hi8XrJ9wlvpgLs A+X1u6oXgBnLNswKJkt87oUMVPqZBKSedK8CtAPYsnMGG9/LdPYrh8nMR9WUNVfCPDjO GfmgMJ+mSngN5phy3b6YwERwK9WAqLOQmIxZ4t5GuaapbaxUK3r922UbQ1MTFkWnhyfn tapgHRC+vVVU2zM3MXVhD7KPW80TIJaPT+LSO4jseAVCHT+SVF3GaJqWj5tSgVAZnSTO Zu1A== X-Gm-Message-State: AOAM531HWdNrnqTyys+FEom/48HJ+MonfdnNgWVzb8FVhnjYsQ/PGaDN qMDWRE2bnQ+670b/ojwEsecXcR2KmLrK X-Google-Smtp-Source: ABdhPJxkQdAYSGlIDwzPRvybZXRBQfHSLeYfhwbH5tnTdrY6mFM6YP9HOoQphYHoVoYVEF02TWVPNs9nvaBl X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:dd4b:52bb:771d:7bb4]) (user=irogers job=sendgmr) by 2002:a05:6902:725:b0:649:68fd:6d85 with SMTP id l5-20020a056902072500b0064968fd6d85mr7546725ybt.11.1651551484866; Mon, 02 May 2022 21:18:04 -0700 (PDT) Date: Mon, 2 May 2022 21:17:52 -0700 In-Reply-To: <20220503041757.2365696-1-irogers@google.com> Message-Id: <20220503041757.2365696-2-irogers@google.com> Mime-Version: 1.0 References: <20220503041757.2365696-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v5 1/6] perf cpumap: Switch to using perf_cpu_map API From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Switch some raw accesses to the cpu map to using the library API. This can help with reference count checking. Some BPF cases switch from index to CPU for consistency, this shouldn't matter as the CPU map is full. Signed-off-by: Ian Rogers Acked-by: Namhyung Kim --- tools/perf/builtin-record.c | 13 +++++---- tools/perf/util/bpf_counter_cgroup.c | 42 +++++++++++++--------------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 069825c48d40..a5cf6a99d67f 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1011,7 +1011,7 @@ static int record__thread_data_init_maps(struct recor= d_thread *thread_data, stru =20 for (m =3D 0, tm =3D 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) { if (cpu_map__is_dummy(cpus) || - test_bit(cpus->map[m].cpu, thread_data->mask->maps.bits)) { + test_bit(perf_cpu_map__cpu(cpus, m).cpu, thread_data->mask->maps.bit= s)) { if (thread_data->maps) { thread_data->maps[tm] =3D &mmap[m]; pr_debug2("thread_data[%p]: cpu%d: maps[%d] -> mmap[%d]\n", @@ -3331,13 +3331,14 @@ struct option *record_options =3D __record_options; =20 static void record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct = perf_cpu_map *cpus) { - int c; + struct perf_cpu cpu; + int idx; =20 if (cpu_map__is_dummy(cpus)) return; =20 - for (c =3D 0; c < cpus->nr; c++) - set_bit(cpus->map[c].cpu, mask->bits); + perf_cpu_map__for_each_cpu(cpu, idx, cpus) + set_bit(cpu.cpu, mask->bits); } =20 static int record__mmap_cpu_mask_init_spec(struct mmap_cpu_mask *mask, con= st char *mask_spec) @@ -3404,8 +3405,8 @@ static int record__init_thread_cpu_masks(struct recor= d *rec, struct perf_cpu_map pr_debug("nr_threads: %d\n", rec->nr_threads); =20 for (t =3D 0; t < rec->nr_threads; t++) { - set_bit(cpus->map[t].cpu, rec->thread_masks[t].maps.bits); - set_bit(cpus->map[t].cpu, rec->thread_masks[t].affinity.bits); + set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].maps.bits); + set_bit(perf_cpu_map__cpu(cpus, t).cpu, rec->thread_masks[t].affinity.bi= ts); if (verbose) { pr_debug("thread_masks[%d]: ", t); mmap_cpu_mask__scnprintf(&rec->thread_masks[t].maps, "maps"); diff --git a/tools/perf/util/bpf_counter_cgroup.c b/tools/perf/util/bpf_cou= nter_cgroup.c index ac60c08e8e2a..63b9db657442 100644 --- a/tools/perf/util/bpf_counter_cgroup.c +++ b/tools/perf/util/bpf_counter_cgroup.c @@ -46,8 +46,8 @@ static int bperf_load_program(struct evlist *evlist) struct bpf_link *link; struct evsel *evsel; struct cgroup *cgrp, *leader_cgrp; - __u32 i, cpu; - __u32 nr_cpus =3D evlist->core.all_cpus->nr; + int i, j; + struct perf_cpu cpu; int total_cpus =3D cpu__max_cpu().cpu; int map_size, map_fd; int prog_fd, err; @@ -93,9 +93,9 @@ static int bperf_load_program(struct evlist *evlist) goto out; } =20 - for (i =3D 0; i < nr_cpus; i++) { + perf_cpu_map__for_each_cpu(cpu, i, evlist->core.all_cpus) { link =3D bpf_program__attach_perf_event(skel->progs.on_cgrp_switch, - FD(cgrp_switch, i)); + FD(cgrp_switch, cpu.cpu)); if (IS_ERR(link)) { pr_err("Failed to attach cgroup program\n"); err =3D PTR_ERR(link); @@ -122,10 +122,9 @@ static int bperf_load_program(struct evlist *evlist) } =20 map_fd =3D bpf_map__fd(skel->maps.events); - for (cpu =3D 0; cpu < nr_cpus; cpu++) { - int fd =3D FD(evsel, cpu); - __u32 idx =3D evsel->core.idx * total_cpus + - evlist->core.all_cpus->map[cpu].cpu; + perf_cpu_map__for_each_cpu(cpu, j, evlist->core.all_cpus) { + int fd =3D FD(evsel, cpu.cpu); + __u32 idx =3D evsel->core.idx * total_cpus + cpu.cpu; =20 err =3D bpf_map_update_elem(map_fd, &idx, &fd, BPF_ANY); @@ -207,14 +206,12 @@ static int bperf_cgrp__install_pe(struct evsel *evsel= __maybe_unused, */ static int bperf_cgrp__sync_counters(struct evlist *evlist) { - int i, cpu; - int nr_cpus =3D evlist->core.all_cpus->nr; + struct perf_cpu cpu; + int idx; int prog_fd =3D bpf_program__fd(skel->progs.trigger_read); =20 - for (i =3D 0; i < nr_cpus; i++) { - cpu =3D evlist->core.all_cpus->map[i].cpu; - bperf_trigger_reading(prog_fd, cpu); - } + perf_cpu_map__for_each_cpu(cpu, idx, evlist->core.all_cpus) + bperf_trigger_reading(prog_fd, cpu.cpu); =20 return 0; } @@ -244,12 +241,10 @@ static int bperf_cgrp__disable(struct evsel *evsel) static int bperf_cgrp__read(struct evsel *evsel) { struct evlist *evlist =3D evsel->evlist; - int i, cpu, nr_cpus =3D evlist->core.all_cpus->nr; int total_cpus =3D cpu__max_cpu().cpu; struct perf_counts_values *counts; struct bpf_perf_event_value *values; int reading_map_fd, err =3D 0; - __u32 idx; =20 if (evsel->core.idx) return 0; @@ -263,7 +258,10 @@ static int bperf_cgrp__read(struct evsel *evsel) reading_map_fd =3D bpf_map__fd(skel->maps.cgrp_readings); =20 evlist__for_each_entry(evlist, evsel) { - idx =3D evsel->core.idx; + __u32 idx =3D evsel->core.idx; + int i; + struct perf_cpu cpu; + err =3D bpf_map_lookup_elem(reading_map_fd, &idx, values); if (err) { pr_err("bpf map lookup failed: idx=3D%u, event=3D%s, cgrp=3D%s\n", @@ -271,13 +269,11 @@ static int bperf_cgrp__read(struct evsel *evsel) goto out; } =20 - for (i =3D 0; i < nr_cpus; i++) { - cpu =3D evlist->core.all_cpus->map[i].cpu; - + perf_cpu_map__for_each_cpu(cpu, i, evlist->core.all_cpus) { counts =3D perf_counts(evsel->counts, i, 0); - counts->val =3D values[cpu].counter; - counts->ena =3D values[cpu].enabled; - counts->run =3D values[cpu].running; + counts->val =3D values[cpu.cpu].counter; + counts->ena =3D values[cpu.cpu].enabled; + counts->run =3D values[cpu.cpu].running; } } =20 --=20 2.36.0.464.gb9c8b46e94-goog From nobody Sun May 10 14:12:26 2026 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 C0CAAC433EF for ; Tue, 3 May 2022 04:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbiECEVp (ORCPT ); Tue, 3 May 2022 00:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbiECEVi (ORCPT ); Tue, 3 May 2022 00:21:38 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27AB038BFC for ; Mon, 2 May 2022 21:18:08 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f8d487f575so79397687b3.5 for ; Mon, 02 May 2022 21:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qM0CcLJJrKpW2Wkspbw9oc4+0PMtIaoOGCh2yb1+c8Y=; b=iT5xdA/rg8+MNsb785W3GH63t4eHf4o2ufE9t16Fodq6V8dmlCaFTXp1amgu76yDEd hdCCSc0RvrUoAMypdlByXDbeqohAw1BOVSCMyhQiHLq91rulRu5aw/8bkvnic86sCoru i5j6EZzVYStAni8Geao/E6QSYanLC7VaQwNXNwatg0idyTvuXkKNP6vbPHjghWo2iu4A lqhgzQQcqlP7yadi40ymLoJ4Lj9uIOynVAwTNYZda9t0LCRTWDtruwtfzL0ekTcrHJ5X fZhqw04Nf/CKLEkFaoF+ExsdgV2pd36WDimqIsL8lyepqPuLBqnFjdfhQqECSZQxjyFV THTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qM0CcLJJrKpW2Wkspbw9oc4+0PMtIaoOGCh2yb1+c8Y=; b=Or6eWBx+FZGRkAIsQmWRYlcrkyAzMg6lw/bt46r5bNGGloOMX+yKM7MsqIl8z9sibU upZbTY4lECNpq5KhwhL7iiT8/pDBnCQ/b5eg0iokEMK0JhJqWy+cX8xPia+EaM9k3MJu ftqtE4651WDyiRfMFsIV7FHQDj8EjE/ovfmVbgT0SAYQ/PN/VQsylxeipfBox3YJS2dM GqGC0ZKxY1msZd92JrSnYeHXtzPD+os+ikjAVQ6Hj7CYWc5MMfsSVC4asw3dewNtllt1 iABIf9xGA1qhUKjK8o4Nf0RAoGGqAdrlw+xThbjc8cVl8GEqD6NmZjkyKD/AOz7NAylX I69w== X-Gm-Message-State: AOAM530QRrS3SCO47NyBh5DPZtn39V1n0CrInx5jj1345JAOU484Fkom +207HcKq9OmJNkfuJnwUl/WrZI1HwG73 X-Google-Smtp-Source: ABdhPJxiPnCbA7/Eppx8fhZ4RJy6qiG1Go1/53a0D2Iw71MIcgee3dcMxSVJ2GFtTvoQRpF4s/3zJG32pHul X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:dd4b:52bb:771d:7bb4]) (user=irogers job=sendgmr) by 2002:a81:6cc1:0:b0:2f8:bb31:143b with SMTP id h184-20020a816cc1000000b002f8bb31143bmr13489355ywc.64.1651551487238; Mon, 02 May 2022 21:18:07 -0700 (PDT) Date: Mon, 2 May 2022 21:17:53 -0700 In-Reply-To: <20220503041757.2365696-1-irogers@google.com> Message-Id: <20220503041757.2365696-3-irogers@google.com> Mime-Version: 1.0 References: <20220503041757.2365696-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v5 2/6] perf evlist: Clear all_cpus before propagating From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" all_cpus is merged into during propagation. Initially all_cpus is set from PMU sysfs. perf_evlist__set_maps will recompute it and change evsel->cpus to user_requested_cpus if they are given. If all_cpus isn't cleared then the union of the user_requested_cpus and PMU sysfs values is set to all_cpus, whereas just user_requested_cpus is necessary. To avoid this make all_cpus empty prior to propagation. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- tools/lib/perf/evlist.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index a09315538a30..974b4585f93e 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -59,6 +59,10 @@ static void perf_evlist__propagate_maps(struct perf_evli= st *evlist) { struct perf_evsel *evsel; =20 + /* Recomputing all_cpus, so start with a blank slate. */ + perf_cpu_map__put(evlist->all_cpus); + evlist->all_cpus =3D NULL; + perf_evlist__for_each_evsel(evlist, evsel) __perf_evlist__propagate_maps(evlist, evsel); } --=20 2.36.0.464.gb9c8b46e94-goog From nobody Sun May 10 14:12:26 2026 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 66A36C433EF for ; Tue, 3 May 2022 04:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbiECEV5 (ORCPT ); Tue, 3 May 2022 00:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230514AbiECEVl (ORCPT ); Tue, 3 May 2022 00:21:41 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7458A3CA55 for ; Mon, 2 May 2022 21:18:10 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id w133-20020a25c78b000000b0064847b10a22so14746138ybe.18 for ; Mon, 02 May 2022 21:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ylADTrsJ6wiLUYsMxUfv5wTGPsw8bfvmV1tE6kxgk9c=; b=Q420HA5+e4YUXnBw0wYuoypr1QivktDnGGhQ7w4Z4sP6i4mW2dFHRT5/AYIx/FNAre /+0noaBCbkUNRm3jlp7LW63K5hEdi6jLSShCREkUKipd3lNd/fO4Moe9qXO5/9fLk1Rc lJ/0CfIJL7U9KMZOmUgCQhF3PZrbmSeO/HtdTQFSFFkpsN9josCbuiCREy7T0zpnn7rF xnSgxieL1+zDlu5jt8cv66hzWA8qQI3RSaIKbmbmI0iLByiBUPgH4wgE9ALXcZ1Ykggo zxPzFr/4dhV9zAN/XARbMyWS9xS+MpgR6ki8I7iCXEDd86urxYCMBx5e18KAadlq+EVq Onfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ylADTrsJ6wiLUYsMxUfv5wTGPsw8bfvmV1tE6kxgk9c=; b=MnSRkhO65K0tlDw4MnzcdOXLdPlSUw+fN8y1FmiEH4Kbv105fZ+gnBDXOxs4SYuHne EQ6t1hGCwniXx4tPM5pE1aDbF9uMPFTCp1Cbnl4JEs70Ispa/GeMU/Z1buRiEXurhLuo 3Qv0gKXFMGRNdBeQdTN5qAOLkqEaoiZSk24VEuOH8z4etclpWfyHs6qBUEUbGt5R01i0 yPK71lmjW/3LotujAfMAxmV6qmjY2tcDaAoIMnBEjuX7FF339vXgXGnTXnLxMgz2Ajwj 9u3fADHWFn9eintGHWo9uWmcqGoc7FZnJSJKok9B7XVnpPEkxxNyF6kEBETgsDr9fQND n0vw== X-Gm-Message-State: AOAM531ZRN8iYnoCNN6w2PXkUA8xS9WtD6ywZSNiO6oghsiP8Qc4ENO6 YIt0QwsMM+EEK1XZwVECMzl7uLwy9p1O X-Google-Smtp-Source: ABdhPJxd67nRJPH+qie23bqG5YLJVJJaTjfosAGibjZUM+HmIUkuw5cVpuRlHQWC1JKopkXEnBO+ZdDTxw4F X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:dd4b:52bb:771d:7bb4]) (user=irogers job=sendgmr) by 2002:a25:488a:0:b0:648:cfd4:8044 with SMTP id v132-20020a25488a000000b00648cfd48044mr12279689yba.555.1651551489576; Mon, 02 May 2022 21:18:09 -0700 (PDT) Date: Mon, 2 May 2022 21:17:54 -0700 In-Reply-To: <20220503041757.2365696-1-irogers@google.com> Message-Id: <20220503041757.2365696-4-irogers@google.com> Mime-Version: 1.0 References: <20220503041757.2365696-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v5 3/6] perf stat: Avoid printing cpus with no counters From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" perf_evlist's user_requested_cpus can contain CPUs not present in any evsel's cpus, for example uncore counters. Avoid printing the prefix and trailing \n until the first valid counter is encountered. Reviewed-by: Adrian Hunter Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index d9629a83aa78..13f705737367 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -948,8 +948,6 @@ static void print_no_aggr_metric(struct perf_stat_confi= g *config, struct evsel *counter; bool first =3D true; =20 - if (prefix) - fputs(prefix, config->output); evlist__for_each_entry(evlist, counter) { u64 ena, run, val; double uval; @@ -961,6 +959,8 @@ static void print_no_aggr_metric(struct perf_stat_confi= g *config, =20 id =3D aggr_cpu_id__cpu(cpu, /*data=3D*/NULL); if (first) { + if (prefix) + fputs(prefix, config->output); aggr_printout(config, counter, id, 0); first =3D false; } @@ -972,7 +972,8 @@ static void print_no_aggr_metric(struct perf_stat_confi= g *config, printout(config, id, 0, counter, uval, prefix, run, ena, 1.0, &rt_stat); } - fputc('\n', config->output); + if (!first) + fputc('\n', config->output); } } =20 --=20 2.36.0.464.gb9c8b46e94-goog From nobody Sun May 10 14:12:26 2026 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 E1B59C433EF for ; Tue, 3 May 2022 04:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbiECEWE (ORCPT ); Tue, 3 May 2022 00:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbiECEVn (ORCPT ); Tue, 3 May 2022 00:21:43 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FF13CA74 for ; Mon, 2 May 2022 21:18:12 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2f7ee6bc6ddso152082467b3.1 for ; Mon, 02 May 2022 21:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qZYkK0QiKq2QKPszwBBc5ZNarCxrPY8dG8RgsS3qw5I=; b=fz9PewPyxjyTQCArVvRbymNYsWXATr1fj+gd6LaOOTRE5kG4bgI8Lf2sJ+gw0H38Wv /6tKf7w0KAU0cFq6Z8ZHgpfq57G0ENDBSTS2QnNY1FGoWVqNRKYiN2InHXvgYHuZmdXY R8+OtNyphACNsriRlxgKJJgY2acJJPQf7jlXveW8ycK1LfsjSBCtLM+pMBU7kS7mKu7x bmBf3wDsYFw+BVfNud9SoRSUH7GTOSFQg5MjRcLgpGA1psmuKLn/wiUdZwRmlLK+ap78 KJrIc2WDt5JJBcBvk3n48RiFgW7vGkEpJml7ltCRl6tUOst4RJGtMTPnvHmLj62p2APD aa0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qZYkK0QiKq2QKPszwBBc5ZNarCxrPY8dG8RgsS3qw5I=; b=iFZm+0ZGKQmKjMhFOsT6UPAns8LEE6Pueu6+Ntcq2YzThxGJf1ayfIeVINbBz61vQ1 hrFyLwMKv3AX8qwg8RhmE0Ri3KQhg3T46gu3oMEfXiDxwQ4sct5zi2ocxq2To2RlRGaW z6SEyPQelibFR1DUyvHN5IEbcuKh5mAMQS1P/k1YOYiBcl+jffAAU7bx2AmALZUCIW9J c2dbCRawaeRhCTHtWG11mWL9MBc4rRcrR116SQ0q/fsuUqqhuRDN/b7HO0VpBXJ1IXsq iFMMPcia5M75nep0aD6v0X/QKoCQY8+Tnp/Bvc+Xk01qreQCpf6cXgsPjDQwIe1L4et2 7+CA== X-Gm-Message-State: AOAM530+6gCKA7izTz6lRSxl+vh0SxgVy+JsgKAp5DhwfnESxeGLUSsB NOjTRuu+njNH6YlGm5moQ4dFjcKNywJu X-Google-Smtp-Source: ABdhPJx077Sx6pfDuCYkY9uKRPc4HO/I1fDmQkMxNFkxBO6TpMeXvcgzxUzF4eAREwfCmgFo6NmMk9+B9O/+ X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:dd4b:52bb:771d:7bb4]) (user=irogers job=sendgmr) by 2002:a81:1107:0:b0:2f7:cf9a:bd7 with SMTP id 7-20020a811107000000b002f7cf9a0bd7mr13980584ywr.482.1651551491508; Mon, 02 May 2022 21:18:11 -0700 (PDT) Date: Mon, 2 May 2022 21:17:55 -0700 In-Reply-To: <20220503041757.2365696-1-irogers@google.com> Message-Id: <20220503041757.2365696-5-irogers@google.com> Mime-Version: 1.0 References: <20220503041757.2365696-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v5 4/6] perf cpumap: Handle dummy maps as empty in subset From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" perf_cpu_map__empty is true for empty and dummy maps. Make is_subset respect that. Signed-off-by: Ian Rogers --- tools/lib/perf/cpumap.c | 4 ++-- tools/perf/tests/cpumap.c | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/lib/perf/cpumap.c b/tools/lib/perf/cpumap.c index 384d5e076ee4..9c83675788c2 100644 --- a/tools/lib/perf/cpumap.c +++ b/tools/lib/perf/cpumap.c @@ -322,9 +322,9 @@ struct perf_cpu perf_cpu_map__max(struct perf_cpu_map *= map) /** Is 'b' a subset of 'a'. */ bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct pe= rf_cpu_map *b) { - if (a =3D=3D b || !b) + if (a =3D=3D b || perf_cpu_map__empty(b)) return true; - if (!a || b->nr > a->nr) + if (perf_cpu_map__empty(a) || b->nr > a->nr) return false; =20 for (int i =3D 0, j =3D 0; i < a->nr; i++) { diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c index f94929ebb54b..d52b58395385 100644 --- a/tools/perf/tests/cpumap.c +++ b/tools/perf/tests/cpumap.c @@ -128,13 +128,21 @@ static int test__cpu_map_merge(struct test_suite *tes= t __maybe_unused, int subte struct perf_cpu_map *a =3D perf_cpu_map__new("4,2,1"); struct perf_cpu_map *b =3D perf_cpu_map__new("4,5,7"); struct perf_cpu_map *c =3D perf_cpu_map__merge(a, b); + struct perf_cpu_map *d =3D perf_cpu_map__dummy_new(); + struct perf_cpu_map *e =3D perf_cpu_map__merge(b, d); char buf[100]; =20 TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(c) =3D=3D= 5); cpu_map__snprint(c, buf, sizeof(buf)); TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "1-2,4-5,= 7")); - perf_cpu_map__put(b); + + TEST_ASSERT_VAL("failed to merge map: bad nr", perf_cpu_map__nr(e) =3D=3D= 3); + cpu_map__snprint(e, buf, sizeof(buf)); + TEST_ASSERT_VAL("failed to merge map: bad result", !strcmp(buf, "4-5,7")); + perf_cpu_map__put(c); + perf_cpu_map__put(d); + perf_cpu_map__put(e); return 0; } =20 --=20 2.36.0.464.gb9c8b46e94-goog From nobody Sun May 10 14:12:26 2026 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 E4A1EC433EF for ; Tue, 3 May 2022 04:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbiECEWK (ORCPT ); Tue, 3 May 2022 00:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231130AbiECEVp (ORCPT ); Tue, 3 May 2022 00:21:45 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B25F3CA4C for ; Mon, 2 May 2022 21:18:14 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f16f3a7c34so151109777b3.17 for ; Mon, 02 May 2022 21:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=b34dyzAkv3FpeidZX/hRwae+MMN4Fpbu6ur7DPv1sVY=; b=dLAMg9xp1Bq+8oU3LmNvjKFIrXLGRCu8ItgNKNl0yBRM/IPgPUjZR4T9cwl4AjprKX VH2eP91Vr9upMXDatSrCR7UCNj+lSpjaCv/Q6bGAzT4okUalpNpTa4OQ7JEh7PQO6nS7 XJoxtC1aL/9MLXcCnlh9iqm2wqoTb1C7IDB97XRTMQhHCMFJadDYzRBqRpv2A+Ot/Muv dHlAdyMc23yT/+tjQCHZzD6WBXnVUVfoCYXXfHFt5eeNNzbdq+iMvYTa7dkVy16dCqs1 2/bM4Jr69/xn/SONvckwuQpya2n84ceLgapNYrSDvgCX1OrMfqfImxGEuz8M6N6cpQOA e+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=b34dyzAkv3FpeidZX/hRwae+MMN4Fpbu6ur7DPv1sVY=; b=7vaSdidLPfHiV6rKPg6xIAAgS9ghcPmjFGNj+374BJRucR5+moqnf/B+0xeZ6Sd+sV M8T5aZW4r3PuRD2OgO7Q7Pe5TNcWp4WsmQNChsHlkRtBgqsNB9MNMqZJ4RXTbn9kOkxl RHrKSxIIfBhnsMHnYrh7bsEYq0jbgdVzBOixnqBlPeEBHIl9H/4ChKgZUWaM9DE8cqjA LoN5G4sGzx5aWcE1U6zE4QsBzDRxkHdXEExZ7WEblROW2qTJyRnbIrPNLwqF2N2xA0vD PZEdOBprbdZk58aKo/RZP0HmQwWMwFlP24GDX/WP2cN/cRriODjISkjl2AKUXpE8QFQg zWcQ== X-Gm-Message-State: AOAM530rAu3E98nJadVbF/D95lg+8H2TZjgAwcGBGKeNWGVSHCE8QoDG 5WqBEiC4sRoOUPqX8KPXn4wiIQ6hJsZ7 X-Google-Smtp-Source: ABdhPJyoF2H6Ud94AgIlUYETrlX7d0C8Y18ge1BtOFYyIMXyyoBHWH5yQIbJtH6V5bU9IQmL3ldGrs8QkD4Z X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:dd4b:52bb:771d:7bb4]) (user=irogers job=sendgmr) by 2002:a25:250c:0:b0:645:781c:3ec4 with SMTP id l12-20020a25250c000000b00645781c3ec4mr11902163ybl.143.1651551493698; Mon, 02 May 2022 21:18:13 -0700 (PDT) Date: Mon, 2 May 2022 21:17:56 -0700 In-Reply-To: <20220503041757.2365696-1-irogers@google.com> Message-Id: <20220503041757.2365696-6-irogers@google.com> Mime-Version: 1.0 References: <20220503041757.2365696-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v5 5/6] perf evlist: Add to user_requested_cpus documentation From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document a key use-case in propagation. Signed-off-by: Ian Rogers --- tools/lib/perf/include/internal/evlist.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/incl= ude/internal/evlist.h index e3e64f37db7b..74541bd87aa9 100644 --- a/tools/lib/perf/include/internal/evlist.h +++ b/tools/lib/perf/include/internal/evlist.h @@ -21,7 +21,8 @@ struct perf_evlist { bool has_user_cpus; /** * The cpus passed from the command line or all online CPUs by - * default. + * default. For evsels with no or dummy cpu maps, this cpu map replaces + * their cpus during propagation. */ struct perf_cpu_map *user_requested_cpus; /** The union of all evsel cpu maps. */ --=20 2.36.0.464.gb9c8b46e94-goog From nobody Sun May 10 14:12:26 2026 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 E0D76C433EF for ; Tue, 3 May 2022 04:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231165AbiECEWP (ORCPT ); Tue, 3 May 2022 00:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbiECEVs (ORCPT ); Tue, 3 May 2022 00:21:48 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDBDD3CA76 for ; Mon, 2 May 2022 21:18:16 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b6-20020a5b0b46000000b006457d921729so14748971ybr.23 for ; Mon, 02 May 2022 21:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=a46QziEU66/cDbtPub87VXrgG7YIg8QLWbq+SG0jhNk=; b=JI3XL0LVYp4aIVcMMZiF5LQC+k/3cgbjsFX6UZUIJRgGOj0ArqWK70q/CP/pRc4Pb/ I2bc9CwhZ0RYsAlPEqXmNpu0TjCKyE9UV52oh1OnXnscL3BcWQQhetveq+XMJNQASFRF +v8uZCvfWZPpY5urJli9yk9S3WaVe1EYgH5CSx53MqfQPIui49iqvB9TWfXRbdYTuGQR IwvqwxyE5XKPA+LtPqerzVWgPJp6zZXH+X6jlOdbx2cIbr2KYyJzXtN9Z+bHlLCu6OaA 7jdCwFxGdPX3BLI2f+vuvnUZ6fBB5qvnfND94xBN+usidqDVxbuFc/Jn58nYnf0EGj+q Cizw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=a46QziEU66/cDbtPub87VXrgG7YIg8QLWbq+SG0jhNk=; b=yybD24Jzm1uv3oJrQO/RkmZiE9XyYUZfaki6H7uLhanSM3rzDGhgtFQM1ozLX08VhR hhSefMNRDL+6RiIVeCaMs4STGMXiScrovcqbFvasG/iCJMMjPHpBcw4+MQLPjG46pLoj 9EhpCs188LTXHlU1rnN3r1jBkamnVCanSiPJCUUBTxNLtnKy4jFIWTooiKP5SQUpftbl IEHIcKGgFqf0OBk/calHZsHugp8aOl28eTdwesP8wK72qtkMWSzKPUVkQvt/zXlf5Fpc qejcgxyTe5o40wV996fAFUuLL435GVzfxrtksj9t+a55rOhpCXf5TsUQPHua6sk6MFMG HthA== X-Gm-Message-State: AOAM531iOXfkO3JuIRa6Dxylc6CTu7BI5EMkD7TwPzsdSwvnw7bOQc6i WW5SCt/zuhfX2bK2G84/LUHOsGzrLxW1 X-Google-Smtp-Source: ABdhPJyfalc/ICdgSYqrnMy1h3zYTiirmygQqTMEhjgiC/ZvA/YUm3m32+/MWC5pnWX2F74QpR4kP0Sw0juN X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:dd4b:52bb:771d:7bb4]) (user=irogers job=sendgmr) by 2002:a25:f414:0:b0:624:33e:e486 with SMTP id q20-20020a25f414000000b00624033ee486mr12282880ybd.361.1651551495993; Mon, 02 May 2022 21:18:15 -0700 (PDT) Date: Mon, 2 May 2022 21:17:57 -0700 In-Reply-To: <20220503041757.2365696-1-irogers@google.com> Message-Id: <20220503041757.2365696-7-irogers@google.com> Mime-Version: 1.0 References: <20220503041757.2365696-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v5 6/6] perf evlist: Rename all_cpus From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Kajol Jain , James Clark , German Gomez , Adrian Hunter , Riccardo Mancini , Andi Kleen , Alexey Bayduraev , Alexander Antonov , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Try to make the struct variable clearer by renaming to merged_evsel_cpus. Signed-off-by: Ian Rogers --- tools/lib/perf/evlist.c | 16 ++++++++-------- tools/lib/perf/include/internal/evlist.h | 2 +- tools/perf/util/bpf_counter_cgroup.c | 12 ++++++------ tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evlist.h | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index 974b4585f93e..5840a9377494 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -52,16 +52,16 @@ static void __perf_evlist__propagate_maps(struct perf_e= vlist *evlist, =20 perf_thread_map__put(evsel->threads); evsel->threads =3D perf_thread_map__get(evlist->threads); - evlist->all_cpus =3D perf_cpu_map__merge(evlist->all_cpus, evsel->cpus); + evlist->merged_evsel_cpus =3D perf_cpu_map__merge(evlist->merged_evsel_cp= us, evsel->cpus); } =20 static void perf_evlist__propagate_maps(struct perf_evlist *evlist) { struct perf_evsel *evsel; =20 - /* Recomputing all_cpus, so start with a blank slate. */ - perf_cpu_map__put(evlist->all_cpus); - evlist->all_cpus =3D NULL; + /* Recomputing merged_evsel_cpus, so start with a blank slate. */ + perf_cpu_map__put(evlist->merged_evsel_cpus); + evlist->merged_evsel_cpus =3D NULL; =20 perf_evlist__for_each_evsel(evlist, evsel) __perf_evlist__propagate_maps(evlist, evsel); @@ -128,10 +128,10 @@ static void perf_evlist__purge(struct perf_evlist *ev= list) void perf_evlist__exit(struct perf_evlist *evlist) { perf_cpu_map__put(evlist->user_requested_cpus); - perf_cpu_map__put(evlist->all_cpus); + perf_cpu_map__put(evlist->merged_evsel_cpus); perf_thread_map__put(evlist->threads); evlist->user_requested_cpus =3D NULL; - evlist->all_cpus =3D NULL; + evlist->merged_evsel_cpus =3D NULL; evlist->threads =3D NULL; fdarray__exit(&evlist->pollfd); } @@ -169,8 +169,8 @@ void perf_evlist__set_maps(struct perf_evlist *evlist, evlist->threads =3D perf_thread_map__get(threads); } =20 - if (!evlist->all_cpus && cpus) - evlist->all_cpus =3D perf_cpu_map__get(cpus); + if (!evlist->merged_evsel_cpus && cpus) + evlist->merged_evsel_cpus =3D perf_cpu_map__get(cpus); =20 perf_evlist__propagate_maps(evlist); } diff --git a/tools/lib/perf/include/internal/evlist.h b/tools/lib/perf/incl= ude/internal/evlist.h index 74541bd87aa9..3a0a47ba8c57 100644 --- a/tools/lib/perf/include/internal/evlist.h +++ b/tools/lib/perf/include/internal/evlist.h @@ -26,7 +26,7 @@ struct perf_evlist { */ struct perf_cpu_map *user_requested_cpus; /** The union of all evsel cpu maps. */ - struct perf_cpu_map *all_cpus; + struct perf_cpu_map *merged_evsel_cpus; struct perf_thread_map *threads; int nr_mmaps; size_t mmap_len; diff --git a/tools/perf/util/bpf_counter_cgroup.c b/tools/perf/util/bpf_cou= nter_cgroup.c index 63b9db657442..35e92b889c3b 100644 --- a/tools/perf/util/bpf_counter_cgroup.c +++ b/tools/perf/util/bpf_counter_cgroup.c @@ -88,12 +88,12 @@ static int bperf_load_program(struct evlist *evlist) err =3D -1; =20 cgrp_switch =3D evsel__new(&cgrp_switch_attr); - if (evsel__open_per_cpu(cgrp_switch, evlist->core.all_cpus, -1) < 0) { + if (evsel__open_per_cpu(cgrp_switch, evlist->core.merged_evsel_cpus, -1) = < 0) { pr_err("Failed to open cgroup switches event\n"); goto out; } =20 - perf_cpu_map__for_each_cpu(cpu, i, evlist->core.all_cpus) { + perf_cpu_map__for_each_cpu(cpu, i, evlist->core.merged_evsel_cpus) { link =3D bpf_program__attach_perf_event(skel->progs.on_cgrp_switch, FD(cgrp_switch, cpu.cpu)); if (IS_ERR(link)) { @@ -115,14 +115,14 @@ static int bperf_load_program(struct evlist *evlist) evsel->cgrp =3D NULL; =20 /* open single copy of the events w/o cgroup */ - err =3D evsel__open_per_cpu(evsel, evlist->core.all_cpus, -1); + err =3D evsel__open_per_cpu(evsel, evlist->core.merged_evsel_cpus, -1); if (err) { pr_err("Failed to open first cgroup events\n"); goto out; } =20 map_fd =3D bpf_map__fd(skel->maps.events); - perf_cpu_map__for_each_cpu(cpu, j, evlist->core.all_cpus) { + perf_cpu_map__for_each_cpu(cpu, j, evlist->core.merged_evsel_cpus) { int fd =3D FD(evsel, cpu.cpu); __u32 idx =3D evsel->core.idx * total_cpus + cpu.cpu; =20 @@ -210,7 +210,7 @@ static int bperf_cgrp__sync_counters(struct evlist *evl= ist) int idx; int prog_fd =3D bpf_program__fd(skel->progs.trigger_read); =20 - perf_cpu_map__for_each_cpu(cpu, idx, evlist->core.all_cpus) + perf_cpu_map__for_each_cpu(cpu, idx, evlist->core.merged_evsel_cpus) bperf_trigger_reading(prog_fd, cpu.cpu); =20 return 0; @@ -269,7 +269,7 @@ static int bperf_cgrp__read(struct evsel *evsel) goto out; } =20 - perf_cpu_map__for_each_cpu(cpu, i, evlist->core.all_cpus) { + perf_cpu_map__for_each_cpu(cpu, i, evlist->core.merged_evsel_cpus) { counts =3D perf_counts(evsel->counts, i, 0); counts->val =3D values[cpu.cpu].counter; counts->ena =3D values[cpu.cpu].enabled; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 52ea004ba01e..57ecd94e6f9e 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -349,7 +349,7 @@ struct evlist_cpu_iterator evlist__cpu_begin(struct evl= ist *evlist, struct affin .evsel =3D NULL, .cpu_map_idx =3D 0, .evlist_cpu_map_idx =3D 0, - .evlist_cpu_map_nr =3D perf_cpu_map__nr(evlist->core.all_cpus), + .evlist_cpu_map_nr =3D perf_cpu_map__nr(evlist->core.merged_evsel_cpus), .cpu =3D (struct perf_cpu){ .cpu =3D -1}, .affinity =3D affinity, }; @@ -360,7 +360,7 @@ struct evlist_cpu_iterator evlist__cpu_begin(struct evl= ist *evlist, struct affin } else { itr.evsel =3D evlist__first(evlist); if (itr.affinity) { - itr.cpu =3D perf_cpu_map__cpu(evlist->core.all_cpus, 0); + itr.cpu =3D perf_cpu_map__cpu(evlist->core.merged_evsel_cpus, 0); affinity__set(itr.affinity, itr.cpu.cpu); itr.cpu_map_idx =3D perf_cpu_map__idx(itr.evsel->core.cpus, itr.cpu); /* @@ -388,7 +388,7 @@ void evlist_cpu_iterator__next(struct evlist_cpu_iterat= or *evlist_cpu_itr) if (evlist_cpu_itr->evlist_cpu_map_idx < evlist_cpu_itr->evlist_cpu_map_n= r) { evlist_cpu_itr->evsel =3D evlist__first(evlist_cpu_itr->container); evlist_cpu_itr->cpu =3D - perf_cpu_map__cpu(evlist_cpu_itr->container->core.all_cpus, + perf_cpu_map__cpu(evlist_cpu_itr->container->core.merged_evsel_cpus, evlist_cpu_itr->evlist_cpu_map_idx); if (evlist_cpu_itr->affinity) affinity__set(evlist_cpu_itr->affinity, evlist_cpu_itr->cpu.cpu); diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index a21daaa5fc1b..e2e68f988d26 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -336,12 +336,12 @@ struct evlist_cpu_iterator { /** The CPU map index corresponding to the evsel->core.cpus for the curre= nt CPU. */ int cpu_map_idx; /** - * The CPU map index corresponding to evlist->core.all_cpus for the + * The CPU map index corresponding to evlist->core.merged_evsel_cpus for = the * current CPU. Distinct from cpu_map_idx as the evsel's cpu map may * contain fewer entries. */ int evlist_cpu_map_idx; - /** The number of CPU map entries in evlist->core.all_cpus. */ + /** The number of CPU map entries in evlist->core.merged_evsel_cpus. */ int evlist_cpu_map_nr; /** The current CPU of the iterator. */ struct perf_cpu cpu; --=20 2.36.0.464.gb9c8b46e94-goog