From: Adrian Hunter <adrian.hunter@intel.com>
To: lirongqing <lirongqing@baidu.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
James Clark <james.clark@linaro.org>,
<linux-perf-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf intel-pt: Save the reference window used to detect snapshot wraps
Date: Fri, 4 Dec 2026 14:47:05 +0200 [thread overview]
Message-ID: <2320f3f7-9da8-4f6f-8141-b54b235ca315@intel.com> (raw)
In-Reply-To: <20261116092650.1714-1-lirongqing@baidu.com>
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;
> }
prev parent reply other threads:[~2026-12-04 12:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:26 lirongqing
2026-12-04 12:47 ` Adrian Hunter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2320f3f7-9da8-4f6f-8141-b54b235ca315@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®