This patch introduces a PERF_SAMPLE_TAILSIZE flag which allows a size[...]
field attached at the end of a sample. The idea comes from  that,
with tie size at tail of an event, it is possible for user program who
read from the ring buffer parse events backward.
|E6|...| B 8| C 11| D 7|E..|
In this case, from the 'head' pointer provided by kernel, user program
can first see '6' by (*(head - sizeof(u64))), then it can get the start
pointer of record 'E', then it can read size and find start position
of record D, C, B in similar way.
The implementation is easy: adding a PERF_SAMPLE_TAILSIZE flag, makes
perf_output_sample() output size at the end of a sample.
Following things are done for ensure the ring buffer is safe for
- Don't allow two events with different PERF_SAMPLE_TAILSIZE setting
set their output to each other;
- For non-sample events, also output tailsize if required.
This patch has a limitation for perf:
Before reading such ring buffer, perf must ensure all events which may
output to it is already stopped, so the 'head' pointer it get is the
end of the last record.
Signed-off-by: Wang Nan <wangnan0@xxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
Cc: Yunlong Song <yunlong.song@xxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>