diff options
author | Yong Wang <yong.y.wang@linux.intel.com> | 2009-05-29 01:28:35 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-29 03:04:58 -0400 |
commit | c323d95fa4dbe0b6bf6d59e24a0b7db067dd08a7 (patch) | |
tree | 4e674688eb9ba7a84ab34db4bf51cfca34edf6ed /arch | |
parent | da417a7537cbf4beb28a08a49adf915f2358040c (diff) |
perf_counter/x86: Always use NMI for performance-monitoring interrupt
Always use NMI for performance-monitoring interrupt as there could be
racy situations if we switch between irq and nmi mode frequently.
Signed-off-by: Yong Wang <yong.y.wang@intel.com>
LKML-Reference: <20090529052835.GA13657@ywang-moblin2.bj.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/perf_counter.h | 4 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/perf_counter.c | 19 |
3 files changed, 8 insertions, 17 deletions
diff --git a/arch/x86/include/asm/perf_counter.h b/arch/x86/include/asm/perf_counter.h index d08dd52cb8ff..876ed97147b3 100644 --- a/arch/x86/include/asm/perf_counter.h +++ b/arch/x86/include/asm/perf_counter.h | |||
@@ -91,10 +91,10 @@ extern void set_perf_counter_pending(void); | |||
91 | 91 | ||
92 | #ifdef CONFIG_PERF_COUNTERS | 92 | #ifdef CONFIG_PERF_COUNTERS |
93 | extern void init_hw_perf_counters(void); | 93 | extern void init_hw_perf_counters(void); |
94 | extern void perf_counters_lapic_init(int nmi); | 94 | extern void perf_counters_lapic_init(void); |
95 | #else | 95 | #else |
96 | static inline void init_hw_perf_counters(void) { } | 96 | static inline void init_hw_perf_counters(void) { } |
97 | static inline void perf_counters_lapic_init(int nmi) { } | 97 | static inline void perf_counters_lapic_init(void) { } |
98 | #endif | 98 | #endif |
99 | 99 | ||
100 | #endif /* _ASM_X86_PERF_COUNTER_H */ | 100 | #endif /* _ASM_X86_PERF_COUNTER_H */ |
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 89b63b5fad33..60df2efd7c80 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -1135,7 +1135,7 @@ void __cpuinit setup_local_APIC(void) | |||
1135 | apic_write(APIC_ESR, 0); | 1135 | apic_write(APIC_ESR, 0); |
1136 | } | 1136 | } |
1137 | #endif | 1137 | #endif |
1138 | perf_counters_lapic_init(0); | 1138 | perf_counters_lapic_init(); |
1139 | 1139 | ||
1140 | preempt_disable(); | 1140 | preempt_disable(); |
1141 | 1141 | ||
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c index 2eeaa99add1c..316b0c995f38 100644 --- a/arch/x86/kernel/cpu/perf_counter.c +++ b/arch/x86/kernel/cpu/perf_counter.c | |||
@@ -604,7 +604,7 @@ try_generic: | |||
604 | hwc->counter_base = x86_pmu.perfctr; | 604 | hwc->counter_base = x86_pmu.perfctr; |
605 | } | 605 | } |
606 | 606 | ||
607 | perf_counters_lapic_init(hwc->nmi); | 607 | perf_counters_lapic_init(); |
608 | 608 | ||
609 | x86_pmu.disable(hwc, idx); | 609 | x86_pmu.disable(hwc, idx); |
610 | 610 | ||
@@ -863,24 +863,15 @@ void set_perf_counter_pending(void) | |||
863 | apic->send_IPI_self(LOCAL_PENDING_VECTOR); | 863 | apic->send_IPI_self(LOCAL_PENDING_VECTOR); |
864 | } | 864 | } |
865 | 865 | ||
866 | void perf_counters_lapic_init(int nmi) | 866 | void perf_counters_lapic_init(void) |
867 | { | 867 | { |
868 | u32 apic_val; | ||
869 | |||
870 | if (!x86_pmu_initialized()) | 868 | if (!x86_pmu_initialized()) |
871 | return; | 869 | return; |
872 | 870 | ||
873 | /* | 871 | /* |
874 | * Enable the performance counter vector in the APIC LVT: | 872 | * Always use NMI for PMU |
875 | */ | 873 | */ |
876 | apic_val = apic_read(APIC_LVTERR); | 874 | apic_write(APIC_LVTPC, APIC_DM_NMI); |
877 | |||
878 | apic_write(APIC_LVTERR, apic_val | APIC_LVT_MASKED); | ||
879 | if (nmi) | ||
880 | apic_write(APIC_LVTPC, APIC_DM_NMI); | ||
881 | else | ||
882 | apic_write(APIC_LVTPC, LOCAL_PERF_VECTOR); | ||
883 | apic_write(APIC_LVTERR, apic_val); | ||
884 | } | 875 | } |
885 | 876 | ||
886 | static int __kprobes | 877 | static int __kprobes |
@@ -1054,7 +1045,7 @@ void __init init_hw_perf_counters(void) | |||
1054 | 1045 | ||
1055 | pr_info("... counter mask: %016Lx\n", perf_counter_mask); | 1046 | pr_info("... counter mask: %016Lx\n", perf_counter_mask); |
1056 | 1047 | ||
1057 | perf_counters_lapic_init(0); | 1048 | perf_counters_lapic_init(); |
1058 | register_die_notifier(&perf_counter_nmi_notifier); | 1049 | register_die_notifier(&perf_counter_nmi_notifier); |
1059 | } | 1050 | } |
1060 | 1051 | ||