From nobody Sun May 10 22:40:32 2026 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 44E9EC433F5 for ; Thu, 21 Apr 2022 16:52:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379393AbiDUQzW (ORCPT ); Thu, 21 Apr 2022 12:55:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357491AbiDUQzQ (ORCPT ); Thu, 21 Apr 2022 12:55:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 894EA49927; Thu, 21 Apr 2022 09:52:24 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3AA961570; Thu, 21 Apr 2022 09:52:24 -0700 (PDT) Received: from ip-10-252-15-9.eu-west-1.compute.internal (unknown [10.252.15.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 57E493F73B; Thu, 21 Apr 2022 09:52:21 -0700 (PDT) From: Timothy Hayes To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: Timothy Hayes , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 1/3] perf: arm-spe: Fix addresses of synthesized SPE events Date: Thu, 21 Apr 2022 17:52:03 +0100 Message-Id: <20220421165205.117662-2-timothy.hayes@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220421165205.117662-1-timothy.hayes@arm.com> References: <20220421165205.117662-1-timothy.hayes@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch corrects a bug whereby synthesized events from SPE samples are missing virtual addresses. Signed-off-by: Timothy Hayes Reviewed-by: Leo Yan --- tools/perf/util/arm-spe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index d2b64e3f588b..151cc38a171c 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1036,7 +1036,7 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) attr.sample_type =3D evsel->core.attr.sample_type & PERF_SAMPLE_MASK; attr.sample_type |=3D PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC | - PERF_SAMPLE_WEIGHT; + PERF_SAMPLE_WEIGHT | PERF_SAMPLE_ADDR; if (spe->timeless_decoding) attr.sample_type &=3D ~(u64)PERF_SAMPLE_TIME; else --=20 2.25.1 From nobody Sun May 10 22:40:32 2026 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 81A17C433FE for ; Thu, 21 Apr 2022 16:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356784AbiDUQzc (ORCPT ); Thu, 21 Apr 2022 12:55:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357961AbiDUQzS (ORCPT ); Thu, 21 Apr 2022 12:55:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1DA0549C82; Thu, 21 Apr 2022 09:52:28 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CAB861576; Thu, 21 Apr 2022 09:52:27 -0700 (PDT) Received: from ip-10-252-15-9.eu-west-1.compute.internal (unknown [10.252.15.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F16203F73B; Thu, 21 Apr 2022 09:52:24 -0700 (PDT) From: Timothy Hayes To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: Timothy Hayes , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 2/3] perf: arm-spe: Fix SPE events with phys addresses Date: Thu, 21 Apr 2022 17:52:04 +0100 Message-Id: <20220421165205.117662-3-timothy.hayes@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220421165205.117662-1-timothy.hayes@arm.com> References: <20220421165205.117662-1-timothy.hayes@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch corrects a bug whereby SPE collection is invoked with pa_enable=3D1 but synthesized events fail to show physical addresses. Signed-off-by: Timothy Hayes Reviewed-by: Leo Yan --- tools/perf/arch/arm64/util/arm-spe.c | 10 ++++++++++ tools/perf/util/arm-spe.c | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/u= til/arm-spe.c index af4d63af8072..e8b577d33e53 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -148,6 +148,7 @@ static int arm_spe_recording_options(struct auxtrace_re= cord *itr, bool privileged =3D perf_event_paranoid_check(-1); struct evsel *tracking_evsel; int err; + u64 bit; =20 sper->evlist =3D evlist; =20 @@ -245,6 +246,15 @@ static int arm_spe_recording_options(struct auxtrace_r= ecord *itr, */ evsel__set_sample_bit(arm_spe_evsel, DATA_SRC); =20 + /* + * The PHYS_ADDR flag does not affect the driver behaviour, it is used to + * inform that the resulting output's SPE samples contain physical addres= ses + * where applicable. + */ + bit =3D perf_pmu__format_bits(&arm_spe_pmu->format, "pa_enable"); + if (arm_spe_evsel->core.attr.config & bit) + evsel__set_sample_bit(arm_spe_evsel, PHYS_ADDR); + /* Add dummy event to keep tracking */ err =3D parse_events(evlist, "dummy:u", NULL); if (err) diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c index 151cc38a171c..1a80151baed9 100644 --- a/tools/perf/util/arm-spe.c +++ b/tools/perf/util/arm-spe.c @@ -1033,7 +1033,8 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf= _session *session) memset(&attr, 0, sizeof(struct perf_event_attr)); attr.size =3D sizeof(struct perf_event_attr); attr.type =3D PERF_TYPE_HARDWARE; - attr.sample_type =3D evsel->core.attr.sample_type & PERF_SAMPLE_MASK; + attr.sample_type =3D evsel->core.attr.sample_type & + (PERF_SAMPLE_MASK | PERF_SAMPLE_PHYS_ADDR); attr.sample_type |=3D PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_PERIOD | PERF_SAMPLE_DATA_SRC | PERF_SAMPLE_WEIGHT | PERF_SAMPLE_ADDR; --=20 2.25.1 From nobody Sun May 10 22:40:32 2026 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 B823CC433EF for ; Thu, 21 Apr 2022 16:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358909AbiDUQzj (ORCPT ); Thu, 21 Apr 2022 12:55:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387208AbiDUQza (ORCPT ); Thu, 21 Apr 2022 12:55:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A94FE49CA0; Thu, 21 Apr 2022 09:52:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66D8C153B; Thu, 21 Apr 2022 09:52:31 -0700 (PDT) Received: from ip-10-252-15-9.eu-west-1.compute.internal (unknown [10.252.15.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8CFBD3F73B; Thu, 21 Apr 2022 09:52:28 -0700 (PDT) From: Timothy Hayes To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org Cc: Timothy Hayes , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 3/3] perf test: Add perf_event_attr test for Arm SPE Date: Thu, 21 Apr 2022 17:52:05 +0100 Message-Id: <20220421165205.117662-4-timothy.hayes@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220421165205.117662-1-timothy.hayes@arm.com> References: <20220421165205.117662-1-timothy.hayes@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Adds a perf_event_attr test for Arm SPE in which the presence of physical addresses are checked when SPE unit is run with pa_enable=3D1. Signed-off-by: Timothy Hayes Reviewed-by: Leo Yan Tested-by: Leo Yan --- tools/perf/tests/attr/README | 1 + .../perf/tests/attr/test-record-spe-physical-address | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 tools/perf/tests/attr/test-record-spe-physical-address diff --git a/tools/perf/tests/attr/README b/tools/perf/tests/attr/README index 454505d343fa..eb3f7d4bb324 100644 --- a/tools/perf/tests/attr/README +++ b/tools/perf/tests/attr/README @@ -60,6 +60,7 @@ Following tests are defined (with perf commands): perf record -R kill (test-record-raw) perf record -c 2 -e arm_spe_0// -- kill (test-record-spe-period) perf record -e arm_spe_0/period=3D3/ -- kill (test-record-spe-period-= term) + perf record -e arm_spe_0/pa_enable=3D1/ -- kill (test-record-spe-physica= l-address) perf stat -e cycles kill (test-stat-basic) perf stat kill (test-stat-default) perf stat -d kill (test-stat-detailed-1) diff --git a/tools/perf/tests/attr/test-record-spe-physical-address b/tools= /perf/tests/attr/test-record-spe-physical-address new file mode 100644 index 000000000000..7ebcf5012ce3 --- /dev/null +++ b/tools/perf/tests/attr/test-record-spe-physical-address @@ -0,0 +1,12 @@ +[config] +command =3D record +args =3D --no-bpf-event -e arm_spe_0/pa_enable=3D1/ -- kill >/dev/null = 2>&1 +ret =3D 1 +arch =3D aarch64 + +[event-10:base-record-spe] +# 622727 is the decimal of IP|TID|TIME|CPU|IDENTIFIER|DATA_SRC|PHYS_ADDR +sample_type=3D622727 + +# dummy event +[event-1:base-record-spe] \ No newline at end of file --=20 2.25.1