]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ftrace: Make get_ftrace_addr() and get_ftrace_addr_old() global
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Wed, 7 May 2014 01:34:14 +0000 (21:34 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 14 May 2014 15:37:29 +0000 (11:37 -0400)
Move and rename get_ftrace_addr() and get_ftrace_addr_old() to
ftrace_get_addr_new() and ftrace_get_addr_curr() respectively.

This moves these two helper functions in the generic code out from
the arch specific code, and renames them to have a better generic
name. This will allow other archs to use them as well as makes it
a bit easier to work on getting separate trampolines for different
functions.

ftrace_get_addr_new() returns the trampoline address that the mcount
call address will be converted to.

ftrace_get_addr_curr() returns the trampoline address of what the
mcount call address currently jumps to.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
arch/x86/kernel/ftrace.c
include/linux/ftrace.h
kernel/trace/ftrace.c

index 4b3c195d4133bb26d5cc33ec92a3e1c6adc14b2f..5ef43ce8492ff69cd079193d44f832129dbad6dd 100644 (file)
@@ -349,38 +349,12 @@ static int add_brk_on_nop(struct dyn_ftrace *rec)
        return add_break(rec->ip, old);
 }
 
-/*
- * If the record has the FTRACE_FL_REGS set, that means that it
- * wants to convert to a callback that saves all regs. If FTRACE_FL_REGS
- * is not not set, then it wants to convert to the normal callback.
- */
-static unsigned long get_ftrace_addr(struct dyn_ftrace *rec)
-{
-       if (rec->flags & FTRACE_FL_REGS)
-               return (unsigned long)FTRACE_REGS_ADDR;
-       else
-               return (unsigned long)FTRACE_ADDR;
-}
-
-/*
- * The FTRACE_FL_REGS_EN is set when the record already points to
- * a function that saves all the regs. Basically the '_EN' version
- * represents the current state of the function.
- */
-static unsigned long get_ftrace_old_addr(struct dyn_ftrace *rec)
-{
-       if (rec->flags & FTRACE_FL_REGS_EN)
-               return (unsigned long)FTRACE_REGS_ADDR;
-       else
-               return (unsigned long)FTRACE_ADDR;
-}
-
 static int add_breakpoints(struct dyn_ftrace *rec, int enable)
 {
        unsigned long ftrace_addr;
        int ret;
 
-       ftrace_addr = get_ftrace_old_addr(rec);
+       ftrace_addr = ftrace_get_addr_curr(rec);
 
        ret = ftrace_test_record(rec, enable);
 
@@ -438,14 +412,14 @@ static int remove_breakpoint(struct dyn_ftrace *rec)
                 * If not, don't touch the breakpoint, we make just create
                 * a disaster.
                 */
-               ftrace_addr = get_ftrace_addr(rec);
+               ftrace_addr = ftrace_get_addr_new(rec);
                nop = ftrace_call_replace(ip, ftrace_addr);
 
                if (memcmp(&ins[1], &nop[1], MCOUNT_INSN_SIZE - 1) == 0)
                        goto update;
 
                /* Check both ftrace_addr and ftrace_old_addr */
-               ftrace_addr = get_ftrace_old_addr(rec);
+               ftrace_addr = ftrace_get_addr_curr(rec);
                nop = ftrace_call_replace(ip, ftrace_addr);
 
                if (memcmp(&ins[1], &nop[1], MCOUNT_INSN_SIZE - 1) != 0)
@@ -489,7 +463,7 @@ static int add_update(struct dyn_ftrace *rec, int enable)
 
        ret = ftrace_test_record(rec, enable);
 
-       ftrace_addr  = get_ftrace_addr(rec);
+       ftrace_addr  = ftrace_get_addr_new(rec);
 
        switch (ret) {
        case FTRACE_UPDATE_IGNORE:
@@ -536,7 +510,7 @@ static int finish_update(struct dyn_ftrace *rec, int enable)
 
        ret = ftrace_update_record(rec, enable);
 
-       ftrace_addr = get_ftrace_addr(rec);
+       ftrace_addr = ftrace_get_addr_new(rec);
 
        switch (ret) {
        case FTRACE_UPDATE_IGNORE:
index f0ff2c2453e7c944cbbef56f6056ecce65531b77..2f8cbffecd3d97ed193fcfde9bc81a1bdedc1d66 100644 (file)
@@ -400,6 +400,8 @@ int ftrace_update_record(struct dyn_ftrace *rec, int enable);
 int ftrace_test_record(struct dyn_ftrace *rec, int enable);
 void ftrace_run_stop_machine(int command);
 unsigned long ftrace_location(unsigned long ip);
+unsigned long ftrace_get_addr_new(struct dyn_ftrace *rec);
+unsigned long ftrace_get_addr_curr(struct dyn_ftrace *rec);
 
 extern ftrace_func_t ftrace_trace_function;
 
index 98fa931b686433741c9860757f35ce06f2df5c06..e825fded435db127ca26cd5e1eb6b2815f1a5390 100644 (file)
@@ -1755,6 +1755,42 @@ int ftrace_test_record(struct dyn_ftrace *rec, int enable)
        return ftrace_check_record(rec, enable, 0);
 }
 
+/**
+ * ftrace_get_addr_new - Get the call address to set to
+ * @rec:  The ftrace record descriptor
+ *
+ * If the record has the FTRACE_FL_REGS set, that means that it
+ * wants to convert to a callback that saves all regs. If FTRACE_FL_REGS
+ * is not not set, then it wants to convert to the normal callback.
+ *
+ * Returns the address of the trampoline to set to
+ */
+unsigned long ftrace_get_addr_new(struct dyn_ftrace *rec)
+{
+       if (rec->flags & FTRACE_FL_REGS)
+               return (unsigned long)FTRACE_REGS_ADDR;
+       else
+               return (unsigned long)FTRACE_ADDR;
+}
+
+/**
+ * ftrace_get_addr_curr - Get the call address that is already there
+ * @rec:  The ftrace record descriptor
+ *
+ * The FTRACE_FL_REGS_EN is set when the record already points to
+ * a function that saves all the regs. Basically the '_EN' version
+ * represents the current state of the function.
+ *
+ * Returns the address of the trampoline that is currently being called
+ */
+unsigned long ftrace_get_addr_curr(struct dyn_ftrace *rec)
+{
+       if (rec->flags & FTRACE_FL_REGS_EN)
+               return (unsigned long)FTRACE_REGS_ADDR;
+       else
+               return (unsigned long)FTRACE_ADDR;
+}
+
 static int
 __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
 {