Re: [PATCH v2 07/14] perf arm-spe: Use generic snapshot search
From: Leo Yan
Date: Thu Aug 27 2026 - 12:20:42 EST
On Fri, Aug 21, 2026 at 10:49:05AM +0100, James Clark wrote:
[...]
> SPE also had a special fixup case for head pointers greater than the
> buffer length, which is not needed because the SPE driver always wraps
> them, and __auxtrace_mmap__read() handles that anyway. It also didn't
> have the special case for old > head for when the wrap heuristic fails
> but the pointers showed a wrap had happened.
Here mentioned the "special fixup case" is:
if (head >= buffer_size)
return true
If the hardware pointer is exactly the end of buffer, it is a strong
indication for wrapping. So it might be worth adding an explicit
"head == buffer_size" check in the common code.
That said, if always checking the final 512 bytes, this case is very
likely to be detected anyway, so I am not concerned about dropping the
check.
> The other feature lost is that this search only looked from head to the
> end of the buffer, rather than always at the last 512 bytes. This was
> flawed because once head is close to the end, it's likely it could
> contain zero padding from actual SPE data and a wrap would be missed.
> It's better to err on the side of caution and mark as a wrap, rather
> than trying to optimize by limiting the search from head onwards.
Wouldn't this be a trade-off between missing a wrap and reporting a
false positive wrap?
Ignoring head makes the search overlap valid trace data when head is
close to the end of the buffer but has not wrapped yet
(e.g. mm->len - head < 512). That data can then be mistaken as evidence
of a wrap.
For a false positive wrap, [head..mm->len] contains zero data. This
should be fine, as zero data are treated as PAD packets and discarded
during decoding.
I'd suggest adding this info into the commit log, in case later we need
to understand these weird cases. With that:
Reviewed-by: Leo Yan <leo.yan@xxxxxxx>