aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-01-26 21:00:48 -0500
committerSteven Rostedt <rostedt@goodmis.org>2015-02-02 10:22:34 -0500
commit7eeafbcab47fe9860e5106286db83d60e3f35644 (patch)
treeb60a82740520c4ef85c05c7273cf84f98d6384dd /kernel
parentc602894814adc93589dde028182101818c5f938b (diff)
tracing: Separate out initializing top level dir from instances
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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 2668a0d742ee..5afce60e1b68 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -5815,28 +5815,11 @@ static __init int register_snapshot_cmd(void)
5815static inline __init int register_snapshot_cmd(void) { return 0; } 5815static inline __init int register_snapshot_cmd(void) { return 0; }
5816#endif /* defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE) */ 5816#endif /* defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE) */
5817 5817
5818static struct dentry *tracing_init_dentry_tr(struct trace_array *tr) 5818static struct dentry *tracing_get_dentry(struct trace_array *tr)
5819{ 5819{
5820 if (tr->dir)
5821 return tr->dir;
5822
5823 if (!debugfs_initialized())
5824 return ERR_PTR(-ENODEV);
5825
5826 if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
5827 tr->dir = debugfs_create_dir("tracing", NULL);
5828
5829 if (!tr->dir)
5830 pr_warn_once("Could not create debugfs directory 'tracing'\n");
5831
5832 return tr->dir; 5820 return tr->dir;
5833} 5821}
5834 5822
5835struct dentry *tracing_init_dentry(void)
5836{
5837 return tracing_init_dentry_tr(&global_trace);
5838}
5839
5840static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu) 5823static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
5841{ 5824{
5842 struct dentry *d_tracer; 5825 struct dentry *d_tracer;
@@ -5844,7 +5827,7 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
5844 if (tr->percpu_dir) 5827 if (tr->percpu_dir)
5845 return tr->percpu_dir; 5828 return tr->percpu_dir;
5846 5829
5847 d_tracer = tracing_init_dentry_tr(tr); 5830 d_tracer = tracing_get_dentry(tr);
5848 if (IS_ERR(d_tracer)) 5831 if (IS_ERR(d_tracer))
5849 return NULL; 5832 return NULL;
5850 5833
@@ -6047,7 +6030,7 @@ static struct dentry *trace_options_init_dentry(struct trace_array *tr)
6047 if (tr->options) 6030 if (tr->options)
6048 return tr->options; 6031 return tr->options;
6049 6032
6050 d_tracer = tracing_init_dentry_tr(tr); 6033 d_tracer = tracing_get_dentry(tr);
6051 if (IS_ERR(d_tracer)) 6034 if (IS_ERR(d_tracer))
6052 return NULL; 6035 return NULL;
6053 6036
@@ -6532,6 +6515,33 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
6532 6515
6533} 6516}
6534 6517
6518/**
6519 * tracing_init_dentry - initialize top level trace array
6520 *
6521 * This is called when creating files or directories in the tracing
6522 * directory. It is called via fs_initcall() by any of the boot up code
6523 * and expects to return the dentry of the top level tracing directory.
6524 */
6525struct dentry *tracing_init_dentry(void)
6526{
6527 struct trace_array *tr = &global_trace;
6528
6529 if (tr->dir)
6530 return tr->dir;
6531
6532 if (WARN_ON(!debugfs_initialized()))
6533 return ERR_PTR(-ENODEV);
6534
6535 tr->dir = debugfs_create_dir("tracing", NULL);
6536
6537 if (!tr->dir) {
6538 pr_warn_once("Could not create debugfs directory 'tracing'\n");
6539 return ERR_PTR(-ENOMEM);
6540 }
6541
6542 return tr->dir;
6543}
6544
6535static __init int tracer_init_debugfs(void) 6545static __init int tracer_init_debugfs(void)
6536{ 6546{
6537 struct dentry *d_tracer; 6547 struct dentry *d_tracer;
@@ -6772,7 +6782,6 @@ __init static int tracer_alloc_buffers(void)
6772 int ring_buf_size; 6782 int ring_buf_size;
6773 int ret = -ENOMEM; 6783 int ret = -ENOMEM;
6774 6784
6775
6776 if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL)) 6785 if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
6777 goto out; 6786 goto out;
6778 6787