aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-03-26 19:25:38 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-07 08:43:07 -0400
commit5452af664f6fba26b80eb2c8c4ceae2999d5cf56 (patch)
tree08fb64bfc3242ad96b65719a55424db729585f17 /kernel/trace/trace.c
parenta5dec5573f3c7e63f2f9b5852b9759ea342a5ff9 (diff)
tracing/ftrace: factorize the tracing files creation
Impact: cleanup Most of the tracing files creation follow the same pattern: ret = debugfs_create_file(...) if (!ret) pr_warning("Couldn't create ... entry\n") Unify it! Reported-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <1238109938-11840-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c159
1 files changed, 62 insertions, 97 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 32653c8c6e26..0615751a3ed7 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3581,7 +3581,7 @@ struct dentry *tracing_dentry_percpu(void)
3581static void tracing_init_debugfs_percpu(long cpu) 3581static void tracing_init_debugfs_percpu(long cpu)
3582{ 3582{
3583 struct dentry *d_percpu = tracing_dentry_percpu(); 3583 struct dentry *d_percpu = tracing_dentry_percpu();
3584 struct dentry *entry, *d_cpu; 3584 struct dentry *d_cpu;
3585 /* strlen(cpu) + MAX(log10(cpu)) + '\0' */ 3585 /* strlen(cpu) + MAX(log10(cpu)) + '\0' */
3586 char cpu_dir[7]; 3586 char cpu_dir[7];
3587 3587
@@ -3596,21 +3596,15 @@ static void tracing_init_debugfs_percpu(long cpu)
3596 } 3596 }
3597 3597
3598 /* per cpu trace_pipe */ 3598 /* per cpu trace_pipe */
3599 entry = debugfs_create_file("trace_pipe", 0444, d_cpu, 3599 trace_create_file("trace_pipe", 0444, d_cpu,
3600 (void *) cpu, &tracing_pipe_fops); 3600 (void *) cpu, &tracing_pipe_fops);
3601 if (!entry)
3602 pr_warning("Could not create debugfs 'trace_pipe' entry\n");
3603 3601
3604 /* per cpu trace */ 3602 /* per cpu trace */
3605 entry = debugfs_create_file("trace", 0644, d_cpu, 3603 trace_create_file("trace", 0644, d_cpu,
3606 (void *) cpu, &tracing_fops); 3604 (void *) cpu, &tracing_fops);
3607 if (!entry)
3608 pr_warning("Could not create debugfs 'trace' entry\n");
3609 3605
3610 entry = debugfs_create_file("trace_pipe_raw", 0444, d_cpu, 3606 trace_create_file("trace_pipe_raw", 0444, d_cpu,
3611 (void *) cpu, &tracing_buffers_fops); 3607 (void *) cpu, &tracing_buffers_fops);
3612 if (!entry)
3613 pr_warning("Could not create debugfs 'trace_pipe_raw' entry\n");
3614} 3608}
3615 3609
3616#ifdef CONFIG_FTRACE_SELFTEST 3610#ifdef CONFIG_FTRACE_SELFTEST
@@ -3766,6 +3760,22 @@ static const struct file_operations trace_options_core_fops = {
3766 .write = trace_options_core_write, 3760 .write = trace_options_core_write,
3767}; 3761};
3768 3762
3763struct dentry *trace_create_file(const char *name,
3764 mode_t mode,
3765 struct dentry *parent,
3766 void *data,
3767 const struct file_operations *fops)
3768{
3769 struct dentry *ret;
3770
3771 ret = debugfs_create_file(name, mode, parent, data, fops);
3772 if (!ret)
3773 pr_warning("Could not create debugfs '%s' entry\n", name);
3774
3775 return ret;
3776}
3777
3778
3769static struct dentry *trace_options_init_dentry(void) 3779static struct dentry *trace_options_init_dentry(void)
3770{ 3780{
3771 struct dentry *d_tracer; 3781 struct dentry *d_tracer;
@@ -3793,7 +3803,6 @@ create_trace_option_file(struct trace_option_dentry *topt,
3793 struct tracer_opt *opt) 3803 struct tracer_opt *opt)
3794{ 3804{
3795 struct dentry *t_options; 3805 struct dentry *t_options;
3796 struct dentry *entry;
3797 3806
3798 t_options = trace_options_init_dentry(); 3807 t_options = trace_options_init_dentry();
3799 if (!t_options) 3808 if (!t_options)
@@ -3802,11 +3811,9 @@ create_trace_option_file(struct trace_option_dentry *topt,
3802 topt->flags = flags; 3811 topt->flags = flags;
3803 topt->opt = opt; 3812 topt->opt = opt;
3804 3813
3805 entry = debugfs_create_file(opt->name, 0644, t_options, topt, 3814 topt->entry = trace_create_file(opt->name, 0644, t_options, topt,
3806 &trace_options_fops); 3815 &trace_options_fops);
3807 3816
3808 topt->entry = entry;
3809
3810} 3817}
3811 3818
3812static struct trace_option_dentry * 3819static struct trace_option_dentry *
@@ -3861,123 +3868,81 @@ static struct dentry *
3861create_trace_option_core_file(const char *option, long index) 3868create_trace_option_core_file(const char *option, long index)
3862{ 3869{
3863 struct dentry *t_options; 3870 struct dentry *t_options;
3864 struct dentry *entry;
3865 3871
3866 t_options = trace_options_init_dentry(); 3872 t_options = trace_options_init_dentry();
3867 if (!t_options) 3873 if (!t_options)
3868 return NULL; 3874 return NULL;
3869 3875
3870 entry = debugfs_create_file(option, 0644, t_options, (void *)index, 3876 return trace_create_file(option, 0644, t_options, (void *)index,
3871 &trace_options_core_fops); 3877 &trace_options_core_fops);
3872
3873 return entry;
3874} 3878}
3875 3879
3876static __init void create_trace_options_dir(void) 3880static __init void create_trace_options_dir(void)
3877{ 3881{
3878 struct dentry *t_options; 3882 struct dentry *t_options;
3879 struct dentry *entry;
3880 int i; 3883 int i;
3881 3884
3882 t_options = trace_options_init_dentry(); 3885 t_options = trace_options_init_dentry();
3883 if (!t_options) 3886 if (!t_options)
3884 return; 3887 return;
3885 3888
3886 for (i = 0; trace_options[i]; i++) { 3889 for (i = 0; trace_options[i]; i++)
3887 entry = create_trace_option_core_file(trace_options[i], i); 3890 create_trace_option_core_file(trace_options[i], i);
3888 if (!entry)
3889 pr_warning("Could not create debugfs %s entry\n",
3890 trace_options[i]);
3891 }
3892} 3891}
3893 3892
3894static __init int tracer_init_debugfs(void) 3893static __init int tracer_init_debugfs(void)
3895{ 3894{
3896 struct dentry *d_tracer; 3895 struct dentry *d_tracer;
3897 struct dentry *entry;
3898 int cpu; 3896 int cpu;
3899 3897
3900 d_tracer = tracing_init_dentry(); 3898 d_tracer = tracing_init_dentry();
3901 3899
3902 entry = debugfs_create_file("tracing_enabled", 0644, d_tracer, 3900 trace_create_file("tracing_enabled", 0644, d_tracer,
3903 &global_trace, &tracing_ctrl_fops); 3901 &global_trace, &tracing_ctrl_fops);
3904 if (!entry)
3905 pr_warning("Could not create debugfs 'tracing_enabled' entry\n");
3906 3902
3907 entry = debugfs_create_file("trace_options", 0644, d_tracer, 3903 trace_create_file("trace_options", 0644, d_tracer,
3908 NULL, &tracing_iter_fops); 3904 NULL, &tracing_iter_fops);
3909 if (!entry)
3910 pr_warning("Could not create debugfs 'trace_options' entry\n");
3911 3905
3912 create_trace_options_dir(); 3906 trace_create_file("tracing_cpumask", 0644, d_tracer,
3907 NULL, &tracing_cpumask_fops);
3908
3909 trace_create_file("trace", 0644, d_tracer,
3910 (void *) TRACE_PIPE_ALL_CPU, &tracing_fops);
3911
3912 trace_create_file("available_tracers", 0444, d_tracer,
3913 &global_trace, &show_traces_fops);
3914
3915 trace_create_file("current_tracer", 0444, d_tracer,
3916 &global_trace, &set_tracer_fops);
3917
3918 trace_create_file("tracing_max_latency", 0644, d_tracer,
3919 &tracing_max_latency, &tracing_max_lat_fops);
3920
3921 trace_create_file("tracing_thresh", 0644, d_tracer,
3922 &tracing_thresh, &tracing_max_lat_fops);
3913 3923
3914 entry = debugfs_create_file("tracing_cpumask", 0644, d_tracer, 3924 trace_create_file("README", 0644, d_tracer,
3915 NULL, &tracing_cpumask_fops); 3925 NULL, &tracing_readme_fops);
3916 if (!entry) 3926
3917 pr_warning("Could not create debugfs 'tracing_cpumask' entry\n"); 3927 trace_create_file("trace_pipe", 0444, d_tracer,
3918
3919 entry = debugfs_create_file("trace", 0644, d_tracer,
3920 (void *) TRACE_PIPE_ALL_CPU, &tracing_fops);
3921 if (!entry)
3922 pr_warning("Could not create debugfs 'trace' entry\n");
3923
3924 entry = debugfs_create_file("available_tracers", 0444, d_tracer,
3925 &global_trace, &show_traces_fops);
3926 if (!entry)
3927 pr_warning("Could not create debugfs 'available_tracers' entry\n");
3928
3929 entry = debugfs_create_file("current_tracer", 0444, d_tracer,
3930 &global_trace, &set_tracer_fops);
3931 if (!entry)
3932 pr_warning("Could not create debugfs 'current_tracer' entry\n");
3933
3934 entry = debugfs_create_file("tracing_max_latency", 0644, d_tracer,
3935 &tracing_max_latency,
3936 &tracing_max_lat_fops);
3937 if (!entry)
3938 pr_warning("Could not create debugfs "
3939 "'tracing_max_latency' entry\n");
3940
3941 entry = debugfs_create_file("tracing_thresh", 0644, d_tracer,
3942 &tracing_thresh, &tracing_max_lat_fops);
3943 if (!entry)
3944 pr_warning("Could not create debugfs "
3945 "'tracing_thresh' entry\n");
3946 entry = debugfs_create_file("README", 0644, d_tracer,
3947 NULL, &tracing_readme_fops);
3948 if (!entry)
3949 pr_warning("Could not create debugfs 'README' entry\n");
3950
3951 entry = debugfs_create_file("trace_pipe", 0444, d_tracer,
3952 (void *) TRACE_PIPE_ALL_CPU, &tracing_pipe_fops); 3928 (void *) TRACE_PIPE_ALL_CPU, &tracing_pipe_fops);
3953 if (!entry) 3929
3954 pr_warning("Could not create debugfs " 3930 trace_create_file("buffer_size_kb", 0644, d_tracer,
3955 "'trace_pipe' entry\n"); 3931 &global_trace, &tracing_entries_fops);
3956 3932
3957 entry = debugfs_create_file("buffer_size_kb", 0644, d_tracer, 3933 trace_create_file("trace_marker", 0220, d_tracer,
3958 &global_trace, &tracing_entries_fops); 3934 NULL, &tracing_mark_fops);
3959 if (!entry)
3960 pr_warning("Could not create debugfs "
3961 "'buffer_size_kb' entry\n");
3962
3963 entry = debugfs_create_file("trace_marker", 0220, d_tracer,
3964 NULL, &tracing_mark_fops);
3965 if (!entry)
3966 pr_warning("Could not create debugfs "
3967 "'trace_marker' entry\n");
3968 3935
3969#ifdef CONFIG_DYNAMIC_FTRACE 3936#ifdef CONFIG_DYNAMIC_FTRACE
3970 entry = debugfs_create_file("dyn_ftrace_total_info", 0444, d_tracer, 3937 trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
3971 &ftrace_update_tot_cnt, 3938 &ftrace_update_tot_cnt, &tracing_dyn_info_fops);
3972 &tracing_dyn_info_fops);
3973 if (!entry)
3974 pr_warning("Could not create debugfs "
3975 "'dyn_ftrace_total_info' entry\n");
3976#endif 3939#endif
3977#ifdef CONFIG_SYSPROF_TRACER 3940#ifdef CONFIG_SYSPROF_TRACER
3978 init_tracer_sysprof_debugfs(d_tracer); 3941 init_tracer_sysprof_debugfs(d_tracer);
3979#endif 3942#endif
3980 3943
3944 create_trace_options_dir();
3945
3981 for_each_tracing_cpu(cpu) 3946 for_each_tracing_cpu(cpu)
3982 tracing_init_debugfs_percpu(cpu); 3947 tracing_init_debugfs_percpu(cpu);
3983 3948