OSDN Git Service

perf intel-pt: Use aux_watermark
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Wed, 14 Apr 2021 15:49:55 +0000 (18:49 +0300)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 16 Apr 2021 14:32:39 +0000 (16:32 +0200)
commit874fc35cdd55e2d46161901de43ec58ca2efc5fe
tree9ec7efd4f31680cdb274f59dee013722e933e8e1
parentd68e6799a5c87f415d3bfa0dea49caee28ab00d1
perf intel-pt: Use aux_watermark

Turns out, the default setting of attr.aux_watermark to half of the total
buffer size is not very useful, especially with smaller buffers. The
problem is that, after half of the buffer is filled up, the kernel updates
->aux_head and sets up the next "transaction", while observing that
->aux_tail is still zero (as userspace haven't had the chance to update
it), meaning that the trace will have to stop at the end of this second
"transaction". This means, for example, that the second PERF_RECORD_AUX in
every trace comes with TRUNCATED flag set.

Setting attr.aux_watermark to quarter of the buffer gives enough space for
the ->aux_tail update to be observed and prevents the data loss.

The obligatory before/after showcase:

> # perf_before record -e intel_pt//u -m,8 uname
> Linux
> [ perf record: Woken up 6 times to write data ]
> Warning:
> AUX data lost 4 times out of 10!
>
> [ perf record: Captured and wrote 0.099 MB perf.data ]
> # perf record -e intel_pt//u -m,8 uname
> Linux
> [ perf record: Woken up 4 times to write data ]
> [ perf record: Captured and wrote 0.039 MB perf.data ]

The effect is still visible with large workloads and large buffers,
although less pronounced.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20210414154955.49603-3-alexander.shishkin@linux.intel.com
tools/perf/arch/x86/util/intel-pt.c