]> www.infradead.org Git - users/hch/misc.git/commitdiff
perf: riscv: skip empty batches in counter start
authorYunhui Cui <cuiyunhui@bytedance.com>
Mon, 4 Aug 2025 02:51:10 +0000 (10:51 +0800)
committerPaul Walmsley <pjw@kernel.org>
Fri, 19 Sep 2025 01:28:13 +0000 (19:28 -0600)
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>
drivers/perf/riscv_pmu_sbi.c

index c18dbffa983450ae2f1992a7b24721b70816d443..3fc16bbab0250bf18b5eb720f612a2a32ee68f59 100644 (file)
@@ -877,8 +877,10 @@ static inline void pmu_sbi_start_ovf_ctrs_sbi(struct cpu_hw_events *cpu_hw_evt,
        for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
                ctr_start_mask = cpu_hw_evt->used_hw_ctrs[i] & ~ctr_ovf_mask;
                /* Start all the counters that did not overflow in a single shot */
-               sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG, ctr_start_mask,
-                       0, 0, 0, 0);
+               if (ctr_start_mask) {
+                       sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG,
+                                 ctr_start_mask, 0, 0, 0, 0);
+               }
        }
 
        /* Reinitialize and start all the counter that overflowed */