[PATCH v5 11/11] alpha/perf: sample only retired instructions for precise events
From: Matt Turner
Date: Tue Nov 03 2026 - 15:40:30 EST
ProfileMe samples include instructions killed on a wrong path, which
show up as hot spots in perf report although they did no work. On an
EV7 loop with a randomly mispredicted branch, 19% of the samples were
killed before being mapped and another 48% later.
PEBS and AMD IBS op samples are of retired instructions only, so make
precise_ip imply the retired filter, unless filters are given. The
profileme bit still selects every sample. With cycles:p, both kinds of
killed sample went to 0%.
DTB miss samples, whose instruction is aborted, are then dropped too:
their data source now needs cpu/cycles,trapped/p.
Suggested-by: Ian Rogers <irogers@xxxxxxxxxx>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matt Turner <mattst88@xxxxxxxxx>
---
arch/alpha/kernel/perf_event.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/alpha/kernel/perf_event.c b/arch/alpha/kernel/perf_event.c
index bed671fe726d..c108b5488a50 100644
--- a/arch/alpha/kernel/perf_event.c
+++ b/arch/alpha/kernel/perf_event.c
@@ -825,6 +825,11 @@ static int __hw_perf_event_init(struct perf_event *event)
if (attr->config1 && !profileme)
return -EINVAL;
hwc->config = attr->config1;
+ /* As with PEBS, precise samples are of retired instructions. */
+ if (attr->precise_ip && !attr->config1 &&
+ !(attr->type == PERF_TYPE_RAW &&
+ (attr->config & ALPHA_PERF_CONFIG_PROFILEME)))
+ hwc->config = ALPHA_PERF_CONFIG1_RETIRED;
if (attr->type == PERF_TYPE_RAW &&
(attr->config & ALPHA_PERF_CONFIG_RANDOMIZE)) {
--
2.55.0