The perf mmap'ed buffer contains the flag 'cap_user_time_short' and two
extra fields 'time_cycles' and 'time_mask', perf tool needs to know them
for handling the counter wrapping case.
This patch is to reads out the relevant parameters from the head of the
first mmap'ed page and stores into the structure 'perf_tsc_conversion',
if the flag 'cap_user_time_short' has been set, it will firstly
calibrate cycle value for timestamp calculation.
Committer testing:
Before/after:
# perf test tsc
70: Convert perf time to TSC : Ok
#
# perf test -v tsc
70: Convert perf time to TSC :
--- start ---
test child forked, pid 11059
mmap size 528384B
1st event perf time 996384576521 tsc 3850532906613
rdtsc time 996384578455 tsc 3850532913950
2nd event perf time 996384578845 tsc 3850532915428
test child finished with 0
---- end ----
Convert perf time to TSC: Ok
#
Signed-off-by: Leo Yan
Tested-by: Arnaldo Carvalho de Melo
Cc: Adrian Hunter
Cc: Alexander Shishkin
Cc: Andi Kleen
Cc: Gustavo A. R. Silva
Cc: Ian Rogers
Cc: Jiri Olsa
Cc: John Garry
Cc: Kemeng Shi
Cc: Mark Rutland
Cc: Mathieu Poirier
Cc: Namhyung Kim
Cc: Nick Gasson
Cc: Peter Zijlstra
Cc: Remi Bernon
Cc: Stephane Eranian
Cc: Steve Maclean
Cc: Will Deacon
Cc: Zou Wei
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lore.kernel.org/lkml/20200914115311.2201-4-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo