diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-12-09 15:43:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-12-11 09:45:45 -0500 |
commit | 4ac13294e44664bb7edf4daf52edb71e7c6bbe84 (patch) | |
tree | accb533350a655e39a8ab846abc37018b2f87ccf /arch | |
parent | 43874d238d5f208854a73c3225ca2a22833eec8b (diff) |
perf counters: protect them against CSTATE transitions
Impact: fix rare lost events problem
There are CPUs whose performance counters misbehave on CSTATE transitions,
so provide a way to just disable/enable them around deep idle methods.
(hw_perf_enable_all() is cheap on x86.)
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/cpu/perf_counter.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c index 6a93d1f04d97..0a7f3bea2dc6 100644 --- a/arch/x86/kernel/cpu/perf_counter.c +++ b/arch/x86/kernel/cpu/perf_counter.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/notifier.h> | 12 | #include <linux/notifier.h> |
13 | #include <linux/hardirq.h> | 13 | #include <linux/hardirq.h> |
14 | #include <linux/kprobes.h> | 14 | #include <linux/kprobes.h> |
15 | #include <linux/module.h> | ||
15 | #include <linux/kdebug.h> | 16 | #include <linux/kdebug.h> |
16 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
17 | 18 | ||
@@ -119,10 +120,21 @@ void hw_perf_enable_all(void) | |||
119 | wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0); | 120 | wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0); |
120 | } | 121 | } |
121 | 122 | ||
122 | void hw_perf_disable_all(void) | 123 | void hw_perf_restore_ctrl(u64 ctrl) |
123 | { | 124 | { |
125 | wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, ctrl, 0); | ||
126 | } | ||
127 | EXPORT_SYMBOL_GPL(hw_perf_restore_ctrl); | ||
128 | |||
129 | u64 hw_perf_disable_all(void) | ||
130 | { | ||
131 | u64 ctrl; | ||
132 | |||
133 | rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl); | ||
124 | wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0); | 134 | wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0); |
135 | return ctrl; | ||
125 | } | 136 | } |
137 | EXPORT_SYMBOL_GPL(hw_perf_disable_all); | ||
126 | 138 | ||
127 | static inline void | 139 | static inline void |
128 | __hw_perf_counter_disable(struct hw_perf_counter *hwc, unsigned int idx) | 140 | __hw_perf_counter_disable(struct hw_perf_counter *hwc, unsigned int idx) |