Skip to content

Commit

Permalink
sparc: Throttle perf events properly.
Browse files Browse the repository at this point in the history
[ Upstream commit 455adb3 ]

Like x86 and arm, call perf_sample_event_took() in perf event
NMI interrupt handler.

Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
davem330 authored and gregkh committed Nov 13, 2018
1 parent 9d388b0 commit c37b554
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions arch/sparc/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <asm/cpudata.h>
#include <linux/uaccess.h>
#include <linux/atomic.h>
#include <linux/sched/clock.h>
#include <asm/nmi.h>
#include <asm/pcr.h>
#include <asm/cacheflush.h>
Expand Down Expand Up @@ -1612,6 +1613,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
struct perf_sample_data data;
struct cpu_hw_events *cpuc;
struct pt_regs *regs;
u64 finish_clock;
u64 start_clock;
int i;

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

start_clock = sched_clock();

regs = args->regs;

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

finish_clock = sched_clock();

perf_sample_event_took(finish_clock - start_clock);

return NOTIFY_STOP;
}

Expand Down

0 comments on commit c37b554

Please sign in to comment.