aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-10-12 13:33:20 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-12 13:33:20 -0400
commit455adb3174d2c8518cef1a61140c211f6ac224d2 (patch)
treea3c8dcaf2cd8e4bf6784349b45c758c5225a42b4
parentcfdc3170d214046b9509183fe9b9544dc644d40b (diff)
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>
-rw-r--r--arch/sparc/kernel/perf_event.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index a4cc26bd89a2..67b3e6b3ce5d 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -24,6 +24,7 @@
24#include <asm/cpudata.h> 24#include <asm/cpudata.h>
25#include <linux/uaccess.h> 25#include <linux/uaccess.h>
26#include <linux/atomic.h> 26#include <linux/atomic.h>
27#include <linux/sched/clock.h>
27#include <asm/nmi.h> 28#include <asm/nmi.h>
28#include <asm/pcr.h> 29#include <asm/pcr.h>
29#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
@@ -1612,6 +1613,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
1612 struct perf_sample_data data; 1613 struct perf_sample_data data;
1613 struct cpu_hw_events *cpuc; 1614 struct cpu_hw_events *cpuc;
1614 struct pt_regs *regs; 1615 struct pt_regs *regs;
1616 u64 finish_clock;
1617 u64 start_clock;
1615 int i; 1618 int i;
1616 1619
1617 if (!atomic_read(&active_events)) 1620 if (!atomic_read(&active_events))
@@ -1625,6 +1628,8 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
1625 return NOTIFY_DONE; 1628 return NOTIFY_DONE;
1626 } 1629 }
1627 1630
1631 start_clock = sched_clock();
1632
1628 regs = args->regs; 1633 regs = args->regs;
1629 1634
1630 cpuc = this_cpu_ptr(&cpu_hw_events); 1635 cpuc = this_cpu_ptr(&cpu_hw_events);
@@ -1663,6 +1668,10 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
1663 sparc_pmu_stop(event, 0); 1668 sparc_pmu_stop(event, 0);
1664 } 1669 }
1665 1670
1671 finish_clock = sched_clock();
1672
1673 perf_sample_event_took(finish_clock - start_clock);
1674
1666 return NOTIFY_STOP; 1675 return NOTIFY_STOP;
1667} 1676}
1668 1677