[PATCH] perf intel-pt: Save the reference window used to detect snapshot wraps
From: lirongqing
Date: Mon Nov 16 2026 - 04:27:10 EST
From: Li RongQing <lirongqing@xxxxxxxxx>
The snapshot reference offset is initialized to the end of the AUX
buffer and does not change. The comparison checks that fixed window,
but the reference update copies bytes immediately before the current
head instead.
Two snapshots before the trace reaches the buffer end can consequently
compare trace bytes against an untouched tail and falsely report a wrap.
The reader then treats the buffer as full and emits stale or unwritten
bytes in addition to the new trace.
Copy the window ending at ref_offset plus its size, matching the window
used by the comparison.
Fixes: 90e457f7be08 ("perf tools: Add Intel PT support")
Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>
---
tools/perf/arch/x86/util/intel-pt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index a533114..5e38b9c 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -1091,7 +1091,7 @@ static bool intel_pt_wrapped(struct intel_pt_recording *ptr, int idx,
data, head);
intel_pt_copy_ref(ref->ref_buf, ptr->snapshot_ref_buf_size, mm->len,
- data, head);
+ data, ref->ref_offset + ptr->snapshot_ref_buf_size);
return wrapped;
}
--
2.9.4