Skip to content

Commit

Permalink
perfcounters: fix non-intel-perfmon CPUs
Browse files Browse the repository at this point in the history
Do not write MSR_CORE_PERF_GLOBAL_CTRL on CPUs where it does not exist.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Ingo Molnar committed Dec 14, 2008
1 parent e06c61a commit 2b9ff0d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,31 @@ 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);
}

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);
Expand Down

0 comments on commit 2b9ff0d

Please sign in to comment.