]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tracing: Convert the tracing facility over to use tracefs
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>
Tue, 20 Jan 2015 17:13:40 +0000 (12:13 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 3 Feb 2015 17:48:41 +0000 (12:48 -0500)
debugfs was fine for the tracing facility as a quick way to get
an interface. Now that tracing has matured, it should separate itself
from debugfs such that it can be mounted separately without needing
to mount all of debugfs with it. That is, users resist using tracing
because it requires mounting debugfs. Having tracing have its own file
system lets users get the features of tracing without needing to bring
in the rest of the kernel's debug infrastructure.

Another reason for tracefs is that debubfs does not support mkdir.
Currently, to create instances, one does a mkdir in the tracing/instance
directory. This is implemented via a hack that forces debugfs to do
something it is not intended on doing. By converting over to tracefs, this
hack can be removed and mkdir can be properly implemented. This patch does
not address this yet, but it lays the ground work for that to be done.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_events.c
kernel/trace/trace_functions_graph.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_probe.h
kernel/trace/trace_stat.c

index 45e5cb143d173d979576689dbc8e7a66703eee06..fcc0e7052a79de9c6c921e0a17db37be126f6e9c 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/kallsyms.h>
 #include <linux/seq_file.h>
 #include <linux/suspend.h>
-#include <linux/debugfs.h>
+#include <linux/tracefs.h>
 #include <linux/hardirq.h>
 #include <linux/kthread.h>
 #include <linux/uaccess.h>
@@ -1008,7 +1008,7 @@ static struct tracer_stat function_stats __initdata = {
        .stat_show      = function_stat_show
 };
 
-static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
+static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
 {
        struct ftrace_profile_stat *stat;
        struct dentry *entry;
@@ -1044,15 +1044,15 @@ static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
                }
        }
 
-       entry = debugfs_create_file("function_profile_enabled", 0644,
+       entry = tracefs_create_file("function_profile_enabled", 0644,
                                    d_tracer, NULL, &ftrace_profile_fops);
        if (!entry)
-               pr_warning("Could not create debugfs "
+               pr_warning("Could not create tracefs "
                           "'function_profile_enabled' entry\n");
 }
 
 #else /* CONFIG_FUNCTION_PROFILER */
-static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
+static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
 {
 }
 #endif /* CONFIG_FUNCTION_PROFILER */
@@ -4690,7 +4690,7 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops)
        mutex_unlock(&ftrace_lock);
 }
 
-static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer)
+static __init int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
 {
 
        trace_create_file("available_filter_functions", 0444,
@@ -4998,7 +4998,7 @@ static int __init ftrace_nodyn_init(void)
 }
 core_initcall(ftrace_nodyn_init);
 
-static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; }
+static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; }
 static inline void ftrace_startup_enable(int command) { }
 static inline void ftrace_startup_all(int command) { }
 /* Keep as macros so we do not need to define the commands */
@@ -5451,7 +5451,7 @@ static const struct file_operations ftrace_pid_fops = {
        .release        = ftrace_pid_release,
 };
 
-static __init int ftrace_init_debugfs(void)
+static __init int ftrace_init_tracefs(void)
 {
        struct dentry *d_tracer;
 
@@ -5459,16 +5459,16 @@ static __init int ftrace_init_debugfs(void)
        if (IS_ERR(d_tracer))
                return 0;
 
-       ftrace_init_dyn_debugfs(d_tracer);
+       ftrace_init_dyn_tracefs(d_tracer);
 
        trace_create_file("set_ftrace_pid", 0644, d_tracer,
                            NULL, &ftrace_pid_fops);
 
-       ftrace_profile_debugfs(d_tracer);
+       ftrace_profile_tracefs(d_tracer);
 
        return 0;
 }
