Skip to content

Commit 096b52f

Browse files
sm-scpalmer-dabbelt
authored andcommitted
perf: RISC-V: throttle perf events
Call perf_sample_event_took() to report time spent in overflow interrupts. Perf core uses these measurements to throttle perf events properly. Signed-off-by: Sergey Matyukevich <sergey.matyukevich@syntacore.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Link: https://lore.kernel.org/r/20220830155306.301714-4-geomatsi@gmail.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 1537bf2 commit 096b52f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/perf/riscv_pmu_sbi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/of_irq.h>
1919
#include <linux/of.h>
2020
#include <linux/cpu_pm.h>
21+
#include <linux/sched/clock.h>
2122

2223
#include <asm/sbi.h>
2324
#include <asm/hwcap.h>
@@ -570,6 +571,7 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
570571
unsigned long overflow;
571572
unsigned long overflowed_ctrs = 0;
572573
struct cpu_hw_events *cpu_hw_evt = dev;
574+
u64 start_clock = sched_clock();
573575

574576
if (WARN_ON_ONCE(!cpu_hw_evt))
575577
return IRQ_NONE;
@@ -638,7 +640,9 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
638640
perf_event_overflow(event, &data, regs);
639641
}
640642
}
643+
641644
pmu_sbi_start_overflow_mask(pmu, overflowed_ctrs);
645+
perf_sample_event_took(sched_clock() - start_clock);
642646

643647
return IRQ_HANDLED;
644648
}

0 commit comments

Comments
 (0)