Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp152007rwd; Wed, 24 May 2023 15:50:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+1pm4eM03qrJbRVKHjxAzFNhO++HDRXbVTGyVWpQvKWxO+eU/O8v6v4arwuH3qlak6NRI X-Received: by 2002:a17:903:22c2:b0:1ae:1237:874d with SMTP id y2-20020a17090322c200b001ae1237874dmr21501946plg.69.1684968605233; Wed, 24 May 2023 15:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684968605; cv=none; d=google.com; s=arc-20160816; b=cp7d/fYf2ebnB3+7aOG8mifAboo//bvVmUxNiYlXul1H8ugsxsguYwZJcMlhONgXNL vQhoK2SB3o/l9A+5SksgREnPV4EzSbuYaYal8R5LzGkcIQ66B0Bld5ZbyW/zONY2yMPO jzOT8ZGQNt6oAa1Oicp3fdZHi8qbZklBUlieVrfaZ53CaMhZ8y41peRCgtSI2hqvGMJP FI8kaglcp6e1F5+6CB9ktkD/lk79F5F1wCVtJn6FwBNxrFbIgj5pygT/IJTWFljsgKb0 J2a2/mgzGmUfZyHZ6gJy/4yJ2WNsGbkYCsLBIY8bB1+6qcEFo7RGN0wYKe9LS55ssiAG FHaQ== 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=c2Fu8Hh2fRZjS6aZytO0Djl8Sie1Qlvn6RQorz5XdqQ=; b=ovCiBIR+VhkRRMqdYPrZuJeiestTIJpktCvkD/cQIbBOSFhqo0sD5jJCDX2uR5SPFT n1F+qoHR+TxW/fgXmvzz1hJ5oJ9nt6n95iPof9JYPxVSL5/4wyCfiUx5KNpSU9ehPcFt TBCWtv5KVBj/nq2UkfWoVCW7jBRAVKPVz18JngbX4shnhVoS10Smr57tDTSu0HRDrizT sG3PG5bqbCO3TV8r5U8J1B1lPiT+WlrvPIktuMnsDOTAhms2ana4gyot5i2oZ/sPzPW8 DJTBRQHbYHEBkp//ZhlUjwUwvIhTmOaV1xoMWDxP9CkAR1gm3tU2/kZu6qmkaygOlN3z xwgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Ev8OlsiX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a170902f54100b001ab2431f012si535251plf.423.2023.05.24.15.49.49; Wed, 24 May 2023 15:50:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Ev8OlsiX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237191AbjEXWTV (ORCPT + 99 others); Wed, 24 May 2023 18:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236995AbjEXWS6 (ORCPT ); Wed, 24 May 2023 18:18:58 -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 822F9186 for ; Wed, 24 May 2023 15:18:51 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba8cf175f5bso853454276.0 for ; Wed, 24 May 2023 15:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684966731; x=1687558731; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=c2Fu8Hh2fRZjS6aZytO0Djl8Sie1Qlvn6RQorz5XdqQ=; b=Ev8OlsiXMdtu6FlOgdizkae87AqhWPM7LWi4Pz2YIJ9tsGVdgoW7Efn6yopiotMOXY /RzHMjyEcpMqh8gdAZoPRjXZ6DK/qlv1VuVe7isIGvvOybJCxWYpVXWkuT0FBTT52PEb x/nSvvHn9yhkumGCzrbVeGiuUQkTEcPjobeCv3i94Do/b5elK/+xAjXTZZNXH21uCVcU ginf8tZxLhE6DEWNa218qJT2oxUW+8GRyaMXpm0049KDScJYYQ577V76F5+IfOB80Bxh FTYnYBNxSKwNI+gj8ZnDRrLXuYoxoPnWrBLCVt13zTbkZIJWqRNV5S7FN8BKH5WFOlRR xnKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684966731; x=1687558731; 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=c2Fu8Hh2fRZjS6aZytO0Djl8Sie1Qlvn6RQorz5XdqQ=; b=YMVAePH95TjP+vNoTSmPKYqEovcREufZSu4ed0Nks0dlGdYnS3ENt8mrWfg36rK5T8 X3CFhjsh6GBScdRF/pCMXhT5NB88b/cNUlZCUBbMrULjzoPKLntlIGEO5qNBQ7uItmPM wZM6TjgwKfqFLoLCQrYyq3g53iV5plJejNoOd1EFop0TA3e9+YoCMFbhRDdQY1SXC1Du WN/iNYp8G81+hS6wJMKvfuzFAYKuTd/x7De2GOnUxOFpG/yBrdKRee4U4Cd3gFI9nUR8 +9xU9EuIPd6aZy5q3SgWcXHjEaZpcsG3evQEP92J5ETzwvK7Yg1Q/KtJa6Bpd7lIV92z 6x5A== X-Gm-Message-State: AC+VfDzMhIHNlIVz6N9Ei+aZEWDZNF3i4ekjypoTZP7nD9b1sAtGDlZG RcTh6TgGJ0sSZ3LQZQy9576SSrAuPetF X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:7aa7:3d2d:76ae:8e96]) (user=irogers job=sendgmr) by 2002:a25:6612:0:b0:b94:6989:7fa6 with SMTP id a18-20020a256612000000b00b9469897fa6mr569267ybc.4.1684966731195; Wed, 24 May 2023 15:18:51 -0700 (PDT) Date: Wed, 24 May 2023 15:18:03 -0700 In-Reply-To: <20230524221831.1741381-1-irogers@google.com> Message-Id: <20230524221831.1741381-8-irogers@google.com> Mime-Version: 1.0 References: <20230524221831.1741381-1-irogers@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v3 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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/include/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, etc. */ 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; }; 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 = orig->core.nr_members; evsel->core.system_wide = orig->core.system_wide; evsel->core.requires_cpu = orig->core.requires_cpu; + evsel->core.is_pmu_core = orig->core.is_pmu_core; if (orig->name) { evsel->name = 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 = cpus; evsel->core.own_cpus = perf_cpu_map__get(cpus); evsel->core.requires_cpu = pmu ? pmu->is_uncore : false; + evsel->core.is_pmu_core = pmu ? pmu->is_core : false; evsel->auto_merge_stats = auto_merge_stats; evsel->pmu = pmu; evsel->pmu_name = pmu && pmu->name ? strdup(pmu->name) : NULL; -- 2.40.1.698.g37aff9b760-goog