-fs_initcall(ftrace_init_debugfs);
+fs_initcall(ftrace_init_tracefs);
 
 /**
  * ftrace_kill - kill ftrace
index 05e0e50539fccad2e4526541020dc37907b79077..6c4739bee4bb96ef8807eb4baaa4683adf06518f 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/notifier.h>
 #include <linux/irqflags.h>
 #include <linux/debugfs.h>
+#include <linux/tracefs.h>
 #include <linux/pagemap.h>
 #include <linux/hardirq.h>
 #include <linux/linkage.h>
@@ -5828,6 +5829,14 @@ static inline __init int register_snapshot_cmd(void) { return 0; }
 
 static struct dentry *tracing_get_dentry(struct trace_array *tr)
 {
+       if (WARN_ON(!tr->dir))
+               return ERR_PTR(-ENODEV);
+
+       /* Top directory uses NULL as the parent */
+       if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
+               return NULL;
+
+       /* All sub buffers have a descriptor */
        return tr->dir;
 }
 
@@ -5842,10 +5851,10 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
        if (IS_ERR(d_tracer))
                return NULL;
 
-       tr->percpu_dir = debugfs_create_dir("per_cpu", d_tracer);
+       tr->percpu_dir = tracefs_create_dir("per_cpu", d_tracer);
 
        WARN_ONCE(!tr->percpu_dir,
-                 "Could not create debugfs directory 'per_cpu/%d'\n", cpu);
+                 "Could not create tracefs directory 'per_cpu/%d'\n", cpu);
 
        return tr->percpu_dir;
 }
@@ -5862,7 +5871,7 @@ trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
 }
 
 static void
-tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
+tracing_init_tracefs_percpu(struct trace_array *tr, long cpu)
 {
        struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu);
        struct dentry *d_cpu;
@@ -5872,9 +5881,9 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
                return;
 
        snprintf(cpu_dir, 30, "cpu%ld", cpu);
-       d_cpu = debugfs_create_dir(cpu_dir, d_percpu);
+       d_cpu = tracefs_create_dir(cpu_dir, d_percpu);
        if (!d_cpu) {
-               pr_warning("Could not create debugfs '%s' entry\n", cpu_dir);
+               pr_warning("Could not create tracefs '%s' entry\n", cpu_dir);
                return;
        }
 
@@ -6026,9 +6035,9 @@ struct dentry *trace_create_file(const char *name,
 {
        struct dentry *ret;
 
-       ret = debugfs_create_file(name, mode, parent, data, fops);
+       ret = tracefs_create_file(name, mode, parent, data, fops);
        if (!ret)
-               pr_warning("Could not create debugfs '%s' entry\n", name);
+               pr_warning("Could not create tracefs '%s' entry\n", name);
 
        return ret;
 }
@@ -6045,9 +6054,9 @@ static struct dentry *trace_options_init_dentry(struct trace_array *tr)
        if (IS_ERR(d_tracer))
                return NULL;
 
-       tr->options = debugfs_create_dir("options", d_tracer);
+       tr->options = tracefs_create_dir("options", d_tracer);
        if (!tr->options) {
-               pr_warning("Could not create debugfs directory 'options'\n");
+               pr_warning("Could not create tracefs directory 'options'\n");
                return NULL;
        }
 
@@ -6116,7 +6125,7 @@ destroy_trace_option_files(struct trace_option_dentry *topts)
                return;
 
        for (cnt = 0; topts[cnt].opt; cnt++)
-               debugfs_remove(topts[cnt].entry);
+               tracefs_remove(topts[cnt].entry);
 
        kfree(topts);
 }
@@ -6205,7 +6214,7 @@ static const struct file_operations rb_simple_fops = {
 struct dentry *trace_instance_dir;
 
 static void
-init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer);
+init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer);
 
 static int
 allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size)
@@ -6321,17 +6330,17 @@ static int new_instance_create(const char *name)
        if (allocate_trace_buffers(tr, trace_buf_size) < 0)
                goto out_free_tr;
 
-       tr->dir = debugfs_create_dir(name, trace_instance_dir);
+       tr->dir = tracefs_create_dir(name, trace_instance_dir);
        if (!tr->dir)
                goto out_free_tr;
 
        ret = event_trace_add_tracer(tr->dir, tr);
        if (ret) {
-               debugfs_remove_recursive(tr->dir);
+               tracefs_remove_recursive(tr->dir);
                goto out_free_tr;
        }
 
-       init_tracer_debugfs(tr, tr->dir);
+       init_tracer_tracefs(tr, tr->dir);
 
        list_add(&tr->list, &ftrace_trace_arrays);
 
