Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp479852rwd; Sat, 27 May 2023 00:45:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GBcNIAuKHouoNHTaBiOGnCY4HcDUdxY5MMRIMH2tWACZiWPGJtcAMcrTWGXMsoBqtuvkI X-Received: by 2002:a05:6a20:440d:b0:10b:f590:5a1f with SMTP id ce13-20020a056a20440d00b0010bf5905a1fmr3077113pzb.0.1685173554748; Sat, 27 May 2023 00:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685173554; cv=none; d=google.com; s=arc-20160816; b=ooelo68UCA7LhrgLHtZaVWqnQiv1xbyh+TcBHcXY/EE/XIFsf2o/1Ctar5D9QfaktN +FKG0YH+aT4UJdcuXNftfIvb/97G1NKEIDjjE449sx20LuIAUapYAV/qDB3VusIaRB77 wnFoC05S260igJt0LNO4p6EjdcCb14EIGuMm88XUmYk/6lAl5hocVoEflvdfsyO6nX4e 2Cz/hN3GPq0ap9dDLwcP3pz99ryAelZdyqZDmt8WCmF0rJCl6PAP6pFmz/QJ/4GKpUI0 UAnUrA7Ho/zkl9v2039UaF+SZSR1Ajl0ZYkPd5UEeBwntygPnOvhvYcfwDN6i4rJKrew QTYQ== 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=sTjkcSrIthqBGUF6JyF++nlWwrpLfc1jVqkJtlkt6PQ=; b=oc53EPaiMmRmmAuYqwb0rtGU3aiorGstvl397u//zuuyy9L7xLoN3oUu9Lrb4EjaBF Yoaj+zf1VAodPnJfILetrLBD5+6mG3JdQi1Ed3ZoEkF6QwKS034HPEi+N4PNgc4TNrz+ KTptdqfm6MqXbuHGaqU2VtOBjEqEBmmLScExwB3quUbHK7k1VT41/jwWC9IY66lfmeMr o8vHChz5FyDm2zrOieOW25cgqHiac847uKOispCUoNIMEwRdChHi9hSCR70j8+1PRqpG BKz72x8DfI+we5dlNGRDTsZNFZieqQYfDTWqDFfjdR6jt/0o6mZQg4UfL+8yDQERxlii MWAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=vkjgchpo; 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 k186-20020a6384c3000000b00503059b8b2fsi5875280pgd.220.2023.05.27.00.45.40; Sat, 27 May 2023 00:45:54 -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=vkjgchpo; 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 S229708AbjE0HXF (ORCPT + 99 others); Sat, 27 May 2023 03:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231637AbjE0HWu (ORCPT ); Sat, 27 May 2023 03:22:50 -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 95CD6E45 for ; Sat, 27 May 2023 00:22:47 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5655d99d636so38048397b3.2 for ; Sat, 27 May 2023 00:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685172167; x=1687764167; 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=vkjgchpoH1XPedYIO6/vqF6XE45h/j6eAlFw9kO2YrsTfetys0yIqgYnaYGjje04b5 UwmnJj+BTaYBeWo/k9KnBbMQp/uHUkF2mxlieD1NpTK6lkq/TNvCF9K6uMh14yp6FqF5 7sKN1m8k/ZuqlnMfWC1kW0zjDazuJKoaawuPxxR4RGIM1o75Q458EI2HwPtuXFGq5r40 +meevMGdIBn1ybeDSbALYZ2S2WGHwqheC1Ld9msieGFdT20QVYzIuZGkYwg5XPDypoxk 7V3b4m1qXojw6WKgdgV5oILZ+DV7b2gRO6Mr2tmbY5y+mZYh6Hn9oZ/0mTsNdjKD9DRS Sjbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685172167; x=1687764167; 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=Y8Nhnf+sTJup5Q6I01rhHAzIZx7Ayxm8PPyyVa0eEKbP5C0GQKWSZO7KAFOA89g8Gr V+XToDtu5Kg9PVwZrVFZibVnziO3j7ggMI6LO76pAvcpXJgTj6Hh52+0a0oKCyPCvDNZ EV7B97WT7zxXBegOMNsQxc9jrPceeXsQ3E4rgfEPmbNE6/lVx1x6cm9GQdDbiZUQjgZq KFDdN/ngIv8073NYuzBRLxhyK36bhmoJIwPDCIUJ5DaxaO0wuXJEXls/TPK/uHX2DnOZ IXubD1gOMnYLeeVnehJjOM63bydRnsi3H6pkUA7uRWBZ7LApfMCTQPNk6mUFpcimPG74 EUSQ== X-Gm-Message-State: AC+VfDxzSducDSFMT0FM4N8xDVpD3qn+upqx+RVgbRS5flSjDWRNQeDf WDHrVIOnm/1RmiEWH5KafuzvMuiBRRfZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:3b4e:312c:644:a642]) (user=irogers job=sendgmr) by 2002:a05:690c:727:b0:565:a43e:23c7 with SMTP id bt7-20020a05690c072700b00565a43e23c7mr2467918ywb.0.1685172166863; Sat, 27 May 2023 00:22:46 -0700 (PDT) Date: Sat, 27 May 2023 00:21:42 -0700 In-Reply-To: <20230527072210.2900565-1-irogers@google.com> Message-Id: <20230527072210.2900565-7-irogers@google.com> Mime-Version: 1.0 References: <20230527072210.2900565-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Subject: [PATCH v5 06/34] 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=unavailable 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 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/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.41.0.rc0.172.g3f132b7071-goog