ftrace: store mcount address in rec->ip
[safe/jmp/linux-2.6] / kernel / trace / ftrace.c
index 0118979..f1e9e5c 100644 (file)
@@ -27,6 +27,8 @@
 #include <linux/hash.h>
 #include <linux/list.h>
 
+#include <asm/ftrace.h>
+
 #include "trace.h"
 
 /* ftrace_enabled is a method to turn ftrace on or off */
@@ -50,7 +52,7 @@ 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;
 
-void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
+static void ftrace_list_func(unsigned long ip, unsigned long parent_ip)
 {
        struct ftrace_ops *op = ftrace_list;
 
@@ -329,7 +331,6 @@ ftrace_record_ip(unsigned long ip)
 }
 
 #define FTRACE_ADDR ((long)(ftrace_caller))
-#define MCOUNT_ADDR ((long)(mcount))
 
 static int
 __ftrace_replace_code(struct dyn_ftrace *rec,
@@ -355,20 +356,26 @@ __ftrace_replace_code(struct dyn_ftrace *rec,
                 * If this record is set not to trace then
                 * do nothing.
                 *
+                * If this record is set not to trace and
+                * it is enabled then disable it.
+                *
                 * If this record is not set to be filtered and
                 * it is enabled, disable it.
                 */
-               fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_ENABLED);
+
+               fl = rec->flags & (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE |
+                                  FTRACE_FL_ENABLED);
 
                if ((fl ==  (FTRACE_FL_FILTER | FTRACE_FL_ENABLED)) ||
-                   (fl == 0) || (rec->flags & FTRACE_FL_NOTRACE))
+                   (fl ==  (FTRACE_FL_FILTER | FTRACE_FL_NOTRACE)) ||
+                   !fl || (fl == FTRACE_FL_NOTRACE))
                        return 0;
 
                /*
                 * If it is enabled disable it,
                 * otherwise enable it!
                 */
-               if (fl == FTRACE_FL_ENABLED) {
+               if (fl & FTRACE_FL_ENABLED) {
                        /* swap new and old */
                        new = old;
                        old = ftrace_call_replace(ip, FTRACE_ADDR);