@@ -6404,7 +6413,7 @@ static int instance_mkdir (struct inode *inode, struct dentry *dentry, umode_t m
                return -ENOENT;
 
        /*
-        * The inode mutex is locked, but debugfs_create_dir() will also
+        * The inode mutex is locked, but tracefs_create_dir() will also
         * take the mutex. As the instances directory can not be destroyed
         * or changed in any other way, it is safe to unlock it, and
         * let the dentry try. If two users try to make the same dir at
@@ -6434,7 +6443,7 @@ static int instance_rmdir(struct inode *inode, struct dentry *dentry)
        mutex_unlock(&dentry->d_inode->i_mutex);
 
        /*
-        * The inode mutex is locked, but debugfs_create_dir() will also
+        * The inode mutex is locked, but tracefs_create_dir() will also
         * take the mutex. As the instances directory can not be destroyed
         * or changed in any other way, it is safe to unlock it, and
         * let the dentry try. If two users try to make the same dir at
@@ -6459,7 +6468,7 @@ static const struct inode_operations instance_dir_inode_operations = {
 
 static __init void create_trace_instances(struct dentry *d_tracer)
 {
-       trace_instance_dir = debugfs_create_dir("instances", d_tracer);
+       trace_instance_dir = tracefs_create_dir("instances", d_tracer);
        if (WARN_ON(!trace_instance_dir))
                return;
 
@@ -6468,7 +6477,7 @@ static __init void create_trace_instances(struct dentry *d_tracer)
 }
 
 static void
-init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
+init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
 {
        int cpu;
 
@@ -6522,7 +6531,7 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
 #endif
 
        for_each_tracing_cpu(cpu)
-               tracing_init_debugfs_percpu(tr, cpu);
+               tracing_init_tracefs_percpu(tr, cpu);
 
 }
 
@@ -6550,10 +6559,10 @@ struct dentry *tracing_init_dentry(void)
                return ERR_PTR(-ENOMEM);
        }
 
-       return tr->dir;
+       return NULL;
 }
 
-static __init int tracer_init_debugfs(void)
+static __init int tracer_init_tracefs(void)
 {
        struct dentry *d_tracer;
 
@@ -6563,7 +6572,7 @@ static __init int tracer_init_debugfs(void)
        if (IS_ERR(d_tracer))
                return 0;
 
-       init_tracer_debugfs(&global_trace, d_tracer);
+       init_tracer_tracefs(&global_trace, d_tracer);
 
        trace_create_file("tracing_thresh", 0644, d_tracer,
                        &global_trace, &tracing_thresh_fops);
@@ -6925,5 +6934,5 @@ __init static int clear_boot_tracer(void)
        return 0;
 }
 
-fs_initcall(tracer_init_debugfs);
+fs_initcall(tracer_init_tracefs);
 late_initcall(clear_boot_tracer);
index dd8205a35760d7a4b8bf53543f52abd0f1f9a6aa..d951deddec89af0cae6160bc32d65ec3d4fa72d8 100644 (file)
@@ -334,7 +334,7 @@ struct tracer_flags {
 
 
 /**
- * struct tracer - a specific tracer and its callbacks to interact with debugfs
+ * struct tracer - a specific tracer and its callbacks to interact with tracefs
  * @name: the name chosen to select it on the available_tracers file
  * @init: called when one switches to this tracer (echo name > current_tracer)
  * @reset: called when one switches to another tracer
index db54dda10ccc179f733db8fd8407cc402c11e409..0d2e47370ee7ae305e24b903a01e5e3ee95c5ccd 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/workqueue.h>
 #include <linux/spinlock.h>
 #include <linux/kthread.h>
-#include <linux/debugfs.h>
+#include <linux/tracefs.h>
 #include <linux/uaccess.h>
 #include <linux/module.h>
 #include <linux/ctype.h>
@@ -480,7 +480,7 @@ static void remove_subsystem(struct ftrace_subsystem_dir *dir)
                return;
 
        if (!--dir->nr_events) {
-               debugfs_remove_recursive(dir->entry);
+               tracefs_remove_recursive(dir->entry);
                list_del(&dir->list);
                __put_system_dir(dir);
        }
@@ -499,7 +499,7 @@ static void remove_event_file_dir(struct ftrace_event_file *file)
                }
                spin_unlock(&dir->d_lock);
 
-               debugfs_remove_recursive(dir);
+               tracefs_remove_recursive(dir);
        }
 
        list_del(&file->list);
@@ -1526,7 +1526,7 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
        } else
                __get_system(system);
 
-       dir->entry = debugfs_create_dir(name, parent);
+       dir->entry = tracefs_create_dir(name, parent);
        if (!dir->entry) {
                pr_warn("Failed to create system directory %s\n", name);
                __put_system(system);
@@ -1539,12 +1539,12 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
        dir->subsystem = system;
        file->system = dir;
 
-       entry = debugfs_create_file("filter", 0644, dir->entry, dir,
+       entry = tracefs_create_file("filter", 0644, dir->entry, dir,
                                    &ftrace_subsystem_filter_fops);
        if (!entry) {
                kfree(system->filter);
                system->filter = NULL;
-               pr_warn("Could not create debugfs '%s/filter' entry\n", name);
+               pr_warn("Could not create tracefs '%s/filter' entry\n", name);
        }
 
        trace_create_file("enable", 0644, dir->entry, dir,
@@ -1585,9 +1585,9 @@ event_create_dir(struct dentry *parent, struct ftrace_event_file *file)
                d_events = parent;
 
        name = ftrace_event_name(call);
-       file->dir = debugfs_create_dir(name, d_events);
+       file->dir = tracefs_create_dir(name, d_events);
        if (!file->dir) {
-               pr_warn("Could not create debugfs '%s' directory\n", name);
+               pr_warn("Could not create tracefs '%s' directory\n", name);
                return -1;
        }
 
@@ -2228,7 +2228,7 @@ static inline int register_event_cmds(void) { return 0; }
 /*
  * The top level array has already had its ftrace_event_file
  * descriptors created in order to allow for early events to
- * be recorded. This function is called after the debugfs has been
+ * be recorded. This function is called after the tracefs has been
  * initialized, and we now have to create the files associated
  * to the events.
  */
@@ -2311,16 +2311,16 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr)
        struct dentry *d_events;
        struct dentry *entry;
 
