perfcounters: fix non-intel-perfmon CPUs
authorIngo Molnar <mingo@elte.hu>
Sun, 14 Dec 2008 17:36:30 +0000 (18:36 +0100)
committerIngo Molnar <mingo@elte.hu>
Sun, 14 Dec 2008 19:31:28 +0000 (20:31 +0100)
Do not write MSR_CORE_PERF_GLOBAL_CTRL on CPUs where it does not exist.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/cpu/perf_counter.c

index 5afae13d8d59b721a493bc0a0a8516d08f9e8656..6d30f603b62c3903061fc78e143163c9c20d1fda 100644 (file)
@@ -157,6 +157,9 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
 
 void hw_perf_enable_all(void)
 {
+       if (unlikely(!perf_counters_initialized))
+               return;
+
        wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0);
 }
 
@@ -164,14 +167,21 @@ u64 hw_perf_save_disable(void)
 {
        u64 ctrl;
 
+       if (unlikely(!perf_counters_initialized))
+               return 0;
+
        rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl);
        wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0);
+
        return ctrl;
 }
 EXPORT_SYMBOL_GPL(hw_perf_save_disable);
 
 void hw_perf_restore(u64 ctrl)
 {
+       if (unlikely(!perf_counters_initialized))
+               return;
+
        wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, ctrl, 0);
 }
 EXPORT_SYMBOL_GPL(hw_perf_restore);
This page took 0.028238 seconds and 5 git commands to generate.