From mboxrd@z Thu Jan 1 00:00:00 1970 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 7ED96C77B73 for ; Sat, 27 May 2023 07:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbjE0HXD (ORCPT ); Sat, 27 May 2023 03:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231583AbjE0HWt (ORCPT ); Sat, 27 May 2023 03:22:49 -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 95BB8E44 for ; Sat, 27 May 2023 00:22:47 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-5654c7f991bso38098527b3.3 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=JMmUsRSSbrtXg6SR+TrDLxgn7RRyd45qHzoLPL9fyal1OrbGOKhVdqjryAPUKOe3Rt FSW7c3tuAfcPaKk1tSm+TF6v0QnqijQdDn88JHKALWqLHl9v0XNeUyuJY7SB6HW5MqGn m0JqEViz8zeJd/mylCd/+6qJy7IJKXZeSivW/Pd9wJ5dXBFz5P5kfG0zyf94LHWe9bOm eg1BS0fFfQ4Sw4c89tuV8+VWmZ9bcYmjRxCnWoxXFv6nsETJRQBFPFzNMEkSfADUw6RX nj/DTnuNDTdHg5pLQ364p4rJJ+zLzFFJKhSxrzhhNGcQksLbFDqyRuW9G8YruwIOixaN 6sXg== X-Gm-Message-State: AC+VfDzYoZ4usqhXVqN7OZSmJobgYPZsa73Yz1XUOMe/oFosDjFEd/CI IBecCvbQ4AMSE5ytIXqNU+WqmZS/HQ+F X-Google-Smtp-Source: ACHHUZ64hXEe1Ke8DjqNWXMRsC15N8MX9tNVXda0lKECLIb7tEG39y0EQBt9RQD2u66EgzLH4R+0A9dG6tp/ 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" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@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