-       entry = debugfs_create_file("set_event", 0644, parent,
+       entry = tracefs_create_file("set_event", 0644, parent,
                                    tr, &ftrace_set_event_fops);
        if (!entry) {
-               pr_warn("Could not create debugfs 'set_event' entry\n");
+               pr_warn("Could not create tracefs 'set_event' entry\n");
                return -ENOMEM;
        }
 
-       d_events = debugfs_create_dir("events", parent);
+       d_events = tracefs_create_dir("events", parent);
        if (!d_events) {
-               pr_warn("Could not create debugfs 'events' directory\n");
+               pr_warn("Could not create tracefs 'events' directory\n");
                return -ENOMEM;
        }
 
@@ -2412,7 +2412,7 @@ int event_trace_del_tracer(struct trace_array *tr)
 
        down_write(&trace_event_sem);
        __trace_remove_event_dirs(tr);
-       debugfs_remove_recursive(tr->event_dir);
+       tracefs_remove_recursive(tr->event_dir);
        up_write(&trace_event_sem);
 
        tr->event_dir = NULL;
@@ -2534,10 +2534,10 @@ static __init int event_trace_init(void)
        if (IS_ERR(d_tracer))
                return 0;
 
-       entry = debugfs_create_file("available_events", 0444, d_tracer,
+       entry = tracefs_create_file("available_events", 0444, d_tracer,
                                    tr, &ftrace_avail_fops);
        if (!entry)
-               pr_warn("Could not create debugfs 'available_events' entry\n");
+               pr_warn("Could not create tracefs 'available_events' entry\n");
 
        if (trace_define_common_fields())
                pr_warn("tracing: Failed to allocate common fields");
index 2d25ad1526bb16f28e9f18f1d3b0edf2b7093341..9cfea4c6d314c6153d4986a55a89503671e2b1a4 100644 (file)
@@ -6,7 +6,6 @@
  * is Copyright (c) Steven Rostedt <srostedt@redhat.com>
  *
  */
-#include <linux/debugfs.h>
 #include <linux/uaccess.h>
 #include <linux/ftrace.h>
 #include <linux/slab.h>
@@ -151,7 +150,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
         * The curr_ret_stack is initialized to -1 and get increased
         * in this function.  So it can be less than -1 only if it was
         * filtered out via ftrace_graph_notrace_addr() which can be
-        * set from set_graph_notrace file in debugfs by user.
+        * set from set_graph_notrace file in tracefs by user.
         */
        if (current->curr_ret_stack < -1)
                return -EBUSY;
@@ -1432,7 +1431,7 @@ static const struct file_operations graph_depth_fops = {
        .llseek         = generic_file_llseek,
 };
 
-static __init int init_graph_debugfs(void)
+static __init int init_graph_tracefs(void)
 {
        struct dentry *d_tracer;
 
@@ -1445,7 +1444,7 @@ static __init int init_graph_debugfs(void)
 
        return 0;
 }
-fs_initcall(init_graph_debugfs);
+fs_initcall(init_graph_tracefs);
 
 static __init int init_graph_trace(void)
 {
index b4a00def88f5c5784e0d0a8ffd18edbfac694f23..c1c6655847c8a4af01eda670dd51c9170be72bac 100644 (file)
@@ -1310,7 +1310,7 @@ static int unregister_kprobe_event(struct trace_kprobe *tk)
        return ret;
 }
 
-/* Make a debugfs interface for controlling probe points */
+/* Make a tracefs interface for controlling probe points */
 static __init int init_kprobe_trace(void)
 {
        struct dentry *d_tracer;
@@ -1323,20 +1323,20 @@ static __init int init_kprobe_trace(void)
        if (IS_ERR(d_tracer))
                return 0;
 
-       entry = debugfs_create_file("kprobe_events", 0644, d_tracer,
+       entry = tracefs_create_file("kprobe_events", 0644, d_tracer,
                                    NULL, &kprobe_events_ops);
 
        /* Event list interface */
        if (!entry)
-               pr_warning("Could not create debugfs "
+               pr_warning("Could not create tracefs "
                           "'kprobe_events' entry\n");
 
        /* Profile interface */
-       entry = debugfs_create_file("kprobe_profile", 0444, d_tracer,
+       entry = tracefs_create_file("kprobe_profile", 0444, d_tracer,
                                    NULL, &kprobe_profile_ops);
 
        if (!entry)
-               pr_warning("Could not create debugfs "
+               pr_warning("Could not create tracefs "
                           "'kprobe_profile' entry\n");
        return 0;
 }
index 4f815fbce16d26eefbc8e3b572ec9f2fdca7879b..19aff635841a9a46954f18e4bd00c7bf63d73d5b 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/smp.h>
-#include <linux/debugfs.h>
+#include <linux/tracefs.h>
 #include <linux/types.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
index 75e19e86c9548044c3a6a712ca73b9bb02d74e50..6cf935316769630636b447f87e994dc89edf0b01 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/rbtree.h>
-#include <linux/debugfs.h>
+#include <linux/tracefs.h>
 #include "trace_stat.h"
 #include "trace.h"
 
@@ -65,7 +65,7 @@ static void reset_stat_session(struct stat_session *session)
 
 static void destroy_session(struct stat_session *session)
 {
-       debugfs_remove(session->file);
+       tracefs_remove(session->file);
        __reset_stat_session(session);
        mutex_destroy(&session->stat_mutex);
        kfree(session);
@@ -279,9 +279,9 @@ static int tracing_stat_init(void)
        if (IS_ERR(d_tracing))
                return 0;
 
-       stat_dir = debugfs_create_dir("trace_stat", d_tracing);
+       stat_dir = tracefs_create_dir("trace_stat", d_tracing);
        if (!stat_dir)
-               pr_warning("Could not create debugfs "
+               pr_warning("Could not create tracefs "
                           "'trace_stat' entry\n");
        return 0;
 }
@@ -291,7 +291,7 @@ static int init_stat_file(struct stat_session *session)
        if (!stat_dir && tracing_stat_init())
                return -ENODEV;
 
-       session->file = debugfs_create_file(session->ts->name, 0644,
+       session->file = tracefs_create_file(session->ts->name, 0644,
                                            stat_dir,
                                            session, &tracing_stat_fops);
        if (!session->file)