[PATCH 1/2] perf: arm_spe: Order padding before publishing AUX head

Leo Yan leo.yan at arm.com
Thu Oct 15 08:51:58 PDT 2026


The driver fills alignment gaps and calls perf_aux_output_skip(), which
publishes the new aux_head without a memory barrier. A userspace
consumer on another CPU can therefore observe the new head before the
padding stores become visible.

Add smp_wmb() between the padding stores and perf_aux_output_skip().

Fixes: d5d9696b0380 ("drivers/perf: Add support for ARMv8.2 Statistical Profiling Extension")
Assisted-by: LLM
Signed-off-by: Leo Yan <leo.yan at arm.com>
---
 drivers/perf/arm_spe_pmu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index b70f3fedf0282baba1395ce1116272ec5f961ea8..e105462ec5f38eab4776b0a654ba7c8a84f70f71 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -487,8 +487,11 @@ static void arm_spe_pmu_pad_buf(struct perf_output_handle *handle, int len)
 	u64 head = PERF_IDX2OFF(handle->head, buf);
 
 	memset(buf->base + head, ARM_SPE_BUF_PAD_BYTE, len);
-	if (!buf->snapshot)
+	if (!buf->snapshot) {
+		/* Order the padding stores before publishing the new aux_head. */
+		smp_wmb();
 		perf_aux_output_skip(handle, len);
+	}
 }
 
 static u64 arm_spe_pmu_next_snapshot_off(struct perf_output_handle *handle)

-- 
2.34.1




More information about the linux-arm-kernel mailing list