On Tue, Oct 19, 2021 at 06:34:24PM +0100, German Gomez wrote:
Hi Leo,
On 17/10/2021 13:05, Leo Yan wrote:
On Thu, Sep 16, 2021 at 04:46:34PM +0100, German Gomez wrote:
[...]
If run a test case (the test is pasted at the end of the reply), I can get quite different AUX trace data with passing different wait period before sending the first USR2 signal.
# sh test_arm_spe_snapshot.sh 2 Couldn't synthesize bpf events. stress: info: [5768] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 2.833 MB perf.data ]
# sh test_arm_spe_snapshot.sh 10 Couldn't synthesize bpf events. stress: info: [5776] dispatching hogs: 1 cpu, 0 io, 0 vm, 0 hdd [ perf record: Woken up 3 times to write data ] [ perf record: Captured and wrote 24.356 MB perf.data ]
The first command passes argument '2' so the test will wait for 2 seconds before send USR2 signal for snapshot, and the perf data file is 2.833 MB (so this means the Arm SPE trace data is about 2MB) for three snapshots. In the second command, the argument '10' means it will wait for 10 seconds before sending the USR2 signals, and every time it records the trace data from the full AUX buffer (8MB), at the end it gets 24MB AUX trace data.
The issue happens in the second command, waiting for 10 seconds leads to the *full* AUX ring buffer is filled by Arm SPE, so the function arm_spe_buffer_has_wrapped() always return back true for this case. Afterwards, arm_spe_find_snapshot() doesn't respect the passed old header (from '*old') and assumes the trace data size is 'mm->len'.
Returning the entire contents of the buffer once the first wrap-around was detected was the intention of the patch, so I don't currently see it as wrong. What were the values you were expecting to see in the test?
I expect the second command takes three snapshots: the first time it should record AUX trace data with full buffer size (8MB) after waiting for 10 seconds, and later two times will take small AUX trace data since the interval (0.03s) is short and Arm SPE has not filled the full AUX buffer.
If the handling of snapshot mode by the perf tool can be improved after upstreaming the changes to the driver, we could submit a followup patch after that has been fixed.
Okay, I understand now the main concern is for kernel driver changes, this patch for perf tool is fine for me:
Reviewed-by: Leo Yan leo.yan@linaro.org Tested-by: Leo Yan leo.yan@linaro.org
[...]
I will try these and the other driver changes and discuss them with the team internally, thanks!
Thanks a lot!