]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tracing: Separate out initializing top level dir from instances
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Tue, 27 Jan 2015 02:00:48 +0000 (21:00 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Mon, 2 Feb 2015 15:22:34 +0000 (10:22 -0500)
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>
kernel/trace/trace.c

index 2668a0d742eedaa0e1c7d9988bcc90f786fe4ba4..5afce60e1b68e46bca602eeaf87569064260b1c8 100644 (file)
@@ -5815,28 +5815,11 @@ 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;
@@ -5844,7 +5827,7 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
        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;
 
@@ -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;
 
@@ -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;
@@ -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;