The kernel defaults to a watermark of half the AUX buffer. With small buffers, the reader can be notified too late to drain the trace before the available space is exhausted.
Use a quarter-buffer watermark for normal recording to wake the reader earlier and leave more space for trace generated while it handles the notification.
If the computed watermark is at most one page, set it to zero so the kernel selects its default. TRBE's write-out-of-range workaround requires PAGE_SIZE + 64 bytes per trace span and disables trigger counts. A one-page watermark can leave every span too small to enable tracing. The fallback retains a two-page watermark for a four-page AUX mapping.
Leave snapshot and AUX sampling behavior unchanged.
Signed-off-by: Leo Yan leo.yan@arm.com --- tools/perf/arch/arm/util/cs-etm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index d2861d66a6612ea213066258672ba41769e578cb..2b29cd5fde4b8cc18e04d02308635d7b0c13ccf6 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -438,6 +438,21 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, pr_debug2("%s snapshot size: %zu\n", CORESIGHT_ETM_PMU_NAME, opts->auxtrace_snapshot_size);
+ if (!opts->auxtrace_snapshot_mode && !opts->auxtrace_sample_mode) { + size_t aw = opts->auxtrace_mmap_pages * (size_t)page_size / 4; + u32 aux_watermark = aw > UINT_MAX ? UINT_MAX : aw; + + /* + * TRBE workarounds can require more than one page per trace + * span. If the watermark is too small, let the kernel select + * its default. + */ + if (aux_watermark <= page_size) + aux_watermark = 0; + + cs_etm_evsel->core.attr.aux_watermark = aux_watermark; + } + /* * To obtain the auxtrace buffer file descriptor, the auxtrace * event must come first.