tracing: correct module boundaries for ftrace_release
authorjolsa@redhat.com <jolsa@redhat.com>
Wed, 7 Oct 2009 17:00:35 +0000 (19:00 +0200)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 7 Oct 2009 19:52:09 +0000 (15:52 -0400)
When the module is about the unload we release its call records.
The ftrace_release function was given wrong values representing
the module core boundaries, thus not releasing its call records.

Plus making ftrace_release function module specific.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
LKML-Reference: <1254934835-363-3-git-send-email-jolsa@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
include/linux/ftrace.h
kernel/trace/ftrace.c

index cd3d2abaf30a806f508d0d98950f97739ba26562..0b4f97d24d7f510b243bdd8cd461daa2786eaa19 100644 (file)
@@ -241,7 +241,7 @@ extern void ftrace_enable_daemon(void);
 # define ftrace_set_filter(buf, len, reset)    do { } while (0)
 # define ftrace_disable_daemon()               do { } while (0)
 # define ftrace_enable_daemon()                        do { } while (0)
-static inline void ftrace_release(void *start, unsigned long size) { }
+static inline void ftrace_release_mod(struct module *mod) {}
 static inline int register_ftrace_command(struct ftrace_func_command *cmd)
 {
        return -EINVAL;
index 46592feab5a6b0cf47e5cc147f43e1669efcf712..c701476a648bd108c08ec10e11660829a6f415f5 100644 (file)
@@ -2658,19 +2658,17 @@ static int ftrace_convert_nops(struct module *mod,
 }
 
 #ifdef CONFIG_MODULES
-void ftrace_release(void *start, void *end)
+void ftrace_release_mod(struct module *mod)
 {
        struct dyn_ftrace *rec;
        struct ftrace_page *pg;
-       unsigned long s = (unsigned long)start;
-       unsigned long e = (unsigned long)end;
 
-       if (ftrace_disabled || !start || start == end)
+       if (ftrace_disabled)
                return;
 
        mutex_lock(&ftrace_lock);
        do_for_each_ftrace_rec(pg, rec) {
-               if ((rec->ip >= s) && (rec->ip < e)) {
+               if (within_module_core(rec->ip, mod)) {
                        /*
                         * rec->ip is changed in ftrace_free_rec()
                         * It should not between s and e if record was freed.
@@ -2702,9 +2700,7 @@ static int ftrace_module_notify(struct notifier_block *self,
                                   mod->num_ftrace_callsites);
                break;
        case MODULE_STATE_GOING:
-               ftrace_release(mod->ftrace_callsites,
-                              mod->ftrace_callsites +
-                              mod->num_ftrace_callsites);
+               ftrace_release_mod(mod);
                break;
        }