Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
ftrace: Move toplevel init out of ftrace_init_tracefs()
Browse files Browse the repository at this point in the history
Commit 345ddcc ("ftrace: Have set_ftrace_pid use the bitmap like events
do") placed ftrace_init_tracefs into the instance creation, and encapsulated
the top level updating with an if conditional, as the top level only gets
updated at boot up. Unfortunately, this triggers section mismatch errors as
the init functions are called from a function that can be called later, and
the section mismatch logic is unaware of the if conditional that would
prevent it from happening at run time.

To make everyone happy, create a separate ftrace_init_tracefs_toplevel()
routine that only gets called by init functions, and this will be what calls
other init functions for the toplevel directory.

Link: http://lkml.kernel.org/r/[email protected]

Reported-by: kbuild test robot <[email protected]>
Reported-by: Arnd Bergmann <[email protected]>
Fixes: 345ddcc ("ftrace: Have set_ftrace_pid use the bitmap like events do")
Signed-off-by: Steven Rostedt <[email protected]>
  • Loading branch information
rostedt committed Jul 5, 2016
1 parent 7fa8b71 commit 501c237
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
16 changes: 10 additions & 6 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5539,16 +5539,20 @@ static const struct file_operations ftrace_pid_fops = {

void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer)
{
/* Only the top level directory has the dyn_tracefs and profile */
if (tr->flags & TRACE_ARRAY_FL_GLOBAL) {
ftrace_init_dyn_tracefs(d_tracer);
ftrace_profile_tracefs(d_tracer);
}

trace_create_file("set_ftrace_pid", 0644, d_tracer,
tr, &ftrace_pid_fops);
}

void __init ftrace_init_tracefs_toplevel(struct trace_array *tr,
struct dentry *d_tracer)
{
/* Only the top level directory has the dyn_tracefs and profile */
WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL));

ftrace_init_dyn_tracefs(d_tracer);
ftrace_profile_tracefs(d_tracer);
}

/**
* ftrace_kill - kill ftrace
*
Expand Down
1 change: 1 addition & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7369,6 +7369,7 @@ static __init int tracer_init_tracefs(void)
return 0;

init_tracer_tracefs(&global_trace, d_tracer);
ftrace_init_tracefs_toplevel(&global_trace, d_tracer);

trace_create_file("tracing_thresh", 0644, d_tracer,
&global_trace, &tracing_thresh_fops);
Expand Down
3 changes: 3 additions & 0 deletions kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,8 @@ void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func);
void ftrace_reset_array_ops(struct trace_array *tr);
int using_ftrace_ops_list_func(void);
void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer);
void ftrace_init_tracefs_toplevel(struct trace_array *tr,
struct dentry *d_tracer);
#else
static inline int ftrace_trace_task(struct trace_array *tr)
{
Expand All @@ -874,6 +876,7 @@ static inline __init void
ftrace_init_global_array_ops(struct trace_array *tr) { }
static inline void ftrace_reset_array_ops(struct trace_array *tr) { }
static inline void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d) { }
static inline void ftrace_init_tracefs_toplevel(struct trace_array *tr, struct dentry *d) { }
/* ftace_func_t type is not defined, use macro instead of static inline */
#define ftrace_init_array_ops(tr, func) do { } while (0)
#endif /* CONFIG_FUNCTION_TRACER */
Expand Down

0 comments on commit 501c237

Please sign in to comment.