Skip to content

Commit 3e23428

Browse files
committed
ftrace: Allow module init functions to be traced
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 <[email protected]> Cc: Rusty Russell <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 6cafbe1 commit 3e23428

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

include/linux/init.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
/* These are for everybody (although not all archs will actually
4141
discard it in modules) */
42-
#define __init __section(.init.text) __cold __inittrace __latent_entropy
42+
#define __init __section(.init.text) __cold __latent_entropy
4343
#define __initdata __section(.init.data)
4444
#define __initconst __section(.init.rodata)
4545
#define __exitdata __section(.exit.data)
@@ -68,10 +68,8 @@
6868

6969
#ifdef MODULE
7070
#define __exitused
71-
#define __inittrace notrace
7271
#else
7372
#define __exitused __used
74-
#define __inittrace
7573
#endif
7674

7775
#define __exit __section(.exit.text) __exitused __cold notrace

kernel/module.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,6 +3473,8 @@ static noinline int do_init_module(struct module *mod)
34733473
if (!mod->async_probe_requested && (current->flags & PF_USED_ASYNC))
34743474
async_synchronize_full();
34753475

3476+
ftrace_free_mem(mod->init_layout.base, mod->init_layout.base +
3477+
mod->init_layout.size);
34763478
mutex_lock(&module_mutex);
34773479
/* Drop initial reference. */
34783480
module_put(mod);

kernel/trace/ftrace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5752,7 +5752,8 @@ void ftrace_release_mod(struct module *mod)
57525752
last_pg = &ftrace_pages_start;
57535753
for (pg = ftrace_pages_start; pg; pg = *last_pg) {
57545754
rec = &pg->records[0];
5755-
if (within_module_core(rec->ip, mod)) {
5755+
if (within_module_core(rec->ip, mod) ||
5756+
within_module_init(rec->ip, mod)) {
57565757
/*
57575758
* As core pages are first, the first
57585759
* page should never be a module page.
@@ -5821,7 +5822,8 @@ void ftrace_module_enable(struct module *mod)
58215822
* not part of this module, then skip this pg,
58225823
* which the "break" will do.
58235824
*/
5824-
if (!within_module_core(rec->ip, mod))
5825+
if (!within_module_core(rec->ip, mod) &&
5826+
!within_module_init(rec->ip, mod))
58255827
break;
58265828

58275829
cnt = 0;

0 commit comments

Comments
 (0)