* [PATCH] perf intel-pt: Save the reference window used to detect snapshot wraps
@ 2026-11-16 9:26 lirongqing
2026-12-04 12:47 ` Adrian Hunter
0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-11-16 9:26 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, James Clark, Li RongQing,
linux-perf-users, linux-kernel
From: Li RongQing <lirongqing@baidu.com>
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@baidu.com>
---
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] perf intel-pt: Save the reference window used to detect snapshot wraps
2026-11-16 9:26 [PATCH] perf intel-pt: Save the reference window used to detect snapshot wraps lirongqing
@ 2026-12-04 12:47 ` Adrian Hunter
0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2026-12-04 12:47 UTC (permalink / raw)
To: lirongqing, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, James Clark,
linux-perf-users, linux-kernel
On 16/11/2026 11:26, lirongqing wrote:
> From: Li RongQing <lirongqing@baidu.com>
>
> 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@baidu.com>
> ---
> 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);
'head' is correct. The problem seems to be that ref_offset
needs to be moved to match i.e.
ref->ref_offset = (head + mm->len - ptr->snapshot_ref_buf_size) % mm->len;
Does that work?
>
> return wrapped;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 12:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 9:26 [PATCH] perf intel-pt: Save the reference window used to detect snapshot wraps lirongqing
2026-12-04 12:47 ` Adrian Hunter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®