On 24/11/2026 20:41, Adrian Hunter wrote:
On 05/11/2026 13:45, James Clark wrote:
find_snapshot() isn't implemented for Coresight, so when a wrap occurs we only save from offset 0 to current head, modulo buffer size, rather than capturing the whole buffer. Coresight drivers currently use a monotonic head pointer even in snapshot mode, which gives a lot more information for taking snapshots than a wrapped pointer. It means we don't need to search for data at the end of the buffer to guess if a wrap has occurred, and we can go back to saving partial buffers after a wrap by checking if the next size to take is less than the buffer size.
The drivers will always be able to generate a monotonic head because TRBE has a bytes written counter, so even if we stop generating an AUX record on every overflow, we can check if the counter indicated an overwrite and offset head by a whole buffer size if it wrapped. This forces userspace to read the whole buffer rather than between last and current head. ETR and other sinks use software double buffering, so can continue as they are.
Add auxtrace_record__monotonic_find_snapshot() and use it for Coresight. A monotonic head can't be auto-detected in the default find_snapshot() by checking if head > buffer size, because before the first wrap a monotonic head looks the same as a wrapped one. The search would then falsely detect a wrap when head is near the end of the buffer, and the wrapped pointer fixup moves 'old' and 'head' a whole buffer ahead of the driver's head. With a wrapped head that doesn't matter because only the offset within the buffer is used, but with a monotonic head the next snapshot would either save already saved data again or drop up to a buffer's worth of new data.
Reviewed-by: Leo Yan leo.yan@arm.com Tested-by: Leo Yan leo.yan@arm.com Signed-off-by: James Clark james.clark@linaro.org
Reviewed-by: Adrian Hunter adrian.hunter@intel.com
Thanks!