AmpereComputing / ampere-lts-kernel---DEPRECATED

Linux 5.4 and 5.10 Longterm kernel (LTS) with Ampere patches
20 stars 17 forks source link

smmu perf event not work as expected #53

Open adamliyi opened 3 years ago

adamliyi commented 3 years ago

Kernel 5.10.27. Without running any io workload.

We cannot sample two events in one 'perf stat' command. e.g:

# perf stat -e smmuv3_pmcg_27ffe0202/transaction/ -a -I 1000 sleep 2
#           time             counts unit events
     1.000091672                  0      smmuv3_pmcg_27ffe0202/transaction/  <------ as expected, all 0
     2.000222865                  0      smmuv3_pmcg_27ffe0202/transaction/
     2.001426832                  0      smmuv3_pmcg_27ffe0202/transaction/

# perf stat -e smmuv3_pmcg_27ffe0202/tlb_miss/ -a -I 1000 sleep 2
#           time             counts unit events
     1.000096473                  0      smmuv3_pmcg_27ffe0202/tlb_miss/  <--------- as expected, all 0
     2.000235305                  0      smmuv3_pmcg_27ffe0202/tlb_miss/
     2.001375392                  0      smmuv3_pmcg_27ffe0202/tlb_miss/

But if we sample two events in one command, tlb_miss will report non-zero value

# perf stat -e smmuv3_pmcg_27ffe0202/transaction/,smmuv3_pmcg_27ffe0202/tlb_miss/ -a -I 1000 sleep 2
#           time             counts unit events
     1.000105080                  0      smmuv3_pmcg_27ffe0202/transaction/
     1.000105080          500037648      smmuv3_pmcg_27ffe0202/tlb_miss/ <------------ unexpected value
     2.000255880                  0      smmuv3_pmcg_27ffe0202/transaction/
     2.000255880          500074150      smmuv3_pmcg_27ffe0202/tlb_miss/
     2.001373086                  0      smmuv3_pmcg_27ffe0202/transaction/
     2.001373086             558006      smmuv3_pmcg_27ffe0202/tlb_miss/  <-------------- unexpected value

Does smmu pmu counter by design cannot be re-used?

adamliyi commented 3 years ago

Tested with upstream 5.14 kernel (and perf tool is also from 5.14 kernel. This issue seems fixed.

# perf --version
perf version 5.13.g77d34a4683b0
# perf stat -e smmuv3_pmcg_27ffe0202/transaction/,smmuv3_pmcg_27ffe0202/tlb_miss/ -a -I 1000 sleep 5
#           time             counts unit events
     1.001040994                  0      smmuv3_pmcg_27ffe0202/transaction/
     1.001040994                  0      smmuv3_pmcg_27ffe0202/tlb_miss/
     2.002179028                  0      smmuv3_pmcg_27ffe0202/transaction/
     2.002179028                  0      smmuv3_pmcg_27ffe0202/tlb_miss/
     3.003257062                  0      smmuv3_pmcg_27ffe0202/transaction/
     3.003257062                  0      smmuv3_pmcg_27ffe0202/tlb_miss/
     4.004313056                  0      smmuv3_pmcg_27ffe0202/transaction/
     4.004313056                  0      smmuv3_pmcg_27ffe0202/tlb_miss/
     5.001304670                  0      smmuv3_pmcg_27ffe0202/transaction/
     5.001304670                  0      smmuv3_pmcg_27ffe0202/tlb_miss/
adamliyi commented 3 years ago

Fixed by commit: https://github.com/AmpereComputing/ampere-lts-kernel/commit/79aa8c94e778af7a915e8d08063ba9f72edca4d3. Backport upstream patch from 5.14 kernel: https://github.com/torvalds/linux/commit/4c1daba15c209b99d192f147fea3dade30f72ed2