From nobody Mon Jun 15 10:14:12 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 EBAAAC433EF for ; Sat, 30 Apr 2022 06:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356068AbiD3G1A (ORCPT ); Sat, 30 Apr 2022 02:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235069AbiD3G0z (ORCPT ); Sat, 30 Apr 2022 02:26:55 -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 91A1F67D2D for ; Fri, 29 Apr 2022 23:23:34 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2e642be1a51so92754327b3.21 for ; Fri, 29 Apr 2022 23:23:34 -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=tcObfq8Nd5uZdGvF9hEbsjXFIltRilEurI4N4H1VAUs=; b=kZeIqQt8Ii5glk0K9RWxv0Y8+tU5rwCkZR338TAwJ+F4sK4BcmaamZUmfXk7dLwAzU VcAu8hPA+YnbCzBEFGaVJDaO/7EIWXW6g7yMvzlH+7J7rD0paNgo8fIyCG+rSklun8RT R1rwEcQ1YgSx8WpDsKQIo3fz2WpK++CLYWnER5hRDPdezR/tekx6jGwC8mCMRAVjEWL+ HHk1XZn/2UTN29Ove66JZ2zHyO356yYI9ODkydGoFcU2vXkDAUrMvLA5HxMCx4I7q6PZ s4pEROX7VJeB0owJx6mYlLjmfjzG0wAxJ+rbedBvOek/OnQoWNkoFCJS4lt4j+/KFcbz 1c6w== 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=tcObfq8Nd5uZdGvF9hEbsjXFIltRilEurI4N4H1VAUs=; b=QX7IPnxZQiLv4YWejt9M1bvHGxrcIBf62H+itU0t9ygfi/kODgwnSGfli1r9kJw8+r 3nqwDmuVYu7eA9Eu8olah+CJQDSGPTMuxB12Yr22OpLklo3YAKMs/d0qSDPWuYJp5iwv 49X/+7sXxwdOezyaNe4wTXhAht/f7jbJe+GO+iq9KlIf8UtnLr+g+diF/qSeRXll2HFj WCXueKKETdd5C963J0ba3KEs3bn5lsKSH8y/6SRnAR5PMH+y0VYLETBUwFx9NO8J4tzf KanuQzZVX6HvZ0oJnpIIB9CzTJ44qLLfheAj6dN1XJ6V/exCc9ifteRWdSoxlGqtF9Pj 4VJg== X-Gm-Message-State: AOAM533F0NcuUAGrFUEpIOvKrMl3EuBUkLTs7jOuip+eZRn2VGL9Jyqn YV8jWTlxHo2k2FFDCJScFXW/I5zQVAkZ X-Google-Smtp-Source: ABdhPJw+0iChHXMR8nCWK4gTypeBNpwhtyGhs4uDyTQg6LJo/pg2i4nMt1vywPBcNaBMLokt8QHaLwaMHsEr X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:2481:caab:4fd5:232b]) (user=irogers job=sendgmr) by 2002:a25:d20f:0:b0:648:d034:8708 with SMTP id j15-20020a25d20f000000b00648d0348708mr2480138ybg.509.1651299813728; Fri, 29 Apr 2022 23:23:33 -0700 (PDT) Date: Fri, 29 Apr 2022 23:23:19 -0700 In-Reply-To: <20220430062324.1565215-1-irogers@google.com> Message-Id: <20220430062324.1565215-2-irogers@google.com> Mime-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 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. Signed-off-by: Ian Rogers --- tools/perf/builtin-record.c | 13 ++++++------ tools/perf/util/bpf_counter_cgroup.c | 31 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 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..a4b676920da0 100644 --- a/tools/perf/util/bpf_counter_cgroup.c +++ b/tools/perf/util/bpf_counter_cgroup.c @@ -47,7 +47,7 @@ static int bperf_load_program(struct evlist *evlist) struct evsel *evsel; struct cgroup *cgrp, *leader_cgrp; __u32 i, cpu; - __u32 nr_cpus =3D evlist->core.all_cpus->nr; + __u32 nr_cpus =3D perf_cpu_map__nr(evlist->core.all_cpus); int total_cpus =3D cpu__max_cpu().cpu; int map_size, map_fd; int prog_fd, err; @@ -125,7 +125,7 @@ static int bperf_load_program(struct evlist *evlist) 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__cpu(evlist->core.all_cpus, cpu).cpu; =20 err =3D bpf_map_update_elem(map_fd, &idx, &fd, BPF_ANY); @@ -207,13 +207,13 @@ 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, cpus) { + cpu =3D perf_cpu_map__cpu(evlist->core.all_cpus, i); + bperf_trigger_reading(prog_fd, cpu.cpu); } =20 return 0; @@ -244,12 +244,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 +261,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_map 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 +272,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_cpu) { 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 Mon Jun 15 10:14:12 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 CC89EC433EF for ; Sat, 30 Apr 2022 06:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382176AbiD3G1G (ORCPT ); Sat, 30 Apr 2022 02:27:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241361AbiD3G05 (ORCPT ); Sat, 30 Apr 2022 02:26:57 -0400 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 E1B15CFE43 for ; Fri, 29 Apr 2022 23:23:36 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 7-20020a250c07000000b0064137917a4eso9166337ybm.12 for ; Fri, 29 Apr 2022 23:23:36 -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=VBOkfSXM46pJ80dgupLJN/D1Z7T4yXWGOJ+DI1vGk++6kp1gHBu561dvEsfHpL5o2f 7wiKW8+aiHaP+tw9Vc/BpMDSEtzCsCQUrc/SFTRggF4GHyZ2stzGv2Pe1hJpYg0uGJSn tB7jYNqDPL+x7qRlKddqqk3hZnQU9/O59T9eBocCbDUDIYsscz5b8RlIPoVS6gKUoYOo LsRcFKjlm22Tqo1jSDyrWsEevSiiOYcAgJZ6mcKSuF+1e1SOe+iTlqhDMTYDc8F4R659 hIPKUlZNRDKRI5ijUWBupwo5z/zVsb7qjGmsgfxL5E+IPP2XJgt2W3sxeAdrF5oueksY 024w== 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=xLMooxB/2QJlxEG+keQ6gbUDgoVipTzV1/CGyovcwMBWWyFWTeyw1hvvhyvYazFatN sMH5wz6uu9QFOFKBMJMCGllxAOEfqr9G8hIA/HaNOncpvJFwSAS4JWpMZCbmD+turt5d r3EDFPZwtvCKlZPWGlEds9BkvSfWnQL0yK7IKl2gdTQsTQ6phgt7Z4HwnU59azgC7soP oYhoDAq30ZnN8IncEoaeyjdwHokT7A0DFuLA+kFSPTJBvCWIYfiB41ro7tRlEJHoR7UX HEI4pCIAxO05hEg9UnEwl7Uqf4cXsrhx6/zQnG0sECrKT4Oi3+J14qCyVLCHqvmwHMkM Vgcg== X-Gm-Message-State: AOAM5311LBVHmyl0KGnqWCtfG3m8AorEGq14tdkv4fWp97bFCMEwpQ5k My9U6e/4JFxagd/X3JkCptLkwuiKTHSZ X-Google-Smtp-Source: ABdhPJyJgzcdDR0Vabh1YpL71QKZ80jgYwvO35Fkq3RG6FcWK2FDtt70eli+OZlIVxeHRUcVSfpDNWMn1I1n X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:2481:caab:4fd5:232b]) (user=irogers job=sendgmr) by 2002:a81:7b05:0:b0:2f4:e45a:b06e with SMTP id w5-20020a817b05000000b002f4e45ab06emr2725986ywc.458.1651299816033; Fri, 29 Apr 2022 23:23:36 -0700 (PDT) Date: Fri, 29 Apr 2022 23:23:20 -0700 In-Reply-To: <20220430062324.1565215-1-irogers@google.com> Message-Id: <20220430062324.1565215-3-irogers@google.com> Mime-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 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 --- 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 Mon Jun 15 10:14:12 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 A97CAC433F5 for ; Sat, 30 Apr 2022 06:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382197AbiD3G1X (ORCPT ); Sat, 30 Apr 2022 02:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351560AbiD3G1A (ORCPT ); Sat, 30 Apr 2022 02:27:00 -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 00B8DCFE41 for ; Fri, 29 Apr 2022 23:23:38 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 7-20020a250c07000000b0064137917a4eso9166365ybm.12 for ; Fri, 29 Apr 2022 23:23:38 -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=QbAjsSCqSFDRCvHRrmziRST5Dc++EK/823h/RlAIK5g=; b=Rpq1AfeufiJjUWDBocUZh5TWrWdBIcyIGdUOys38n1LCXddAZUD8/lMYA2uJRYehiv DJdYXSKB0Hjp0LHw9ULlY+OmkhssK/42gfA+pTnH6aD1X9Ut0J6A1CpwvqsLNiZUKztC NhPKS9v4ShPG2UBHIp8gp35xL9Nxz1PyCzOIOViTHGblDrrLt7QcExXLDPH4rV61CgiG CjmKNPwrEg+ZXczN6euaoH4tweUxuwjVdDFqbjruJo1ciq9x1Hd9kK2ZAMoWKoqI933l 8jWtvxs93NlAFlzrxmz3QO4j2WyXZHhVH+2Rt7II1m6DbaIchOfRMjYbqaQwN3aKQ+Ye GpdA== 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=QbAjsSCqSFDRCvHRrmziRST5Dc++EK/823h/RlAIK5g=; b=4lBkN6JKhL4Raq2S+wsP7H+apiZOjgwnLm6wqhMS8qGtqCxaaILjnqNV1TywWnRsoI IwP/oI7WM4b0pdjGfsgUtEmDs7B2Up7/mZD2+2QglZj4rNFTqCAbrV8GTya9+eUwYobg Kq5wiVdC0rugj8cfrJ03ztkhhVVTh/iKkWbVsZn2018Xia0lldKFFHO4orpnP+rMm9a5 4t+MY1dhHq2PVDaY2dgWF/RHfgiL0kWnEcDIfb/x1Hmtc3ZIBVue8oWsZNoAk6a9u36D GUmkBkCd6X8rT0SAxq4cNO/a+sLINkr0R7mZd6P+qgqy5x1fzcieg1iWDhfSSLhP8JJG 6eMg== X-Gm-Message-State: AOAM532GeFryKyamm4w2Hhe1/U2bjaJyYmkcesDD0aMR00YORkplm62U OuGRXyCLdaGcZZnB4p+uhxCvU6UgAsz4 X-Google-Smtp-Source: ABdhPJwWdCK9HhHKXU+Zq1v3vI46L5oK3Vj6FtMCyKhUPVl+Q23X1BMEt6F/666jhslBJLRWT0lcaV/p492J X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:2481:caab:4fd5:232b]) (user=irogers job=sendgmr) by 2002:a25:6788:0:b0:648:d8c0:2ed4 with SMTP id b130-20020a256788000000b00648d8c02ed4mr2483910ybc.577.1651299818209; Fri, 29 Apr 2022 23:23:38 -0700 (PDT) Date: Fri, 29 Apr 2022 23:23:21 -0700 In-Reply-To: <20220430062324.1565215-1-irogers@google.com> Message-Id: <20220430062324.1565215-4-irogers@google.com> Mime-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 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. Signed-off-by: Ian Rogers Reviewed-by: Adrian Hunter --- 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 Mon Jun 15 10:14:12 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 85225C433F5 for ; Sat, 30 Apr 2022 06:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382234AbiD3G1f (ORCPT ); Sat, 30 Apr 2022 02:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382172AbiD3G1E (ORCPT ); Sat, 30 Apr 2022 02:27:04 -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 3E08CCFE59 for ; Fri, 29 Apr 2022 23:23:41 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f7ee6bc6ddso93965557b3.1 for ; Fri, 29 Apr 2022 23:23:41 -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=fRsyW6GbkMphhji6HkWrwSTwBAXGNvOlpnZsEL3PdGLSZJ1r7S1xYRjtrLOozK6mWl 3qX3nxKGG2OnhVNIR+ZBXx1evctirZeziZih4gSH/j41Wikg/rbabyFZNsS/NSiOeJyy 3ELoH1FKtB09fYuffeKdXu387tSyafRzaWMlEDjNWA8W6e+zvA7Hum8uO5Ejk0ayaTI5 9NJQk9nM9n7AIYvrQKhRVbp7rzsc0+0lRzwekIYGw03prwRWy7pQqVxyVg/EWQkMWh88 bmnnuvX4EC5Rfnr4firZh3dLp30gU8kumxP8KLeKzbd1R7U2Spu/q8Q2ZbG9CoqheSgA XO2w== 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=lFwVKV4TA6rWVDsn1pD+DoV06jUJ/3LE2QAdA27YVxNmWyd4l+Rfe2pBO+/yDWK5h8 E9vLokTzAbVc/PjI+kYDadQguXqqqW5M71xFFU6kZkTorEO6XlcJ2y5jgrNZdnDo2W5X y9DBJGcjcmxIR65wSIBYpYYgVk0EuHleqoPugEHv9nfC4lgqdlUCLLCsJWmPkSQ/dJwD fd31aHBJZDC2rF9qIScBJIoX4+pxYyrhNVCgUHuvcUkV1vkynVU25AoVelnPqzxHHS7Y cHm+ItznYAO2nwxV8XBI2LmJJBmo/nB+PIu3cNrLVgk4KnKNb/xfSplWQeTwlwi0nMup rVOA== X-Gm-Message-State: AOAM531afzu3YbQLZV+aUn0WYkdBy3pOVJ1Kb8tkrXj3q/fX4hvh2qdU 9ZKRaBjB5Px6vL6CmdtOLsdoqos+N2PQ X-Google-Smtp-Source: ABdhPJxSNfQpR1Zv3c0Oz3hL/CjnVXqYxzCUyoTub6sZuefdc82ZfacJXBoI0or/vNiIC4+++3Egz2cSgZ1n X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:2481:caab:4fd5:232b]) (user=irogers job=sendgmr) by 2002:a25:4944:0:b0:648:a796:a2 with SMTP id w65-20020a254944000000b00648a79600a2mr2761055yba.123.1651299820173; Fri, 29 Apr 2022 23:23:40 -0700 (PDT) Date: Fri, 29 Apr 2022 23:23:22 -0700 In-Reply-To: <20220430062324.1565215-1-irogers@google.com> Message-Id: <20220430062324.1565215-5-irogers@google.com> Mime-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 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 Mon Jun 15 10:14:12 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 2AD37C433F5 for ; Sat, 30 Apr 2022 06:24:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351560AbiD3G1n (ORCPT ); Sat, 30 Apr 2022 02:27:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382206AbiD3G1E (ORCPT ); Sat, 30 Apr 2022 02:27:04 -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 7896FCFE7B for ; Fri, 29 Apr 2022 23:23:43 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2f84aeb403fso86609797b3.22 for ; Fri, 29 Apr 2022 23:23:43 -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=hfLIL3a4Zhyyg3Nc2LxQ8wkrEYWraDLuY33gtpHXcSjAROtxwWSNuXWNoYgOgSw20m 0+DB+YjgUYpjZQXDSb+TYy5nApOeR9ChnhcPR77D52Jb2xiCS6gr39wJ7BuA5lUpW7S6 2XQXEigKXZNKefV3Qi+NqtplyP6VnyHZYvloh1lRlrGViDW3qdXXAAX6WqeuNBA4M+Ef x+n/WqFMozmxM0KnfddJL0rzgoTTpUwa9dnjG7T7b8xwlmNLekjz+hWYmb21LKC9UbXv sh0fHsDR/BqKByFiaxUF1xnIuh+7znh0ApsYAmYS2rKsdJCuj04OFbYLsXHyN9vtRrSK HdNA== 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=399v+YmEkM12YV/wbRS0qyByxitMupW2Amh3zSUKL+2tqEddnIvz+G8ZNoD5hNiSL/ mYxTJHVmdTGdQcb6rvZ3dZUsI1y3kVHISxf9p8oDil6jHaUEkEsKniCEnu8XRuak4Nk6 b47AP/VEWi4gEDqw2gwzWaiG6B9hNoTTgohmtTocFWb0Nkxy5De+XI9tD5NWPYrKjWSj hxcoXKBBg6SOQWDl1KzxUalPOmET4litAPtRU+/6Gswmhws5hNFpT97OE0U0HHzWJOJI v2ggJ1ePEFpqEY6lZNI84H/Bp11G3NOlLn07jkaqyO57AFxMgG4AAL621/8U1s2cVNOT wMYg== X-Gm-Message-State: AOAM533OZD9OelZyhxkNEl62jqJiYLt+vJQmdzt6jv7Ushi/SQPLODG1 JIsu2QbnEp9qmAJOsEfBpPG0AVLCEJQ8 X-Google-Smtp-Source: ABdhPJxJRQJNZzDBHJN5YDt1lFxHqwUQLyivISTont2ekEDl8igflw9m4NtiuFCJeFVuGHhCDiRVX/QeMkHf X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:2481:caab:4fd5:232b]) (user=irogers job=sendgmr) by 2002:a25:df8a:0:b0:647:4954:83e8 with SMTP id w132-20020a25df8a000000b00647495483e8mr2482748ybg.526.1651299822443; Fri, 29 Apr 2022 23:23:42 -0700 (PDT) Date: Fri, 29 Apr 2022 23:23:23 -0700 In-Reply-To: <20220430062324.1565215-1-irogers@google.com> Message-Id: <20220430062324.1565215-6-irogers@google.com> Mime-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 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 Mon Jun 15 10:14:12 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 3E907C433F5 for ; Sat, 30 Apr 2022 06:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382217AbiD3G1v (ORCPT ); Sat, 30 Apr 2022 02:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382202AbiD3G1G (ORCPT ); Sat, 30 Apr 2022 02:27:06 -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 7FBA0CFE44 for ; Fri, 29 Apr 2022 23:23:45 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-2e642be1a51so92756317b3.21 for ; Fri, 29 Apr 2022 23:23:45 -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=q3eYGfM76QKHgEVCmlimxa1q1+ls75+CcUBEqRt2248=; b=ptYYGqJWHOX4CODWcwor5qnwKhVEGFTrduWyiC+2YvEyUqTi/yNMPAOfd1zzRYDA6G U+BSOFARw1/GQ8y3pSn67WQU0O2e+DTSb8SbKBOL0+pYBS1yTeMlTJe8VPh308/l9aDc l4jEvhmZb26OeOE6pl1otQWa2UX5gnZNRimWDQ1GpDaJTTh4HtYk8voqkRelrs2NQf/k 9Y26hRFkIObqiHN1otJNHoKQiwLvfSH6Hf7i5RCFR5S+4/r/w+bkzBrvyR8lsdQgmtEU pOFuxkDphKQNzN6Ld0ZgYV3w8jq7mypBXMcSZn9aJZheaEkvxgSUwPoaAAGuqLWn9oUz TuTw== 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=q3eYGfM76QKHgEVCmlimxa1q1+ls75+CcUBEqRt2248=; b=g2hXX93O3b6N+c9QXa0zbkvyCR/Q6rY1Edll+lU35zneDgBl/GBH7Ga2RFepbCLdBp b0mfQWJQLw6xdc2vOl0L/mTky23YDcf2uggvsNdunlci3dQnagfL/+4OJ6OksXqswGDI bBWOW5yDvuiR3q6SzpRzCfZqcUl71uBNMUbjxIO+oLt7nWfWKTCASx4edFxfJb4GKOAE zHM93xwRaadcBBXcxjlQdZFgWYnHGgCgksuqbxwSU9lLfDoBVPisDn9rlAwCHAtXxG08 P5X9D5VVfudDJT24WHcQHWKcPLiiyj1XAa/VrIOJCPCEyUI9WyIqFV4KTparnRQujY23 eUhQ== X-Gm-Message-State: AOAM531DjyDjYYivY60UJjZ20qw3NGM6pAx1645VJHqc6dGe8EcsWMNf AHmI/J0FzAlqsQGPrVN9uFxkRZE7zsD6 X-Google-Smtp-Source: ABdhPJzEEiG4DHzJkhoc5aJb5CrqIVnK1IgaIiTz6LbTY6tX1Pocer4suNX20yTlkyaLjtNNjC/Y1IFlKse5 X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:2481:caab:4fd5:232b]) (user=irogers job=sendgmr) by 2002:a25:dc5:0:b0:648:f7b4:7cb6 with SMTP id 188-20020a250dc5000000b00648f7b47cb6mr2667075ybn.379.1651299824700; Fri, 29 Apr 2022 23:23:44 -0700 (PDT) Date: Fri, 29 Apr 2022 23:23:24 -0700 In-Reply-To: <20220430062324.1565215-1-irogers@google.com> Message-Id: <20220430062324.1565215-7-irogers@google.com> Mime-Version: 1.0 References: <20220430062324.1565215-1-irogers@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v4 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 | 10 +++++----- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evlist.h | 4 ++-- 5 files changed, 19 insertions(+), 19 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 a4b676920da0..521f1e2b1bce 100644 --- a/tools/perf/util/bpf_counter_cgroup.c +++ b/tools/perf/util/bpf_counter_cgroup.c @@ -47,7 +47,7 @@ static int bperf_load_program(struct evlist *evlist) struct evsel *evsel; struct cgroup *cgrp, *leader_cgrp; __u32 i, cpu; - __u32 nr_cpus =3D perf_cpu_map__nr(evlist->core.all_cpus); + __u32 nr_cpus =3D perf_cpu_map__nr(evlist->core.merged_evsel_cpus); int total_cpus =3D cpu__max_cpu().cpu; int map_size, map_fd; int prog_fd, err; @@ -88,7 +88,7 @@ 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; } @@ -115,7 +115,7 @@ 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; @@ -125,7 +125,7 @@ static int bperf_load_program(struct evlist *evlist) for (cpu =3D 0; cpu < nr_cpus; cpu++) { int fd =3D FD(evsel, cpu); __u32 idx =3D evsel->core.idx * total_cpus + - perf_cpu_map__cpu(evlist->core.all_cpus, cpu).cpu; + perf_cpu_map__cpu(evlist->core.merged_evsel_cpus, cpu).cpu; =20 err =3D bpf_map_update_elem(map_fd, &idx, &fd, BPF_ANY); @@ -212,7 +212,7 @@ static int bperf_cgrp__sync_counters(struct evlist *evl= ist) int prog_fd =3D bpf_program__fd(skel->progs.trigger_read); =20 perf_cpu_map__for_each_cpu(cpu, idx, cpus) { - cpu =3D perf_cpu_map__cpu(evlist->core.all_cpus, i); + cpu =3D perf_cpu_map__cpu(evlist->core.merged_evsel_cpus, i); bperf_trigger_reading(prog_fd, cpu.cpu); } =20 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