Skip to content

Commit 568a2fa

Browse files
cuiyunhuiPaul Walmsley
authored andcommitted
perf: riscv: skip empty batches in counter start
Avoid unnecessary SBI calls when starting non-overflowed counters in pmu_sbi_start_ovf_ctrs_sbi() by checking ctr_start_mask. Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250804025110.11088-1-cuiyunhui@bytedance.com Signed-off-by: Paul Walmsley <pjw@kernel.org>
1 parent f68cd7d commit 568a2fa

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/perf/riscv_pmu_sbi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,10 @@ static inline void pmu_sbi_start_ovf_ctrs_sbi(struct cpu_hw_events *cpu_hw_evt,
877877
for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
878878
ctr_start_mask = cpu_hw_evt->used_hw_ctrs[i] & ~ctr_ovf_mask;
879879
/* Start all the counters that did not overflow in a single shot */
880-
sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG, ctr_start_mask,
881-
0, 0, 0, 0);
880+
if (ctr_start_mask) {
881+
sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG,
882+
ctr_start_mask, 0, 0, 0, 0);
883+
}
882884
}
883885

884886
/* Reinitialize and start all the counter that overflowed */

0 commit comments

Comments
 (0)