]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ftrace: use raw_smp_processor_id for mcount functions
authorSteven Rostedt <rostedt@goodmis.org>
Mon, 12 May 2008 19:21:02 +0000 (21:21 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 23 May 2008 20:01:34 +0000 (22:01 +0200)
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>
kernel/trace/ftrace.c

index 40f64f7cd850aaf2d560a97f2f133ec927d0a01d..af5ad8949abb58a72975d4237b5120145c73c439 100644 (file)
@@ -267,6 +267,7 @@ ftrace_record_ip(unsigned long ip)
        unsigned long key;
        int resched;
        int atomic;
+       int cpu;
 
        if (!ftrace_enabled || ftrace_disabled)
                return;
@@ -274,9 +275,15 @@ ftrace_record_ip(unsigned long ip)
        resched = need_resched();
        preempt_disable_notrace();
 
-       /* We simply need to protect against recursion */
-       __get_cpu_var(ftrace_shutdown_disable_cpu)++;
-       if (__get_cpu_var(ftrace_shutdown_disable_cpu) != 1)
+       /*
+        * We simply need to protect against recursion.
+        * Use the the raw version of smp_processor_id and not
+        * __get_cpu_var which can call debug hooks that can
+        * cause a recursive crash here.
+        */
+       cpu = raw_smp_processor_id();
+       per_cpu(ftrace_shutdown_disable_cpu, cpu)++;
+       if (per_cpu(ftrace_shutdown_disable_cpu, cpu) != 1)
                goto out;
 
        if (unlikely(ftrace_record_suspend))
@@ -317,7 +324,7 @@ ftrace_record_ip(unsigned long ip)
  out_unlock:
        spin_unlock_irqrestore(&ftrace_shutdown_lock, flags);
  out:
-       __get_cpu_var(ftrace_shutdown_disable_cpu)--;
+       per_cpu(ftrace_shutdown_disable_cpu, cpu)--;
 
        /* prevent recursion with scheduler */
        if (resched)