Skip to content

Commit

Permalink
tracing: Separate out initializing top level dir from instances
Browse files Browse the repository at this point in the history
The top level trace array is treated a little different than the
instances, as it has to deal with more of the general tracing.
The tr->dir is the tracing directory, which is an immutable
dentry, where as the tr->dir of instances are the dentry that
was created, and can be destroyed later. These should have different
functions accessing them.

As only tracing_init_dentry() deals with the top level array, fold
the code for it into that function, and remove the trace_init_dentry_tr()
that was also used by the instances to get their directory dentry.

Add a tracing_get_dentry() to just get the tracing dir entry for
instances as well as the top level array.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Feb 2, 2015
1 parent c602894 commit 7eeafbc
Showing 1 changed file with 30 additions and 21 deletions.
51 changes: 30 additions & 21 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5815,36 +5815,19 @@ static __init int register_snapshot_cmd(void)
static inline __init int register_snapshot_cmd(void) { return 0; }
#endif /* defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE) */

static struct dentry *tracing_init_dentry_tr(struct trace_array *tr)
static struct dentry *tracing_get_dentry(struct trace_array *tr)
{
if (tr->dir)
return tr->dir;

if (!debugfs_initialized())
return ERR_PTR(-ENODEV);

if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
tr->dir = debugfs_create_dir("tracing", NULL);

if (!tr->dir)
pr_warn_once("Could not create debugfs directory 'tracing'\n");

return tr->dir;
}

struct dentry *tracing_init_dentry(void)
{
return tracing_init_dentry_tr(&global_trace);
}

static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
{
struct dentry *d_tracer;

if (tr->percpu_dir)
return tr->percpu_dir;

d_tracer = tracing_init_dentry_tr(tr);
d_tracer = tracing_get_dentry(tr);
if (IS_ERR(d_tracer))
return NULL;

Expand Down Expand Up @@ -6047,7 +6030,7 @@ static struct dentry *trace_options_init_dentry(struct trace_array *tr)
if (tr->options)
return tr->options;

d_tracer = tracing_init_dentry_tr(tr);
d_tracer = tracing_get_dentry(tr);
if (IS_ERR(d_tracer))
return NULL;

Expand Down Expand Up @@ -6532,6 +6515,33 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)

}

/**
* tracing_init_dentry - initialize top level trace array
*
* This is called when creating files or directories in the tracing
* directory. It is called via fs_initcall() by any of the boot up code
* and expects to return the dentry of the top level tracing directory.
*/
struct dentry *tracing_init_dentry(void)
{
struct trace_array *tr = &global_trace;

if (tr->dir)
return tr->dir;

if (WARN_ON(!debugfs_initialized()))
return ERR_PTR(-ENODEV);

tr->dir = debugfs_create_dir("tracing", NULL);

if (!tr->dir) {
pr_warn_once("Could not create debugfs directory 'tracing'\n");
return ERR_PTR(-ENOMEM);
}

return tr->dir;
}

static __init int tracer_init_debugfs(void)
{
struct dentry *d_tracer;
Expand Down Expand Up @@ -6772,7 +6782,6 @@ __init static int tracer_alloc_buffers(void)
int ring_buf_size;
int ret = -ENOMEM;


if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
goto out;

Expand Down

0 comments on commit 7eeafbc

Please sign in to comment.