aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-12-09 06:23:59 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-09 13:28:50 -0500
commit43874d238d5f208854a73c3225ca2a22833eec8b (patch)
treed816ecccb2ae3b0779f5f82c0defebdab57ade29
parent1e12567678054bc1d4c944ecfad17624b3e49345 (diff)
perfcounters: consolidate global-disable codepaths
Impact: cleanup Simplify global disable handling. Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index 919ec46679b2..6a93d1f04d97 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -33,7 +33,6 @@ static u32 perf_counter_mask __read_mostly;
33struct cpu_hw_counters { 33struct cpu_hw_counters {
34 struct perf_counter *counters[MAX_HW_COUNTERS]; 34 struct perf_counter *counters[MAX_HW_COUNTERS];
35 unsigned long used[BITS_TO_LONGS(MAX_HW_COUNTERS)]; 35 unsigned long used[BITS_TO_LONGS(MAX_HW_COUNTERS)];
36 int enable_all;
37}; 36};
38 37
39/* 38/*
@@ -115,24 +114,13 @@ int hw_perf_counter_init(struct perf_counter *counter, s32 hw_event_type)
115 return 0; 114 return 0;
116} 115}
117 116
118static void __hw_perf_enable_all(void)
119{
120 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0);
121}
122
123void hw_perf_enable_all(void) 117void hw_perf_enable_all(void)
124{ 118{
125 struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters); 119 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, perf_counter_mask, 0);
126
127 cpuc->enable_all = 1;
128 __hw_perf_enable_all();
129} 120}
130 121
131void hw_perf_disable_all(void) 122void hw_perf_disable_all(void)
132{ 123{
133 struct cpu_hw_counters *cpuc = &__get_cpu_var(cpu_hw_counters);
134
135 cpuc->enable_all = 0;
136 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0); 124 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0);
137} 125}
138 126
@@ -385,8 +373,10 @@ perf_handle_group(struct perf_counter *leader, u64 *status, u64 *overflown)
385static void __smp_perf_counter_interrupt(struct pt_regs *regs, int nmi) 373static void __smp_perf_counter_interrupt(struct pt_regs *regs, int nmi)
386{ 374{
387 int bit, cpu = smp_processor_id(); 375 int bit, cpu = smp_processor_id();
376 u64 ack, status, saved_global;
388 struct cpu_hw_counters *cpuc; 377 struct cpu_hw_counters *cpuc;
389 u64 ack, status; 378
379 rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, saved_global);
390 380
391 /* Disable counters globally */ 381 /* Disable counters globally */
392 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0); 382 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0, 0);
@@ -445,10 +435,9 @@ again:
445 goto again; 435 goto again;
446out: 436out:
447 /* 437 /*
448 * Do not reenable when global enable is off: 438 * Restore - do not reenable when global enable is off:
449 */ 439 */
450 if (cpuc->enable_all) 440 wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, saved_global, 0);
451 __hw_perf_enable_all();
452} 441}
453 442
454void smp_perf_counter_interrupt(struct pt_regs *regs) 443void smp_perf_counter_interrupt(struct pt_regs *regs)