aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>2011-08-01 11:08:59 -0400
committerRobert Richter <robert.richter@amd.com>2011-08-01 16:54:19 -0400
commit1d12d35284b74b7257b84ba0cef1e82a66d73aea (patch)
treef39d356e9313635ade8755fb39d5787939bf0e8f
parent4d4abdcb1dee03a4f9d6d2021622ed07e14dfd17 (diff)
oprofile, x86: Convert memory allocation to static array
On -rt, allocators don't work from atomic context any more, and the maximum size of the array is known at compile time. Call trace on a -rt kernel: oprofile: using NMI interrupt. BUG: sleeping function called from invalid context at kernel/rtmutex.c:645 in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: kworker/0:1 Pid: 0, comm: kworker/0:1 Tainted: G C 3.0.0-rt3-patser+ #39 Call Trace: <IRQ> [<ffffffff8103fc0a>] __might_sleep+0xca/0xf0 [<ffffffff8160d424>] rt_spin_lock+0x24/0x40 [<ffffffff811476c7>] __kmalloc+0xc7/0x370 [<ffffffffa0275c85>] ? ppro_setup_ctrs+0x215/0x260 [oprofile] [<ffffffffa0273de0>] ? oprofile_cpu_notifier+0x60/0x60 [oprofile] [<ffffffffa0275c85>] ppro_setup_ctrs+0x215/0x260 [oprofile] [<ffffffffa0273de0>] ? oprofile_cpu_notifier+0x60/0x60 [oprofile] [<ffffffffa0273de0>] ? oprofile_cpu_notifier+0x60/0x60 [oprofile] [<ffffffffa0273ea4>] nmi_cpu_setup+0xc4/0x110 [oprofile] [<ffffffff81094455>] generic_smp_call_function_interrupt+0x95/0x190 [<ffffffff8101df77>] smp_call_function_interrupt+0x27/0x40 [<ffffffff81615093>] call_function_interrupt+0x13/0x20 <EOI> [<ffffffff8131d0c4>] ? plist_check_head+0x54/0xc0 [<ffffffff81371fe8>] ? intel_idle+0xc8/0x120 [<ffffffff81371fc7>] ? intel_idle+0xa7/0x120 [<ffffffff814a57b0>] cpuidle_idle_call+0xb0/0x230 [<ffffffff810011db>] cpu_idle+0x8b/0xe0 [<ffffffff815fc82f>] start_secondary+0x1d3/0x1d8 Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com> Signed-off-by: Robert Richter <robert.richter@amd.com>
-rw-r--r--arch/x86/oprofile/op_model_ppro.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
index 94b745045e45..608874b70cf4 100644
--- a/arch/x86/oprofile/op_model_ppro.c
+++ b/arch/x86/oprofile/op_model_ppro.c
@@ -28,7 +28,7 @@ static int counter_width = 32;
28 28
29#define MSR_PPRO_EVENTSEL_RESERVED ((0xFFFFFFFFULL<<32)|(1ULL<<21)) 29#define MSR_PPRO_EVENTSEL_RESERVED ((0xFFFFFFFFULL<<32)|(1ULL<<21))
30 30
31static u64 *reset_value; 31static u64 reset_value[OP_MAX_COUNTER];
32 32
33static void ppro_shutdown(struct op_msrs const * const msrs) 33static void ppro_shutdown(struct op_msrs const * const msrs)
34{ 34{
@@ -40,10 +40,6 @@ static void ppro_shutdown(struct op_msrs const * const msrs)
40 release_perfctr_nmi(MSR_P6_PERFCTR0 + i); 40 release_perfctr_nmi(MSR_P6_PERFCTR0 + i);
41 release_evntsel_nmi(MSR_P6_EVNTSEL0 + i); 41 release_evntsel_nmi(MSR_P6_EVNTSEL0 + i);
42 } 42 }
43 if (reset_value) {
44 kfree(reset_value);
45 reset_value = NULL;
46 }
47} 43}
48 44
49static int ppro_fill_in_addresses(struct op_msrs * const msrs) 45static int ppro_fill_in_addresses(struct op_msrs * const msrs)
@@ -79,13 +75,6 @@ static void ppro_setup_ctrs(struct op_x86_model_spec const *model,
79 u64 val; 75 u64 val;
80 int i; 76 int i;
81 77
82 if (!reset_value) {
83 reset_value = kzalloc(sizeof(reset_value[0]) * num_counters,
84 GFP_ATOMIC);
85 if (!reset_value)
86 return;
87 }
88
89 if (cpu_has_arch_perfmon) { 78 if (cpu_has_arch_perfmon) {
90 union cpuid10_eax eax; 79 union cpuid10_eax eax;
91 eax.full = cpuid_eax(0xa); 80 eax.full = cpuid_eax(0xa);
@@ -141,13 +130,6 @@ static int ppro_check_ctrs(struct pt_regs * const regs,
141 u64 val; 130 u64 val;
142 int i; 131 int i;
143 132
144 /*
145 * This can happen if perf counters are in use when
146 * we steal the die notifier NMI.
147 */
148 if (unlikely(!reset_value))
149 goto out;
150
151 for (i = 0; i < num_counters; ++i) { 133 for (i = 0; i < num_counters; ++i) {
152 if (!reset_value[i]) 134 if (!reset_value[i])
153 continue; 135 continue;
@@ -179,8 +161,6 @@ static void ppro_start(struct op_msrs const * const msrs)
179 u64 val; 161 u64 val;
180 int i; 162 int i;
181 163
182 if (!reset_value)
183 return;
184 for (i = 0; i < num_counters; ++i) { 164 for (i = 0; i < num_counters; ++i) {
185 if (reset_value[i]) { 165 if (reset_value[i]) {
186 rdmsrl(msrs->controls[i].addr, val); 166 rdmsrl(msrs->controls[i].addr, val);
@@ -196,8 +176,6 @@ static void ppro_stop(struct op_msrs const * const msrs)
196 u64 val; 176 u64 val;
197 int i; 177 int i;
198 178
199 if (!reset_value)
200 return;
201 for (i = 0; i < num_counters; ++i) { 179 for (i = 0; i < num_counters; ++i) {
202 if (!reset_value[i]) 180 if (!reset_value[i])
203 continue; 181 continue;