aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-12-14 12:36:30 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-14 14:31:28 -0500
commit2b9ff0db19b5e2c77000b7201525f9c3d6e8328d (patch)
treef598dc6c31a60866e653620452db328fa8c87f56 /arch
parente06c61a879910869aa5bf3f8f634abfee1a7bebc (diff)
perfcounters: fix non-intel-perfmon CPUs
Do not write MSR_CORE_PERF_GLOBAL_CTRL on CPUs where it does not exist. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index 5afae13d8d59..6d30f603b62c 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -157,6 +157,9 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
157 157
158void hw_perf_enable_all(void) 158void hw_perf_enable_all(void)
159{ 159{
160 if (unlikely(!perf_counters_initialized))
161 return;
162
160 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0); 163 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0);
161} 164}
162 165
@@ -164,14 +167,21 @@ u64 hw_perf_save_disable(void)
164{ 167{
165 u64 ctrl; 168 u64 ctrl;
166 169
170 if (unlikely(!perf_counters_initialized))
171 return 0;
172
167 rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl); 173 rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl);
168 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0); 174 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0);
175
169 return ctrl; 176 return ctrl;
170} 177}
171EXPORT_SYMBOL_GPL(hw_perf_save_disable); 178EXPORT_SYMBOL_GPL(hw_perf_save_disable);
172 179
173void hw_perf_restore(u64 ctrl) 180void hw_perf_restore(u64 ctrl)
174{ 181{
182 if (unlikely(!perf_counters_initialized))
183 return;
184
175 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, ctrl, 0); 185 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, ctrl, 0);
176} 186}
177EXPORT_SYMBOL_GPL(hw_perf_restore); 187EXPORT_SYMBOL_GPL(hw_perf_restore);