[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251015-arm_spe_fix_truncated_flag-v1-1-555e328cba05@arm.com>
Date: Wed, 15 Oct 2025 19:23:37 +0100
From: Leo Yan <leo.yan@....com>
To: Will Deacon <will@...nel.org>, Mark Rutland <mark.rutland@....com>,
Alexandru Elisei <alexandru.elisei@....com>,
James Clark <james.clark@...aro.org>
Cc: linux-arm-kernel@...ts.infradead.org, linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org, Leo Yan <leo.yan@....com>
Subject: [PATCH] perf: arm_spe: Ensure trace is disabled when TRUNCATED
flag is set
The TRUNCATED flag can be set in the following cases:
1. When data loss is detected (PMBSR_EL1.DL == 0b1).
2. When arm_spe_perf_aux_output_begin() fails to find a valid limit
because it runs out of free space.
Currently, only the first case invokes irq_work_run() to execute the
event disable callback, while the second case does not.
Move the call to irq_work_run() later with checking the TRUNCATED flag,
so that both cases are handled and redundant calls are avoided.
Signed-off-by: Leo Yan <leo.yan@....com>
---
drivers/perf/arm_spe_pmu.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index fa50645feddadbea5dc1e404f80f62cf5aa96fd4..05ba977f75d607a1d524f68694db9ea18a6ef20c 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -731,12 +731,6 @@ static irqreturn_t arm_spe_pmu_irq_handler(int irq, void *dev)
if (act == SPE_PMU_BUF_FAULT_ACT_SPURIOUS)
return IRQ_NONE;
- /*
- * Ensure perf callbacks have completed, which may disable the
- * profiling buffer in response to a TRUNCATION flag.
- */
- irq_work_run();
-
switch (act) {
case SPE_PMU_BUF_FAULT_ACT_FATAL:
/*
@@ -765,6 +759,15 @@ static irqreturn_t arm_spe_pmu_irq_handler(int irq, void *dev)
break;
}
+ /*
+ * The TRUNCATED flag is set when data loss is detected by PMBSR_EL1.DL,
+ * or arm_spe_perf_aux_output_begin() sets the flag if runs out of free
+ * space. Ensure that all perf callbacks have completed for disabling
+ * the profiling buffer.
+ */
+ if (handle->aux_flags & PERF_AUX_FLAG_TRUNCATED)
+ irq_work_run();
+
/* The buffer pointers are now sane, so resume profiling. */
write_sysreg_s(0, SYS_PMBSR_EL1);
return IRQ_HANDLED;
---
base-commit: 1f4a222b0e334540343fbb5d3eac4584a6bfe180
change-id: 20251015-arm_spe_fix_truncated_flag-1a5b3620a3ab
Best regards,
--
Leo Yan <leo.yan@....com>
Powered by blists - more mailing lists