Skip to content

Commit

Permalink
tracing/boot, kprobe, synth: Initialize boot-time tracing earlier
Browse files Browse the repository at this point in the history
Initialize boot-time tracing in core_initcall_sync instead of
fs_initcall, and initialize required tracers (kprobes and synth)
in core_initcall. This will allow the boot-time tracing to trace
__init code from the beginning of postcore_initcall stage.

Link: https://lkml.kernel.org/r/159974155727.478751.7486926132902849578.stgit@devnote2

Signed-off-by: Masami Hiramatsu <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
  • Loading branch information
mhiramat authored and rostedt committed Sep 22, 2020
1 parent 4114fbf commit ba0fbfb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
7 changes: 5 additions & 2 deletions kernel/trace/trace_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,8 @@ static int __init trace_boot_init(void)

return 0;
}

fs_initcall(trace_boot_init);
/*
* Start tracing at the end of core-initcall, so that it starts tracing
* from the beginning of postcore_initcall.
*/
core_initcall_sync(trace_boot_init);
19 changes: 14 additions & 5 deletions kernel/trace/trace_events_synth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,17 +1754,26 @@ static const struct file_operations synth_events_fops = {
.release = seq_release,
};

static __init int trace_events_synth_init(void)
/*
* Register dynevent at core_initcall. This allows kernel to setup kprobe
* events in postcore_initcall without tracefs.
*/
static __init int trace_events_synth_init_early(void)
{
struct dentry *entry = NULL;
int err = 0;

err = dyn_event_register(&synth_event_ops);
if (err) {
if (err)
pr_warn("Could not register synth_event_ops\n");
return err;
}

return err;
}
core_initcall(trace_events_synth_init_early);

static __init int trace_events_synth_init(void)
{
struct dentry *entry = NULL;
int err = 0;
err = tracing_init_dentry();
if (err)
goto err;
Expand Down
6 changes: 3 additions & 3 deletions kernel/trace/trace_kprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1897,8 +1897,8 @@ static __init void setup_boot_kprobe_events(void)
}

/*
* Register dynevent at subsys_initcall. This allows kernel to setup kprobe
* events in fs_initcall without tracefs.
* Register dynevent at core_initcall. This allows kernel to setup kprobe
* events in postcore_initcall without tracefs.
*/
static __init int init_kprobe_trace_early(void)
{
Expand All @@ -1913,7 +1913,7 @@ static __init int init_kprobe_trace_early(void)

return 0;
}
subsys_initcall(init_kprobe_trace_early);
core_initcall(init_kprobe_trace_early);

/* Make a tracefs interface for controlling probe points */
static __init int init_kprobe_trace(void)
Expand Down

0 comments on commit ba0fbfb

Please sign in to comment.