aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2008-05-12 15:21:02 -0400
committerThomas Gleixner <tglx@linutronix.de>2008-05-23 16:01:34 -0400
commit2bb6f8d6389cbfadd657e7dc069f6986abf35e4f (patch)
tree894c84bdec4c716b1e16c60e2ab2a1ab198ac11d /kernel
parenta4feb8348b62fe76a63cdb5569f5c920f5283c06 (diff)
ftrace: use raw_smp_processor_id for mcount functions
Due to debug hooks in the kernel that can change the way smp_processor_id works, use raw_smp_processor_id in mcount called functions (namely ftrace_record_ip). Currently we annotate most debug functions from calling mcount, but we should not rely on that to prevent kernel lockups. This patch uses the raw_smp_processor_id to prevent a recusive crash that can happen if a debug hook in smp_processor_id calls mcount. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/ftrace.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 40f64f7cd850..af5ad8949abb 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -267,6 +267,7 @@ ftrace_record_ip(unsigned long ip)
267 unsigned long key; 267 unsigned long key;
268 int resched; 268 int resched;
269 int atomic; 269 int atomic;
270 int cpu;
270 271
271 if (!ftrace_enabled || ftrace_disabled) 272 if (!ftrace_enabled || ftrace_disabled)
272 return; 273 return;
@@ -274,9 +275,15 @@ ftrace_record_ip(unsigned long ip)
274 resched = need_resched(); 275 resched = need_resched();
275 preempt_disable_notrace(); 276 preempt_disable_notrace();
276 277
277 /* We simply need to protect against recursion */ 278 /*
278 __get_cpu_var(ftrace_shutdown_disable_cpu)++; 279 * We simply need to protect against recursion.
279 if (__get_cpu_var(ftrace_shutdown_disable_cpu) != 1) 280 * Use the the raw version of smp_processor_id and not
281 * __get_cpu_var which can call debug hooks that can
282 * cause a recursive crash here.
283 */
284 cpu = raw_smp_processor_id();
285 per_cpu(ftrace_shutdown_disable_cpu, cpu)++;
286 if (per_cpu(ftrace_shutdown_disable_cpu, cpu) != 1)
280 goto out; 287 goto out;
281 288
282 if (unlikely(ftrace_record_suspend)) 289 if (unlikely(ftrace_record_suspend))
@@ -317,7 +324,7 @@ ftrace_record_ip(unsigned long ip)
317 out_unlock: 324 out_unlock:
318 spin_unlock_irqrestore(&ftrace_shutdown_lock, flags); 325 spin_unlock_irqrestore(&ftrace_shutdown_lock, flags);
319 out: 326 out:
320 __get_cpu_var(ftrace_shutdown_disable_cpu)--; 327 per_cpu(ftrace_shutdown_disable_cpu, cpu)--;
321 328
322 /* prevent recursion with scheduler */ 329 /* prevent recursion with scheduler */
323 if (resched) 330 if (resched)