arm64: perf: Allow more than one cycle counter to be used
authorPratyush Anand <panand@redhat.com>
Sat, 1 Jul 2017 06:33:35 +0000 (12:03 +0530)
committerWill Deacon <will.deacon@arm.com>
Tue, 8 Aug 2017 13:33:13 +0000 (14:33 +0100)
commit1031a1592908ccd3240f4a5731c96c382c932310
treedc0cae0b5281438118b5a0c16bd244e9f5e1d400
parentaae4e7a8bc44722fe70d58920a36916b1043195e
arm64: perf: Allow more than one cycle counter to be used

Currently:
$ perf stat -e cycles:u -e cycles:k  true

 Performance counter stats for 'true':

          2,24,699      cycles:u
     <not counted>      cycles:k (0.00%)

       0.000788087 seconds time elapsed

We can not count more than one cycle counter in one instance,because we
allow to map cycle counter into PMCCNTR_EL0 only. However, if I did not
miss anything then specification do not prohibit to use PMEVCNTR<n>_EL0
for cycle count as well.

Modify the code so that it still prefers to use PMCCNTR_EL0 for cycle
counter, however allow to use PMEVCNTR<n>_EL0 if PMCCNTR_EL0 is already
in use.

After this patch:

$ perf stat -e cycles:u -e cycles:k   true

 Performance counter stats for 'true':

          2,17,310      cycles:u
          7,40,009      cycles:k

       0.000764149 seconds time elapsed

Signed-off-by: Pratyush Anand <panand@redhat.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/perf_event.c