]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ftrace: Allow module init functions to be traced
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Fri, 3 Mar 2017 23:00:22 +0000 (18:00 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 5 Oct 2017 21:57:30 +0000 (17:57 -0400)
Allow for module init sections to be traced as well as core kernel init
sections. Now that filtering modules functions can be stored, for when they
are loaded, it makes sense to be able to trace them.

Cc: Jessica Yu <jeyu@kernel.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
include/linux/init.h
kernel/module.c
kernel/trace/ftrace.c

index 94769d687cf07d8b41081f3e966d7319b5a71ee9..a779c18164376ce6c78eb80ec1d7503727100344 100644 (file)
@@ -39,7 +39,7 @@
 
 /* These are for everybody (although not all archs will actually
    discard it in modules) */
-#define __init         __section(.init.text) __cold __inittrace __latent_entropy
+#define __init         __section(.init.text) __cold  __latent_entropy
 #define __initdata     __section(.init.data)
 #define __initconst    __section(.init.rodata)
 #define __exitdata     __section(.exit.data)
 
 #ifdef MODULE
 #define __exitused
-#define __inittrace notrace
 #else
 #define __exitused  __used
-#define __inittrace
 #endif
 
 #define __exit          __section(.exit.text) __exitused __cold notrace
index de66ec82599289d786063457ef46a3619893bb03..58bca427ac3fb11a6d27f495278e214d75cec539 100644 (file)
@@ -3473,6 +3473,8 @@ static noinline int do_init_module(struct module *mod)
        if (!mod->async_probe_requested && (current->flags & PF_USED_ASYNC))
                async_synchronize_full();
 
+       ftrace_free_mem(mod->init_layout.base, mod->init_layout.base +
+                       mod->init_layout.size);
        mutex_lock(&module_mutex);
        /* Drop initial reference. */
        module_put(mod);
index 84cb5928665ae9c6ab6d62ee32eafe14f6d89452..d7297e866e4aee352e972ae2a1d33a2992ff096e 100644 (file)
@@ -5752,7 +5752,8 @@ void ftrace_release_mod(struct module *mod)
        last_pg = &ftrace_pages_start;
        for (pg = ftrace_pages_start; pg; pg = *last_pg) {
                rec = &pg->records[0];
-               if (within_module_core(rec->ip, mod)) {
+               if (within_module_core(rec->ip, mod) ||
+                   within_module_init(rec->ip, mod)) {
                        /*
                         * As core pages are first, the first
                         * page should never be a module page.
@@ -5821,7 +5822,8 @@ void ftrace_module_enable(struct module *mod)
                 * not part of this module, then skip this pg,
                 * which the "break" will do.
                 */
-               if (!within_module_core(rec->ip, mod))
+               if (!within_module_core(rec->ip, mod) &&
+                   !within_module_init(rec->ip, mod))
                        break;
 
                cnt = 0;