[PATCH] perf: arm_spe: Relax period restriction
Leo Yan
leo.yan at arm.com
Tue May 27 05:18:27 PDT 2025
The minimum interval specified the PMSIDR_EL1.Interval field is a
hardware recommendation. However, this value is set by hardware designer
before the production. It may not accurately reflects actual hardware
limitations, and tools currently have no way to test shorter periods.
This change relaxes the limitation by allowing any non-zero periods.
This gives chance for experimenting smaller periods. Add a warning
for reminding the period is less than recommended threshold.
The downside is that small periods may increase the risk of AUX ring
buffer overruns. When an overrun occurs, the perf core layer will
trigger an irq work to disable the event and wake up the tool in user
space to read the trace data. After the tool finishes reading, it will
re-enable the AUX event.
Signed-off-by: Leo Yan <leo.yan at arm.com>
---
drivers/perf/arm_spe_pmu.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
index 3efed8839a4e..a00229ddfa08 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -309,15 +309,22 @@ static u64 arm_spe_event_to_pmscr(struct perf_event *event)
static void arm_spe_event_sanitise_period(struct perf_event *event)
{
struct arm_spe_pmu *spe_pmu = to_spe_pmu(event->pmu);
+ struct device *dev = &spe_pmu->pdev->dev;
u64 period = event->hw.sample_period;
u64 max_period = PMSIRR_EL1_INTERVAL_MASK;
- if (period < spe_pmu->min_period)
- period = spe_pmu->min_period;
- else if (period > max_period)
+ if (period < spe_pmu->min_period) {
+ /* Period must set to a non-zero value */
+ if (!period)
+ period = 1;
+
+ dev_warn_ratelimited(dev, "Period %llu < %u (recommended minimum interval).\n",
+ period, spe_pmu->min_period);
+ } else if (period > max_period) {
period = max_period;
- else
+ } else {
period &= max_period;
+ }
event->hw.sample_period = period;
}
--
2.34.1
More information about the linux-arm-kernel
mailing list