From nobody Sun Feb 8 20:00:19 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 EDFEDC77B73 for ; Fri, 26 May 2023 21:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244111AbjEZVzB (ORCPT ); Fri, 26 May 2023 17:55:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243916AbjEZVyf (ORCPT ); Fri, 26 May 2023 17:54:35 -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 2CF97135 for ; Fri, 26 May 2023 14:54:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-bacfa4eefd2so3139223276.0 for ; Fri, 26 May 2023 14:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685138070; x=1687730070; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=sTjkcSrIthqBGUF6JyF++nlWwrpLfc1jVqkJtlkt6PQ=; b=w25K3uEgKsF2ESRt4NqswniKM+kqGVpYNbZAC3VV1XivKvawMUAL6LVTMMcJxXQBFb FRg3ZkENeETKjEOtpf9Oxs3HEnHv9vC702x+tfxnLj0KCOpviMP/uuvf3eHH4eVmCXX2 QlWwQxHFuKt0+sC/rwn7FmT/72Cb28MCup5wqZ6c+ghLtyHyrLcxED5iu7/4pUMw2f/H KP5tGz126hCsKh7w5htUiXSvgg5MhWi9cSbRfyC5lmpNzLrI3tHRUvnao8H/Zx7qap4I o5VgvKPBtaw4iY+aMhbxnS+e4o240Y8rT5A92F2E7tu5l9Ys1HwNRKOdkI9yOfCgPgI/ P1XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685138070; x=1687730070; 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=sTjkcSrIthqBGUF6JyF++nlWwrpLfc1jVqkJtlkt6PQ=; b=jb8114hHrlHWGum3zVBsmkRqXQz6yzk1THDQ6v43ddVZ/VJQCLrxTw6XbvGwgr3BVk badRFPwwHgiya7jg3jrkhnBS7LtxKwPppON0gy7w5GIQKpYv02d7VEkAU7LDznV3dw6e zoKfLmWE+SnofjaIBkWGLWmrvkwydxjrUrKmevjaxejjl0SNoJkYveZ/eZ01czt7IYN3 mIjZmG9aHgrBeWsYS6aDkZJkgyLwkryDhx0EvIvrXAn+8dwcI+RtxTt1KZngBnne+GMN 6pUlH9xbTks3qH+CuXS9Rgtyhl+RxCkf5I4l7QoNXjgkZpyOaDouJ04+f+o7bLMUUUuc bQ0g== X-Gm-Message-State: AC+VfDzWwuKHd9Hh/wrd86x8I5o6Wv7eTWN4A2jdfjSvqBYg4TuuTbo6 l56qC6JQygkQGs1TXtnaE2gGF6iFo9sp X-Google-Smtp-Source: ACHHUZ5Y5u5GfQO+v2V+aKXbBLuLyabzsHyJ7UAvFYKMG8567omcANkCFynE5ebfsRhLLEDD5CY9TnAS+MCL X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a25:e08b:0:b0:bad:939:77b9 with SMTP id x133-20020a25e08b000000b00bad093977b9mr1193175ybg.3.1685138070105; Fri, 26 May 2023 14:54:30 -0700 (PDT) Date: Fri, 26 May 2023 14:53:42 -0700 In-Reply-To: <20230526215410.2435674-1-irogers@google.com> Message-Id: <20230526215410.2435674-8-irogers@google.com> Mime-Version: 1.0 References: <20230526215410.2435674-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v4 07/35] perf evsel: Add is_pmu_core inorder to interpret own_cpus From: Ian Rogers To: Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , James Clark , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kajol Jain , Jing Zhang , Kan Liang , Zhengjun Xing , Ravi Bangoria , Madhavan Srinivasan , Athira Rajeev , Ming Wang , Huacai Chen , Sandipan Das , Dmitrii Dolgov <9erthalion6@gmail.com>, Sean Christopherson , Ali Saidi , Rob Herring , Thomas Richter , Kang Minchul , linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The behaviour of handling cpu maps varies for core and other PMUs. For core PMUs the cpu map lists all valid CPUs, whereas for other PMUs the map is the default CPU. Add a flag in the evsel to indicate if a PMU is core to help with later interpreting of the cpu maps and populate it when the evsel is created during parsing. When propagating cpu maps, core PMUs should intersect the cpu map of the PMU with the user requested one. Signed-off-by: Ian Rogers Reviewed-by: Kan Liang --- tools/lib/perf/include/internal/evsel.h | 9 +++++++++ tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c | 1 + 3 files changed, 11 insertions(+) diff --git a/tools/lib/perf/include/internal/evsel.h b/tools/lib/perf/inclu= de/internal/evsel.h index a99a75d9e78f..4d6f2a032f45 100644 --- a/tools/lib/perf/include/internal/evsel.h +++ b/tools/lib/perf/include/internal/evsel.h @@ -41,7 +41,14 @@ struct perf_sample_id { struct perf_evsel { struct list_head node; struct perf_event_attr attr; + /** The commonly used cpu map of CPUs the event should be opened upon, et= c. */ struct perf_cpu_map *cpus; + /** + * The cpu map read from the PMU. For core PMUs this is the list of all + * CPUs the event can be opened upon. For other PMUs this is the default + * cpu map for opening the event on, for example, the first CPU on a + * socket for an uncore event. + */ struct perf_cpu_map *own_cpus; struct perf_thread_map *threads; struct xyarray *fd; @@ -65,6 +72,8 @@ struct perf_evsel { * i.e. it cannot be the 'any CPU' value of -1. */ bool requires_cpu; + /** Is the PMU for the event a core one? Effects the handling of own_cpus= . */ + bool is_pmu_core; int idx; }; =20 diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 2f5910b31fa9..8c8f371ea2b5 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -415,6 +415,7 @@ struct evsel *evsel__clone(struct evsel *orig) evsel->core.nr_members =3D orig->core.nr_members; evsel->core.system_wide =3D orig->core.system_wide; evsel->core.requires_cpu =3D orig->core.requires_cpu; + evsel->core.is_pmu_core =3D orig->core.is_pmu_core; =20 if (orig->name) { evsel->name =3D strdup(orig->name); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index b93264f8a37c..1a0be395c887 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -260,6 +260,7 @@ __add_event(struct list_head *list, int *idx, evsel->core.cpus =3D cpus; evsel->core.own_cpus =3D perf_cpu_map__get(cpus); evsel->core.requires_cpu =3D pmu ? pmu->is_uncore : false; + evsel->core.is_pmu_core =3D pmu ? pmu->is_core : false; evsel->auto_merge_stats =3D auto_merge_stats; evsel->pmu =3D pmu; evsel->pmu_name =3D pmu && pmu->name ? strdup(pmu->name) : NULL; --=20 2.41.0.rc0.172.g3f132b7071-goog