Re: [PATCH] perf: riscv: Fix counter_idx_base in PMU snapshot restart
Anup Patel <[email protected]>
| Newsgroups | org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAAhSdy1kus5OsuvgUR1N4eNUPcJJkiy4tm06OOCNkP29be0D5g@mail.gmail.com> |
On Sat, Aug 22, 2026 at 9:43 PM liutong <[email protected]> wrote: > > In pmu_sbi_start_ovf_ctrs_snapshot(), after for_each_set_bit() finishes > iterating used_hw_ctrs[i], idx is left at BITS_PER_LONG. The subsequent > sbi_ecall() uses idx * BITS_PER_LONG as counter_idx_base, passing an > out-of-range value (4096 on 64-bit) to SBI_EXT_PMU_COUNTER_START. > > This causes the firmware to reject the call and overflowed counters are > never restarted. > > Use the outer loop index 'i' instead of the exhausted iterator 'idx'. > > Fixes: a8625217a054 ("drivers/perf: riscv: Implement SBI PMU snapshot function") > Signed-off-by: liutong <[email protected]> LGTM. Reviewed-by: Anup Patel <[email protected]> Thanks, Anup > --- > drivers/perf/riscv_pmu_sbi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c > index dfc886dee..099ba974a 100644 > --- a/drivers/perf/riscv_pmu_sbi.c > +++ b/drivers/perf/riscv_pmu_sbi.c > @@ -1021,7 +1021,7 @@ static inline void pmu_sbi_start_ovf_ctrs_snapshot(struct cpu_hw_events *cpu_hw_ > sdata->ctr_values[idx] = > cpu_hw_evt->snapshot_cval_shcopy[idx + i * BITS_PER_LONG]; > /* Start all the counters in a single shot */ > - sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, idx * BITS_PER_LONG, > + sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, i * BITS_PER_LONG, > cpu_hw_evt->used_hw_ctrs[i], flag, 0, 0, 0); > } > } > -- > 2.34.1 > _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv