]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - kernel/trace/ftrace.c
ftrace: move ftrace_special to trace.c
[mv-sheeva.git] / kernel / trace / ftrace.c
index 281d97a3208ce70f8ededf70f8186b48586bbddc..89bd9a6f52ecedbe69f960d2a9ca2d4d2eaf6a5c 100644 (file)
 #include <linux/kallsyms.h>
 #include <linux/seq_file.h>
 #include <linux/debugfs.h>
-#include <linux/kthread.h>
 #include <linux/hardirq.h>
-#include <linux/ftrace.h>
+#include <linux/kthread.h>
 #include <linux/uaccess.h>
+#include <linux/ftrace.h>
 #include <linux/sysctl.h>
-#include <linux/hash.h>
 #include <linux/ctype.h>
+#include <linux/hash.h>
 #include <linux/list.h>
 
 #include "trace.h"
@@ -50,9 +50,6 @@ static struct ftrace_ops ftrace_list_end __read_mostly =
 static struct ftrace_ops *ftrace_list __read_mostly = &ftrace_list_end;
 ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub;
 
-/* mcount is defined per arch in assembly */
-EXPORT_SYMBOL(mcount);
-
 void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
 {
        struct ftrace_ops *op = ftrace_list;
@@ -177,9 +174,9 @@ static DEFINE_MUTEX(ftrace_filter_lock);
 
 struct ftrace_page {
        struct ftrace_page      *next;
-       int                     index;
+       unsigned long           index;
        struct dyn_ftrace       records[];
-} __attribute__((packed));
+};
 
 #define ENTRIES_PER_PAGE \
   ((PAGE_SIZE - sizeof(struct ftrace_page)) / sizeof(struct dyn_ftrace))
@@ -267,6 +264,7 @@ ftrace_record_ip(unsigned long ip)
        unsigned long key;
        int resched;
        int atomic;
+       int cpu;
 
        if (!ftrace_enabled || ftrace_disabled)
                return;
@@ -274,9 +272,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 +321,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)
@@ -630,10 +634,10 @@ static int ftraced(void *ignore)
 {
        unsigned long usecs;
 
-       set_current_state(TASK_INTERRUPTIBLE);
-
        while (!kthread_should_stop()) {
 
+               set_current_state(TASK_INTERRUPTIBLE);
+
                /* check once a second */
                schedule_timeout(HZ);
 
@@ -667,8 +671,6 @@ static int ftraced(void *ignore)
                wake_up_interruptible(&ftraced_waiters);
 
                ftrace_shutdown_replenish();
-
-               set_current_state(TASK_INTERRUPTIBLE);
        }
        __set_current_state(TASK_RUNNING);
        return 0;