From patchwork Tue Aug 13 13:23:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13762135 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 88795C52D7C for ; Tue, 13 Aug 2024 14:30:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r+kJ+/NC06vZ9X8R6p8mtg0vV2q4/5EH3hEIt7Tb/aw=; b=WuVA287TJVC6uXNKWgd2S6ZQyp tsGOuj9KWxzaYo09dHnCC53Q8L6wKM7m+u4R0/DVDxpGpPmcx7howhH1022Ld3Il2a6RvuVOn2igS fxHdtLpTfNJRfxLod4JUXmKjo9j+MagpWUzrnBBfJdqW+sdZDLW8U4XkUxjPQettC1BhT/T+ABwrc w0gGUb2WqOyU2NIqoR9A89t9tV/x4eDAmGe8UWgRQOVDPlIGcWJWHqwhs4lYLVUMIWCYPMN9SCAxh +UhBAmslhV+yOStV0KYi4p8BsXX1Vf5UradiqCOeBpipZ9lmJVaYxJ4UVwS7g8yga2G8jw0ucmvdL UaBarWmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdsXi-000000041Rj-30SX; Tue, 13 Aug 2024 14:30:34 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdrWU-00000003rFA-2FKw for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 13:25:15 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so2496532f8f.3 for ; Tue, 13 Aug 2024 06:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723555512; x=1724160312; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r+kJ+/NC06vZ9X8R6p8mtg0vV2q4/5EH3hEIt7Tb/aw=; b=Ghqbwc5fHlC/821+HmSx3sIL4LherlJtjTwmCuW6ggsuKiVTMBqz3RZgqTN96gbnpu c+Eti6YcgKjW9f1OSg/whBRT1TlUd4kR+LY1zXPERCDGrbRK2oEziJ2VFJ+4jZE8VnXF X8F2hpT0cs+YSJDITfAQPSjMl8oFitdiYNpk0x+DVMRYYn0eh2JfP5b6T+qrZc2F07RD wPw1mb6Fl92rZxkkVUzeLpAS4WxK7sn+Ln9h7nZpHQUgjLo2FlUxd20i6a9GFk2sg8JJ VUS3nUUQEs3IO38Y9pXc5kSV3ZKzTQt1vt2OYoILzWJOiZfDr0fsZ6krB14o6kdJWd7J Qaqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723555512; x=1724160312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r+kJ+/NC06vZ9X8R6p8mtg0vV2q4/5EH3hEIt7Tb/aw=; b=DeJQLy+ex28HUBnU+5JX10YJ8ZFJLiDPFtieNWYiWPUJsHIZjxKAZeyEMkkoOzQ99v PYMeIfRD7KXIqG9AlFvI4pf1YkrJJQrLdWpebzB/g3mIcsZFxE6Hr8jR/axn5HRqW/mg 1LVGGvczYyw4TgKXOD9yxsu0sunqXSdagbPh2mALApQZ5U2og2Evq2wvfGeBMCb8OGRv +Fl94Uvg61JebFGU0e3Q4SEUokhdoi5e5qSEvzoPIxKxReq6jlmVxiDRzy4S5ea14rIf wyaPXC4cdNDKvdoUeB+MEy/kiVp2T/C+Bsc+7Hal6N8HJqts1DMB+NjWf+APhjaiQVWV fc6A== X-Forwarded-Encrypted: i=1; AJvYcCXcpqzFHH5mueiAStHKYVz+VuzbbRz46+NDJY91eTTWNYtwDSVux7bnxdo2fFwO1zaklmjtWcNSlmHdkHOLCKoRYn/lGEiNWIiU7OWlfe85NeHWQJc= X-Gm-Message-State: AOJu0YwzsntI6KdPZCA59ew9TktwssHyMdqYh58xRlv8DJPAEHs3MsZi cHed7woTYPAxP4sTK7omQl0ZqJset4IGG6zJpP3SPLRJ9dxIxTlPHlbahePyb7Y= X-Google-Smtp-Source: AGHT+IGjXdWWrJsG8ue7FAAFzotqCer/0Jr9WoBguXbU5v52cPPA7AkQerMal8MjToQlhspx2O6d6Q== X-Received: by 2002:adf:8b1e:0:b0:367:992f:4ac4 with SMTP id ffacd0b85a97d-3716cc542a0mr2499815f8f.0.1723555511781; Tue, 13 Aug 2024 06:25:11 -0700 (PDT) Received: from localhost.localdomain ([89.47.253.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4290c738d21sm223186625e9.12.2024.08.13.06.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 06:25:11 -0700 (PDT) From: James Clark To: irogers@google.com, linux-perf-users@vger.kernel.org Cc: James Clark , John Garry , Will Deacon , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , Dominique Martinet , Yang Jihong , Ze Gao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] perf evsel: Use the same arch_evsel__hw_name() on arm64 as x86 Date: Tue, 13 Aug 2024 14:23:11 +0100 Message-Id: <20240813132323.98728-4-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813132323.98728-1-james.clark@linaro.org> References: <20240813132323.98728-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240813_062514_611949_758ACDAF X-CRM114-Status: GOOD ( 21.38 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Both of these platforms share the same extended type ID mechanism, so share the implementation of the evsel name lookup. Signed-off-by: James Clark --- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/evsel.c | 7 +++++++ tools/perf/arch/x86/util/evsel.c | 17 +---------------- tools/perf/util/evsel.c | 24 ++++++++++++++++++++++++ tools/perf/util/evsel.h | 2 +- 5 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 tools/perf/arch/arm64/util/evsel.c diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index 343ef7589a77..45c77f747d54 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,3 +1,4 @@ +perf-util-y += evsel.o perf-util-y += header.o perf-util-y += machine.o perf-util-y += perf_regs.o diff --git a/tools/perf/arch/arm64/util/evsel.c b/tools/perf/arch/arm64/util/evsel.c new file mode 100644 index 000000000000..6974f72ee37f --- /dev/null +++ b/tools/perf/arch/arm64/util/evsel.c @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "util/evsel.h" + +int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) +{ + return evsel__hw_name_ext_type_id(evsel, bf, size); +} diff --git a/tools/perf/arch/x86/util/evsel.c b/tools/perf/arch/x86/util/evsel.c index 090d0f371891..771b35fef61a 100644 --- a/tools/perf/arch/x86/util/evsel.c +++ b/tools/perf/arch/x86/util/evsel.c @@ -49,22 +49,7 @@ bool arch_evsel__must_be_in_group(const struct evsel *evsel) int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) { - u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK; - u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT; - const char *event_name; - - if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event]) - event_name = evsel__hw_names[event]; - else - event_name = "unknown-hardware"; - - /* The PMU type is not required for the non-hybrid platform. */ - if (!pmu) - return scnprintf(bf, size, "%s", event_name); - - return scnprintf(bf, size, "%s/%s/", - evsel->pmu_name ? evsel->pmu_name : "cpu", - event_name); + return evsel__hw_name_ext_type_id(evsel, bf, size); } static void ibs_l3miss_warn(void) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index bc603193c477..19f4d0e71733 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -584,6 +584,30 @@ int __weak arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size) return scnprintf(bf, size, "%s", __evsel__hw_name(evsel->core.attr.config)); } +/* + * Version of evsel__hw_name() used on platforms where perf_pmus__supports_extended_type() + * may be true and the type needs to be extracted and masked. + */ +int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size) +{ + u64 event = evsel->core.attr.config & PERF_HW_EVENT_MASK; + u64 pmu = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT; + const char *event_name; + + if (event < PERF_COUNT_HW_MAX && evsel__hw_names[event]) + event_name = evsel__hw_names[event]; + else + event_name = "unknown-hardware"; + + /* The PMU type is not required for the non-hybrid platform. */ + if (!pmu) + return scnprintf(bf, size, "%s", event_name); + + return scnprintf(bf, size, "%s/%s/", + evsel->pmu_name ? evsel->pmu_name : "cpu", + event_name); +} + static int evsel__hw_name(struct evsel *evsel, char *bf, size_t size) { int r = arch_evsel__hw_name(evsel, bf, size); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 80b5f6dd868e..f95fc2919462 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -299,7 +299,7 @@ extern const char *const evsel__sw_names[PERF_COUNT_SW_MAX]; extern char *evsel__bpf_counter_events; bool evsel__match_bpf_counter_events(const char *name); int arch_evsel__hw_name(struct evsel *evsel, char *bf, size_t size); - +int evsel__hw_name_ext_type_id(struct evsel *evsel, char *bf, size_t size); int __evsel__hw_cache_type_op_res_name(u8 type, u8 op, u8 result, char *bf, size_t size); const char *evsel__name(struct evsel *evsel); bool evsel__name_is(struct evsel *evsel, const char *name);