]> www.infradead.org Git - nvme.git/commit
perf: RISC-V: Check standard event availability
authorSamuel Holland <samuel.holland@sifive.com>
Fri, 28 Jun 2024 07:51:43 +0000 (00:51 -0700)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 3 Jul 2024 19:56:22 +0000 (12:56 -0700)
commit16d3b1af0944cd0e4eae291ab0097c54ecbc1048
tree8e559a8969dbb64c10a4ccbdbbe97911bfb2cdc1
parent7dd646cf745c34d31e7ed2a52265e9ca8308f58f
perf: RISC-V: Check standard event availability

The RISC-V SBI PMU specification defines several standard hardware and
cache events. Currently, all of these events are exposed to userspace,
even when not actually implemented. They appear in the `perf list`
output, and commands like `perf stat` try to use them.

This is more than just a cosmetic issue, because the PMU driver's .add
function fails for these events, which causes pmu_groups_sched_in() to
prematurely stop scheduling in other (possibly valid) hardware events.

Add logic to check which events are supported by the hardware (i.e. can
be mapped to some counter), so only usable events are reported to
userspace. Since the kernel does not know the mapping between events and
possible counters, this check must happen during boot, when no counters
are in use. Make the check asynchronous to minimize impact on boot time.

Fixes: e9991434596f ("RISC-V: Add perf platform driver based on SBI PMU extension")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Tested-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20240628-misc_perf_fixes-v4-3-e01cfddcf035@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kvm/vcpu_pmu.c
drivers/perf/riscv_pmu_sbi.c