Skip to content

Commit 455adb3

Browse files
committed
sparc: Throttle perf events properly.
Like x86 and arm, call perf_sample_event_took() in perf event NMI interrupt handler. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cfdc317 commit 455adb3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

arch/sparc/kernel/perf_event.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <asm/cpudata.h>
2525
#include <linux/uaccess.h>
2626
#include <linux/atomic.h>
27+
#include <linux/sched/clock.h>
2728
#include <asm/nmi.h>
2829
#include <asm/pcr.h>
2930
#include <asm/cacheflush.h>
@@ -1612,6 +1613,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
16121613
struct perf_sample_data data;
16131614
struct cpu_hw_events *cpuc;
16141615
struct pt_regs *regs;
1616+
u64 finish_clock;
1617+
u64 start_clock;
16151618
int i;
16161619

16171620
if (!atomic_read(&active_events))
@@ -1625,6 +1628,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
16251628
return NOTIFY_DONE;
16261629
}
16271630

1631+
start_clock = sched_clock();
1632+
16281633
regs = args->regs;
16291634

16301635
cpuc = this_cpu_ptr(&cpu_hw_events);
@@ -1663,6 +1668,10 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
16631668
sparc_pmu_stop(event, 0);
16641669
}
16651670

1671+
finish_clock = sched_clock();
1672+
1673+
perf_sample_event_took(finish_clock - start_clock);
1674+
16661675
return NOTIFY_STOP;
16671676
}
16681677

0 commit comments

Comments
 (0)