From patchwork Thu Nov 7 07:16:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13865957 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4356BD5AE6F for ; Thu, 7 Nov 2024 07:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zpux1hxeW8qM1Ui8cdqLbdlB4N3WIFNl+Co4U3zUbxo=; b=YOPx9+8Iu0ZvD8 H/3BY28tSMb5fgntjAKsYN0SkSjr3EYlUryt/CPkLArTq2l0YsOgliR/N5PoylhbWwWm87h68gZkO Lc7gRKw7F+V+sWcx1B99bQa/VIlKthy5pWkEuKoXrlgH+XjNRlJDZCALtNEnj1w/8+HyOoChrPB5E 4+kxf48RqNUeXMjfT1wUjMAGcyZX2j1gykboh4t+9P3Fdfr3vs3TIRE0oK/6zGDb9xFeK533xx3h1 Wsxq3DkGSEXcLFCHJC4+Ru9J65iB0OnhxMW8gapjQhCUfJXrRAhEkdMS1QOAyqvQGAB3mZwet77Wv KNeMvpkIErpqDmqSsPkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8wyS-00000005zjL-2BEX; Thu, 07 Nov 2024 07:30:36 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8wke-00000005wyt-33mj for linux-riscv@lists.infradead.org; Thu, 07 Nov 2024 07:16:22 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6ea7cfb6e0fso14096507b3.0 for ; Wed, 06 Nov 2024 23:16:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730963779; x=1731568579; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Jp6Q6rsYTy2pkFfmFp9hLJ/9ui9ITiVOsHTsdSSP0vY=; b=TMmn2JQlw9NzMgGl+QhfxA/tenhHU9eh0kfRvYojnNCqNtgX35CcXOR1xMjrSlRAE8 5hJmds9meckXF8Gbc6lyhAt1uZOg17PqCFtDttpv1W6nFfyegUOcTzZfuR7MjgLkEghw zqC2NdnMQeKaeXGRNyUiOnO10FMS/dLQXRd8e6Kw1I5Itt38XlfYKzVQt+Qx8ADDm0jA tfOfDTk6txV6S32yC5SXpgXAYCOfEzhNpSlD/nJJWkfSmQ4tiSLtcR+u1NtoSOr3FTwn 6ljoY+qoDnLeKfXguCQAiEzrwgxoAZFcskfB7iLfQHL1CMOWHoW2RkvhqUq0f8gKqHoD mb9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730963779; x=1731568579; 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=Jp6Q6rsYTy2pkFfmFp9hLJ/9ui9ITiVOsHTsdSSP0vY=; b=AoZCXxbCn4GuYwW2OiXsfPgDkCGplW7Ps6JMxkfYk4H85ggpP6VAoUsxulExUAI2wf eaW73K+cj5O7iyn0NQRsEzIHOuhE2gh3Ywr7yn6AZl505HbKe/1KoBeVeWoD+IIohR62 0GG3rx3ALRXIJ81DdCvCmg1CA+TxxqlLZ5T+v17SBDgFKF7fo1wDS5CicUpOXU4jaj3Q ag9YtjqMfd38vp0+ohg9CWMcz9lBSen3ORoVDafThwhlQeMSwFbpnfimY8PP2ppSuFt2 dsI4ILE8iWMRrhmrzRFVXk9o7dlF563QGh7Qa7lGrVqxmdFrOl2a+pNXWzTim67/8c/j zCVg== X-Forwarded-Encrypted: i=1; AJvYcCUUsg8eRQm4eU56sakYgP71n449TuQubKc2wVj+tfybxQKRpnwJqKjxoKmEmTVr6jG5Fy+FnDkohlDo0Q==@lists.infradead.org X-Gm-Message-State: AOJu0Yza/J0NKiTMstLQoMousnNW3JHrUbAcvmWVgQJlHlYjEA8gvCLb tkOKfDc6SC5+kMYIC3ihKotxjH6hbQGZ46P4w82KEoC/LgdILGmD+bnv9IhftLYaYkqxeZtsEc9 HCfjkOQ== X-Google-Smtp-Source: AGHT+IFjJTkBX3Ww5U3GdP9ImzIAFri1PsUtkuPx9cggbPAOvXg0q9D0jMn+HqGO7HRg6a+gW1C87/H1x3x6 X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:acc7:bda:7167:18d8]) (user=irogers job=sendgmr) by 2002:a81:a8c3:0:b0:6e3:d670:f603 with SMTP id 00721157ae682-6e9d8aada53mr4568187b3.3.1730963779222; Wed, 06 Nov 2024 23:16:19 -0800 (PST) Date: Wed, 6 Nov 2024 23:16:00 -0800 In-Reply-To: <20241107071600.9082-1-irogers@google.com> Message-Id: <20241107071600.9082-8-irogers@google.com> Mime-Version: 1.0 References: <20241107071600.9082-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.199.ga7371fff76-goog Subject: [PATCH v1 7/7] perf pmu: Move pmu_metrics_table__find and remove ARM override From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Huacai Chen , Bibo Mao , Athira Rajeev , Ben Zong-You Xie , Alexandre Ghiti , Sandipan Das , Benjamin Gray , Xu Yang , Ravi Bangoria , " =?utf-8?q?Cl=C3=A9ment_Le_Goffic?= " , Yicong Yang , "Masami Hiramatsu (Google)" , Dima Kogan , "Dr. David Alan Gilbert" , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241106_231620_845428_EA9F52FC X-CRM114-Status: GOOD ( 17.37 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Move pmu_metrics_table__find to the jevents.py generated pmu-events.c and remove indirection override for ARM. The movement removes perf_pmu__find_metrics_table that exists to enable the ARM override. The ARM override isn't necessary as just the CPUID, not PMU, is used in the metric table lookup. On non-ARM the CPU argument is just ignored for the CPUID, for ARM -1 is passed so that the CPUID for the first logical CPU is read. Signed-off-by: Ian Rogers --- tools/perf/arch/arm64/util/pmu.c | 20 -------------------- tools/perf/pmu-events/empty-pmu-events.c | 20 ++++---------------- tools/perf/pmu-events/jevents.py | 20 ++++---------------- tools/perf/pmu-events/pmu-events.h | 2 +- tools/perf/util/pmu.c | 5 ----- tools/perf/util/pmu.h | 1 - 6 files changed, 9 insertions(+), 59 deletions(-) diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/pmu.c index a0964b191fcb..895fb0d0610c 100644 --- a/tools/perf/arch/arm64/util/pmu.c +++ b/tools/perf/arch/arm64/util/pmu.c @@ -1,29 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include "../../../util/cpumap.h" -#include "../../../util/header.h" #include "../../../util/pmu.h" #include "../../../util/pmus.h" #include "../../../util/tool_pmu.h" #include -#include - -const struct pmu_metrics_table *pmu_metrics_table__find(void) -{ - struct perf_pmu *pmu; - - /* Metrics aren't currently supported on heterogeneous Arm systems */ - if (perf_pmus__num_core_pmus() > 1) - return NULL; - - /* Doesn't matter which one here because they'll all be the same */ - pmu = perf_pmus__find_core_pmu(); - if (pmu) - return perf_pmu__find_metrics_table(pmu); - - return NULL; -} u64 tool_pmu__cpu_slots_per_cycle(void) { diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-events/empty-pmu-events.c index 2151e8a43f16..1c7a2cfa321f 100644 --- a/tools/perf/pmu-events/empty-pmu-events.c +++ b/tools/perf/pmu-events/empty-pmu-events.c @@ -587,24 +587,12 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) return NULL; } -const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu) +const struct pmu_metrics_table *pmu_metrics_table__find(void) { - const struct pmu_events_map *map = map_for_pmu(pmu); - - if (!map) - return NULL; - - if (!pmu) - return &map->metric_table; - - for (size_t i = 0; i < map->metric_table.num_pmus; i++) { - const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i]; - const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset]; + struct perf_cpu cpu = {-1}; + const struct pmu_events_map *map = map_for_cpu(cpu); - if (pmu__name_match(pmu, pmu_name)) - return &map->metric_table; - } - return NULL; + return map ? &map->metric_table : NULL; } const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 6d6780ca0889..d781a377757a 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -1103,24 +1103,12 @@ const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) return NULL; } -const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu) +const struct pmu_metrics_table *pmu_metrics_table__find(void) { - const struct pmu_events_map *map = map_for_pmu(pmu); - - if (!map) - return NULL; - - if (!pmu) - return &map->metric_table; - - for (size_t i = 0; i < map->metric_table.num_pmus; i++) { - const struct pmu_table_entry *table_pmu = &map->metric_table.pmus[i]; - const char *pmu_name = &big_c_string[table_pmu->pmu_name.offset]; + struct perf_cpu cpu = {-1}; + const struct pmu_events_map *map = map_for_cpu(cpu); - if (pmu__name_match(pmu, pmu_name)) - return &map->metric_table; - } - return NULL; + return map ? &map->metric_table : NULL; } const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid) diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu-events.h index 5435ad92180c..675562e6f770 100644 --- a/tools/perf/pmu-events/pmu-events.h +++ b/tools/perf/pmu-events/pmu-events.h @@ -103,7 +103,7 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, pm void *data); const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu); -const struct pmu_metrics_table *perf_pmu__find_metrics_table(struct perf_pmu *pmu); +const struct pmu_metrics_table *pmu_metrics_table__find(void); const struct pmu_events_table *find_core_events_table(const char *arch, const char *cpuid); const struct pmu_metrics_table *find_core_metrics_table(const char *arch, const char *cpuid); int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data); diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 514cb865f57b..45838651b361 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -818,11 +818,6 @@ static int is_sysfs_pmu_core(const char *name) return file_available(path); } -__weak const struct pmu_metrics_table *pmu_metrics_table__find(void) -{ - return perf_pmu__find_metrics_table(NULL); -} - /** * Return the length of the PMU name not including the suffix for uncore PMUs. * diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index fba3fc608b64..7b3e71194e49 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -260,7 +260,6 @@ void perf_pmu__arch_init(struct perf_pmu *pmu); void pmu_add_cpu_aliases_table(struct perf_pmu *pmu, const struct pmu_events_table *table); -const struct pmu_metrics_table *pmu_metrics_table__find(void); bool pmu_uncore_identifier_match(const char *compat, const char *id); int perf_pmu__convert_scale(const char *scale, char **end, double *sval);