Skip to content

Commit 941a8e9

Browse files
Shifrin Dmitrypalmer-dabbelt
authored andcommitted
perf: riscv: Fix selecting counters in legacy mode
It is required to check event type before checking event config. Events with the different types can have the same config. This check is missed for legacy mode code For such perf usage: sysctl -w kernel.perf_user_access=2 perf stat -e cycles,L1-dcache-loads -- driver will try to force both events to CYCLE counter. This commit implements event type check before forcing events on the special counters. Signed-off-by: Shifrin Dmitry <[email protected]> Reviewed-by: Atish Patra <[email protected]> Fixes: cc4c07c ("drivers: perf: Implement perf event mmap support in the SBI backend") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 57e5c81 commit 941a8e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/perf/riscv_pmu_sbi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
416416
* but not in the user access mode as we want to use the other counters
417417
* that support sampling/filtering.
418418
*/
419-
if (hwc->flags & PERF_EVENT_FLAG_LEGACY) {
419+
if ((hwc->flags & PERF_EVENT_FLAG_LEGACY) && (event->attr.type == PERF_TYPE_HARDWARE)) {
420420
if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES) {
421421
cflags |= SBI_PMU_CFG_FLAG_SKIP_MATCH;
422422
cmask = 1;

0 commit comments

Comments
 (0)