aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 13:22:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 13:22:29 -0400
commit3f3c73de77b5598e9f87812ac4da9445090c3b4a (patch)
tree1b6ea5c10c273025c3d38dddda1975dc3d9a5070 /kernel
parent9497d7380b9c450830190c75aa43b25c278bb1f9 (diff)
parenteae473581cf93dad94ca833aa961c033c6a43924 (diff)
Merge tag 'trace-4.1-tracefs' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracefs from Steven Rostedt: "This adds the new tracefs file system. This has been in linux-next for more than one release, as I had it ready for the 4.0 merge window, but a last minute thing that needed to go into Linux first had to be done. That was that perf hard coded the file system number when reading /sys/kernel/debugfs/tracing directory making sure that the path had the debugfs mount # before it would parse the tracing file. This broke other use cases of perf, and the check is removed. Now when mounting /sys/kernel/debug, tracefs is automatically mounted in /sys/kernel/debug/tracing such that old tools will still see that path as expected. But now system admins can mount tracefs directly and not need to mount debugfs, which can expose security issues. A new directory is created when tracefs is configured such that system admins can now mount it separately (/sys/kernel/tracing)" * tag 'trace-4.1-tracefs' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Have mkdir and rmdir be part of tracefs tracefs: Add directory /sys/kernel/tracing tracing: Automatically mount tracefs on debugfs/tracing tracing: Convert the tracing facility over to use tracefs tracefs: Add new tracefs file system tracing: Create cmdline tracer options on tracing fs init tracing: Only create tracer options files if directory exists debugfs: Provide a file creation function that also takes an initial size
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/ftrace.c22
-rw-r--r--kernel/trace/trace.c187
-rw-r--r--kernel/trace/trace.h2
-rw-r--r--kernel/trace/trace_events.c32
-rw-r--r--kernel/trace/trace_functions_graph.c7
-rw-r--r--kernel/trace/trace_kprobe.c10
-rw-r--r--kernel/trace/trace_probe.h2
-rw-r--r--kernel/trace/trace_stat.c10
8 files changed, 130 insertions, 142 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4f228024055b..5a2e0b53af30 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -18,7 +18,7 @@
18#include <linux/kallsyms.h> 18#include <linux/kallsyms.h>
19#include <linux/seq_file.h> 19#include <linux/seq_file.h>
20#include <linux/suspend.h> 20#include <linux/suspend.h>
21#include <linux/debugfs.h> 21#include <linux/tracefs.h>
22#include <linux/hardirq.h> 22#include <linux/hardirq.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
@@ -1008,7 +1008,7 @@ static struct tracer_stat function_stats __initdata = {
1008 .stat_show = function_stat_show 1008 .stat_show = function_stat_show
1009}; 1009};
1010 1010
1011static __init void ftrace_profile_debugfs(struct dentry *d_tracer) 1011static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
1012{ 1012{
1013 struct ftrace_profile_stat *stat; 1013 struct ftrace_profile_stat *stat;
1014 struct dentry *entry; 1014 struct dentry *entry;
@@ -1044,15 +1044,15 @@ static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
1044 } 1044 }
1045 } 1045 }
1046 1046
1047 entry = debugfs_create_file("function_profile_enabled", 0644, 1047 entry = tracefs_create_file("function_profile_enabled", 0644,
1048 d_tracer, NULL, &ftrace_profile_fops); 1048 d_tracer, NULL, &ftrace_profile_fops);
1049 if (!entry) 1049 if (!entry)
1050 pr_warning("Could not create debugfs " 1050 pr_warning("Could not create tracefs "
1051 "'function_profile_enabled' entry\n"); 1051 "'function_profile_enabled' entry\n");
1052} 1052}
1053 1053
1054#else /* CONFIG_FUNCTION_PROFILER */ 1054#else /* CONFIG_FUNCTION_PROFILER */
1055static __init void ftrace_profile_debugfs(struct dentry *d_tracer) 1055static __init void ftrace_profile_tracefs(struct dentry *d_tracer)
1056{ 1056{
1057} 1057}
1058#endif /* CONFIG_FUNCTION_PROFILER */ 1058#endif /* CONFIG_FUNCTION_PROFILER */
@@ -4712,7 +4712,7 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops)
4712 mutex_unlock(&ftrace_lock); 4712 mutex_unlock(&ftrace_lock);
4713} 4713}
4714 4714
4715static __init int ftrace_init_dyn_debugfs(struct dentry *d_tracer) 4715static __init int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
4716{ 4716{
4717 4717
4718 trace_create_file("available_filter_functions", 0444, 4718 trace_create_file("available_filter_functions", 0444,
@@ -5020,7 +5020,7 @@ static int __init ftrace_nodyn_init(void)
5020} 5020}
5021core_initcall(ftrace_nodyn_init); 5021core_initcall(ftrace_nodyn_init);
5022 5022
5023static inline int ftrace_init_dyn_debugfs(struct dentry *d_tracer) { return 0; } 5023static inline int ftrace_init_dyn_tracefs(struct dentry *d_tracer) { return 0; }
5024static inline void ftrace_startup_enable(int command) { } 5024static inline void ftrace_startup_enable(int command) { }
5025static inline void ftrace_startup_all(int command) { } 5025static inline void ftrace_startup_all(int command) { }
5026/* Keep as macros so we do not need to define the commands */ 5026/* Keep as macros so we do not need to define the commands */
@@ -5473,7 +5473,7 @@ static const struct file_operations ftrace_pid_fops = {
5473 .release = ftrace_pid_release, 5473 .release = ftrace_pid_release,
5474}; 5474};
5475 5475
5476static __init int ftrace_init_debugfs(void) 5476static __init int ftrace_init_tracefs(void)
5477{ 5477{
5478 struct dentry *d_tracer; 5478 struct dentry *d_tracer;
5479 5479
@@ -5481,16 +5481,16 @@ static __init int ftrace_init_debugfs(void)
5481 if (IS_ERR(d_tracer)) 5481 if (IS_ERR(d_tracer))
5482 return 0; 5482 return 0;
5483 5483
5484 ftrace_init_dyn_debugfs(d_tracer); 5484 ftrace_init_dyn_tracefs(d_tracer);
5485 5485
5486 trace_create_file("set_ftrace_pid", 0644, d_tracer, 5486 trace_create_file("set_ftrace_pid", 0644, d_tracer,
5487 NULL, &ftrace_pid_fops); 5487 NULL, &ftrace_pid_fops);
5488 5488
5489 ftrace_profile_debugfs(d_tracer); 5489 ftrace_profile_tracefs(d_tracer);
5490 5490
5491 return 0; 5491 return 0;
5492} 5492}
5493fs_initcall(ftrace_init_debugfs); 5493fs_initcall(ftrace_init_tracefs);
5494 5494
5495/** 5495/**
5496 * ftrace_kill - kill ftrace 5496 * ftrace_kill - kill ftrace
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 62c6506d663f..bcfa2add6dda 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -20,6 +20,7 @@
20#include <linux/notifier.h> 20#include <linux/notifier.h>
21#include <linux/irqflags.h> 21#include <linux/irqflags.h>
22#include <linux/debugfs.h> 22#include <linux/debugfs.h>
23#include <linux/tracefs.h>
23#include <linux/pagemap.h> 24#include <linux/pagemap.h>
24#include <linux/hardirq.h> 25#include <linux/hardirq.h>
25#include <linux/linkage.h> 26#include <linux/linkage.h>
@@ -31,6 +32,7 @@
31#include <linux/splice.h> 32#include <linux/splice.h>
32#include <linux/kdebug.h> 33#include <linux/kdebug.h>
33#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/mount.h>
34#include <linux/rwsem.h> 36#include <linux/rwsem.h>
35#include <linux/slab.h> 37#include <linux/slab.h>
36#include <linux/ctype.h> 38#include <linux/ctype.h>
@@ -4105,9 +4107,24 @@ static void tracing_set_nop(struct trace_array *tr)
4105 tr->current_trace = &nop_trace; 4107 tr->current_trace = &nop_trace;
4106} 4108}
4107 4109
4108static int tracing_set_tracer(struct trace_array *tr, const char *buf) 4110static void update_tracer_options(struct trace_array *tr, struct tracer *t)
4109{ 4111{
4110 static struct trace_option_dentry *topts; 4112 static struct trace_option_dentry *topts;
4113
4114 /* Only enable if the directory has been created already. */
4115 if (!tr->dir)
4116 return;
4117
4118 /* Currently, only the top instance has options */
4119 if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL))
4120 return;
4121
4122 destroy_trace_option_files(topts);
4123 topts = create_trace_option_files(tr, t);
4124}
4125
4126static int tracing_set_tracer(struct trace_array *tr, const char *buf)
4127{
4111 struct tracer *t; 4128 struct tracer *t;
4112#ifdef CONFIG_TRACER_MAX_TRACE 4129#ifdef CONFIG_TRACER_MAX_TRACE
4113 bool had_max_tr; 4130 bool had_max_tr;
@@ -4172,11 +4189,7 @@ static int tracing_set_tracer(struct trace_array *tr, const char *buf)
4172 free_snapshot(tr); 4189 free_snapshot(tr);
4173 } 4190 }
4174#endif 4191#endif
4175 /* Currently, only the top instance has options */ 4192 update_tracer_options(tr, t);
4176 if (tr->flags & TRACE_ARRAY_FL_GLOBAL) {
4177 destroy_trace_option_files(topts);
4178 topts = create_trace_option_files(tr, t);
4179 }
4180 4193
4181#ifdef CONFIG_TRACER_MAX_TRACE 4194#ifdef CONFIG_TRACER_MAX_TRACE
4182 if (t->use_max_tr && !had_max_tr) { 4195 if (t->use_max_tr && !had_max_tr) {
@@ -5817,6 +5830,14 @@ static inline __init int register_snapshot_cmd(void) { return 0; }
5817 5830
5818static struct dentry *tracing_get_dentry(struct trace_array *tr) 5831static struct dentry *tracing_get_dentry(struct trace_array *tr)
5819{ 5832{
5833 if (WARN_ON(!tr->dir))
5834 return ERR_PTR(-ENODEV);
5835
5836 /* Top directory uses NULL as the parent */
5837 if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
5838 return NULL;
5839
5840 /* All sub buffers have a descriptor */
5820 return tr->dir; 5841 return tr->dir;
5821} 5842}
5822 5843
@@ -5831,10 +5852,10 @@ static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
5831 if (IS_ERR(d_tracer)) 5852 if (IS_ERR(d_tracer))
5832 return NULL; 5853 return NULL;
5833 5854
5834 tr->percpu_dir = debugfs_create_dir("per_cpu", d_tracer); 5855 tr->percpu_dir = tracefs_create_dir("per_cpu", d_tracer);
5835 5856
5836 WARN_ONCE(!tr->percpu_dir, 5857 WARN_ONCE(!tr->percpu_dir,
5837 "Could not create debugfs directory 'per_cpu/%d'\n", cpu); 5858 "Could not create tracefs directory 'per_cpu/%d'\n", cpu);
5838 5859
5839 return tr->percpu_dir; 5860 return tr->percpu_dir;
5840} 5861}
@@ -5851,7 +5872,7 @@ trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
5851} 5872}
5852 5873
5853static void 5874static void
5854tracing_init_debugfs_percpu(struct trace_array *tr, long cpu) 5875tracing_init_tracefs_percpu(struct trace_array *tr, long cpu)
5855{ 5876{
5856 struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu); 5877 struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu);
5857 struct dentry *d_cpu; 5878 struct dentry *d_cpu;
@@ -5861,9 +5882,9 @@ tracing_init_debugfs_percpu(struct trace_array *tr, long cpu)
5861 return; 5882 return;
5862 5883
5863 snprintf(cpu_dir, 30, "cpu%ld", cpu); 5884 snprintf(cpu_dir, 30, "cpu%ld", cpu);
5864 d_cpu = debugfs_create_dir(cpu_dir, d_percpu); 5885 d_cpu = tracefs_create_dir(cpu_dir, d_percpu);
5865 if (!d_cpu) { 5886 if (!d_cpu) {
5866 pr_warning("Could not create debugfs '%s' entry\n", cpu_dir); 5887 pr_warning("Could not create tracefs '%s' entry\n", cpu_dir);
5867 return; 5888 return;
5868 } 5889 }
5869 5890
@@ -6015,9 +6036,9 @@ struct dentry *trace_create_file(const char *name,
6015{ 6036{
6016 struct dentry *ret; 6037 struct dentry *ret;
6017 6038
6018 ret = debugfs_create_file(name, mode, parent, data, fops); 6039 ret = tracefs_create_file(name, mode, parent, data, fops);
6019 if (!ret) 6040 if (!ret)
6020 pr_warning("Could not create debugfs '%s' entry\n", name); 6041 pr_warning("Could not create tracefs '%s' entry\n", name);
6021 6042
6022 return ret; 6043 return ret;
6023} 6044}
@@ -6034,9 +6055,9 @@ static struct dentry *trace_options_init_dentry(struct trace_array *tr)
6034 if (IS_ERR(d_tracer)) 6055 if (IS_ERR(d_tracer))
6035 return NULL; 6056 return NULL;
6036 6057
6037 tr->options = debugfs_create_dir("options", d_tracer); 6058 tr->options = tracefs_create_dir("options", d_tracer);
6038 if (!tr->options) { 6059 if (!tr->options) {
6039 pr_warning("Could not create debugfs directory 'options'\n"); 6060 pr_warning("Could not create tracefs directory 'options'\n");
6040 return NULL; 6061 return NULL;
6041 } 6062 }
6042 6063
@@ -6105,7 +6126,7 @@ destroy_trace_option_files(struct trace_option_dentry *topts)
6105 return; 6126 return;
6106 6127
6107 for (cnt = 0; topts[cnt].opt; cnt++) 6128 for (cnt = 0; topts[cnt].opt; cnt++)
6108 debugfs_remove(topts[cnt].entry); 6129 tracefs_remove(topts[cnt].entry);
6109 6130
6110 kfree(topts); 6131 kfree(topts);
6111} 6132}
@@ -6194,7 +6215,7 @@ static const struct file_operations rb_simple_fops = {
6194struct dentry *trace_instance_dir; 6215struct dentry *trace_instance_dir;
6195 6216
6196static void 6217static void
6197init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer); 6218init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer);
6198 6219
6199static int 6220static int
6200allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size) 6221allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size)
@@ -6271,7 +6292,7 @@ static void free_trace_buffers(struct trace_array *tr)
6271#endif 6292#endif
6272} 6293}
6273 6294
6274static int new_instance_create(const char *name) 6295static int instance_mkdir(const char *name)
6275{ 6296{
6276 struct trace_array *tr; 6297 struct trace_array *tr;
6277 int ret; 6298 int ret;
@@ -6310,17 +6331,17 @@ static int new_instance_create(const char *name)
6310 if (allocate_trace_buffers(tr, trace_buf_size) < 0) 6331 if (allocate_trace_buffers(tr, trace_buf_size) < 0)
6311 goto out_free_tr; 6332 goto out_free_tr;
6312 6333
6313 tr->dir = debugfs_create_dir(name, trace_instance_dir); 6334 tr->dir = tracefs_create_dir(name, trace_instance_dir);
6314 if (!tr->dir) 6335 if (!tr->dir)
6315 goto out_free_tr; 6336 goto out_free_tr;
6316 6337
6317 ret = event_trace_add_tracer(tr->dir, tr); 6338 ret = event_trace_add_tracer(tr->dir, tr);
6318 if (ret) { 6339 if (ret) {
6319 debugfs_remove_recursive(tr->dir); 6340 tracefs_remove_recursive(tr->dir);
6320 goto out_free_tr; 6341 goto out_free_tr;
6321 } 6342 }
6322 6343
6323 init_tracer_debugfs(tr, tr->dir); 6344 init_tracer_tracefs(tr, tr->dir);
6324 6345
6325 list_add(&tr->list, &ftrace_trace_arrays); 6346 list_add(&tr->list, &ftrace_trace_arrays);
6326 6347
@@ -6341,7 +6362,7 @@ static int new_instance_create(const char *name)
6341 6362
6342} 6363}
6343 6364
6344static int instance_delete(const char *name) 6365static int instance_rmdir(const char *name)
6345{ 6366{
6346 struct trace_array *tr; 6367 struct trace_array *tr;
6347 int found = 0; 6368 int found = 0;
@@ -6382,82 +6403,17 @@ static int instance_delete(const char *name)
6382 return ret; 6403 return ret;
6383} 6404}
6384 6405
6385static int instance_mkdir (struct inode *inode, struct dentry *dentry, umode_t mode)
6386{
6387 struct dentry *parent;
6388 int ret;
6389
6390 /* Paranoid: Make sure the parent is the "instances" directory */
6391 parent = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
6392 if (WARN_ON_ONCE(parent != trace_instance_dir))
6393 return -ENOENT;
6394
6395 /*
6396 * The inode mutex is locked, but debugfs_create_dir() will also
6397 * take the mutex. As the instances directory can not be destroyed
6398 * or changed in any other way, it is safe to unlock it, and
6399 * let the dentry try. If two users try to make the same dir at
6400 * the same time, then the new_instance_create() will determine the
6401 * winner.
6402 */
6403 mutex_unlock(&inode->i_mutex);
6404
6405 ret = new_instance_create(dentry->d_iname);
6406
6407 mutex_lock(&inode->i_mutex);
6408
6409 return ret;
6410}
6411
6412static int instance_rmdir(struct inode *inode, struct dentry *dentry)
6413{
6414 struct dentry *parent;
6415 int ret;
6416
6417 /* Paranoid: Make sure the parent is the "instances" directory */
6418 parent = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias);
6419 if (WARN_ON_ONCE(parent != trace_instance_dir))
6420 return -ENOENT;
6421
6422 /* The caller did a dget() on dentry */
6423 mutex_unlock(&dentry->d_inode->i_mutex);
6424
6425 /*
6426 * The inode mutex is locked, but debugfs_create_dir() will also
6427 * take the mutex. As the instances directory can not be destroyed
6428 * or changed in any other way, it is safe to unlock it, and
6429 * let the dentry try. If two users try to make the same dir at
6430 * the same time, then the instance_delete() will determine the
6431 * winner.
6432 */
6433 mutex_unlock(&inode->i_mutex);
6434
6435 ret = instance_delete(dentry->d_iname);
6436
6437 mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
6438 mutex_lock(&dentry->d_inode->i_mutex);
6439
6440 return ret;
6441}
6442
6443static const struct inode_operations instance_dir_inode_operations = {
6444 .lookup = simple_lookup,
6445 .mkdir = instance_mkdir,
6446 .rmdir = instance_rmdir,
6447};
6448
6449static __init void create_trace_instances(struct dentry *d_tracer) 6406static __init void create_trace_instances(struct dentry *d_tracer)
6450{ 6407{
6451 trace_instance_dir = debugfs_create_dir("instances", d_tracer); 6408 trace_instance_dir = tracefs_create_instance_dir("instances", d_tracer,
6409 instance_mkdir,
6410 instance_rmdir);
6452 if (WARN_ON(!trace_instance_dir)) 6411 if (WARN_ON(!trace_instance_dir))
6453 return; 6412 return;
6454
6455 /* Hijack the dir inode operations, to allow mkdir */
6456 trace_instance_dir->d_inode->i_op = &instance_dir_inode_operations;
6457} 6413}
6458 6414
6459static void 6415static void
6460init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer) 6416init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
6461{ 6417{
6462 int cpu; 6418 int cpu;
6463 6419
@@ -6511,10 +6467,32 @@ init_tracer_debugfs(struct trace_array *tr, struct dentry *d_tracer)
6511#endif 6467#endif
6512 6468
6513 for_each_tracing_cpu(cpu) 6469 for_each_tracing_cpu(cpu)
6514 tracing_init_debugfs_percpu(tr, cpu); 6470 tracing_init_tracefs_percpu(tr, cpu);
6515 6471
6516} 6472}
6517 6473
6474static struct vfsmount *trace_automount(void *ingore)
6475{
6476 struct vfsmount *mnt;
6477 struct file_system_type *type;
6478
6479 /*
6480 * To maintain backward compatibility for tools that mount
6481 * debugfs to get to the tracing facility, tracefs is automatically
6482 * mounted to the debugfs/tracing directory.
6483 */
6484 type = get_fs_type("tracefs");
6485 if (!type)
6486 return NULL;
6487 mnt = vfs_kern_mount(type, 0, "tracefs", NULL);
6488 put_filesystem(type);
6489 if (IS_ERR(mnt))
6490 return NULL;
6491 mntget(mnt);
6492
6493 return mnt;
6494}
6495
6518/** 6496/**
6519 * tracing_init_dentry - initialize top level trace array 6497 * tracing_init_dentry - initialize top level trace array
6520 * 6498 *
@@ -6526,23 +6504,30 @@ struct dentry *tracing_init_dentry(void)
6526{ 6504{
6527 struct trace_array *tr = &global_trace; 6505 struct trace_array *tr = &global_trace;
6528 6506
6507 /* The top level trace array uses NULL as parent */
6529 if (tr->dir) 6508 if (tr->dir)
6530 return tr->dir; 6509 return NULL;
6531 6510
6532 if (WARN_ON(!debugfs_initialized())) 6511 if (WARN_ON(!debugfs_initialized()))
6533 return ERR_PTR(-ENODEV); 6512 return ERR_PTR(-ENODEV);
6534 6513
6535 tr->dir = debugfs_create_dir("tracing", NULL); 6514 /*
6536 6515 * As there may still be users that expect the tracing
6516 * files to exist in debugfs/tracing, we must automount
6517 * the tracefs file system there, so older tools still
6518 * work with the newer kerenl.
6519 */
6520 tr->dir = debugfs_create_automount("tracing", NULL,
6521 trace_automount, NULL);
6537 if (!tr->dir) { 6522 if (!tr->dir) {
6538 pr_warn_once("Could not create debugfs directory 'tracing'\n"); 6523 pr_warn_once("Could not create debugfs directory 'tracing'\n");
6539 return ERR_PTR(-ENOMEM); 6524 return ERR_PTR(-ENOMEM);
6540 } 6525 }
6541 6526
6542 return tr->dir; 6527 return NULL;
6543} 6528}
6544 6529
6545static __init int tracer_init_debugfs(void) 6530static __init int tracer_init_tracefs(void)
6546{ 6531{
6547 struct dentry *d_tracer; 6532 struct dentry *d_tracer;
6548 6533
@@ -6552,7 +6537,7 @@ static __init int tracer_init_debugfs(void)
6552 if (IS_ERR(d_tracer)) 6537 if (IS_ERR(d_tracer))
6553 return 0; 6538 return 0;
6554 6539
6555 init_tracer_debugfs(&global_trace, d_tracer); 6540 init_tracer_tracefs(&global_trace, d_tracer);
6556 6541
6557 trace_create_file("tracing_thresh", 0644, d_tracer, 6542 trace_create_file("tracing_thresh", 0644, d_tracer,
6558 &global_trace, &tracing_thresh_fops); 6543 &global_trace, &tracing_thresh_fops);
@@ -6575,6 +6560,10 @@ static __init int tracer_init_debugfs(void)
6575 6560
6576 create_trace_options_dir(&global_trace); 6561 create_trace_options_dir(&global_trace);
6577 6562
6563 /* If the tracer was started via cmdline, create options for it here */
6564 if (global_trace.current_trace != &nop_trace)
6565 update_tracer_options(&global_trace, global_trace.current_trace);
6566
6578 return 0; 6567 return 0;
6579} 6568}
6580 6569
@@ -6910,5 +6899,5 @@ __init static int clear_boot_tracer(void)
6910 return 0; 6899 return 0;
6911} 6900}
6912 6901
6913fs_initcall(tracer_init_debugfs); 6902fs_initcall(tracer_init_tracefs);
6914late_initcall(clear_boot_tracer); 6903late_initcall(clear_boot_tracer);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index dd8205a35760..d951deddec89 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -334,7 +334,7 @@ struct tracer_flags {
334 334
335 335
336/** 336/**
337 * struct tracer - a specific tracer and its callbacks to interact with debugfs 337 * struct tracer - a specific tracer and its callbacks to interact with tracefs
338 * @name: the name chosen to select it on the available_tracers file 338 * @name: the name chosen to select it on the available_tracers file
339 * @init: called when one switches to this tracer (echo name > current_tracer) 339 * @init: called when one switches to this tracer (echo name > current_tracer)
340 * @reset: called when one switches to another tracer 340 * @reset: called when one switches to another tracer
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index db54dda10ccc..0d2e47370ee7 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -13,7 +13,7 @@
13#include <linux/workqueue.h> 13#include <linux/workqueue.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/kthread.h> 15#include <linux/kthread.h>
16#include <linux/debugfs.h> 16#include <linux/tracefs.h>
17#include <linux/uaccess.h> 17#include <linux/uaccess.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/ctype.h> 19#include <linux/ctype.h>
@@ -480,7 +480,7 @@ static void remove_subsystem(struct ftrace_subsystem_dir *dir)
480 return; 480 return;
481 481
482 if (!--dir->nr_events) { 482 if (!--dir->nr_events) {
483 debugfs_remove_recursive(dir->entry); 483 tracefs_remove_recursive(dir->entry);
484 list_del(&dir->list); 484 list_del(&dir->list);
485 __put_system_dir(dir); 485 __put_system_dir(dir);
486 } 486 }
@@ -499,7 +499,7 @@ static void remove_event_file_dir(struct ftrace_event_file *file)
499 } 499 }
500 spin_unlock(&dir->d_lock); 500 spin_unlock(&dir->d_lock);
501 501
502 debugfs_remove_recursive(dir); 502 tracefs_remove_recursive(dir);
503 } 503 }
504 504
505 list_del(&file->list); 505 list_del(&file->list);
@@ -1526,7 +1526,7 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
1526 } else 1526 } else
1527 __get_system(system); 1527 __get_system(system);
1528 1528
1529 dir->entry = debugfs_create_dir(name, parent); 1529 dir->entry = tracefs_create_dir(name, parent);
1530 if (!dir->entry) { 1530 if (!dir->entry) {
1531 pr_warn("Failed to create system directory %s\n", name); 1531 pr_warn("Failed to create system directory %s\n", name);
1532 __put_system(system); 1532 __put_system(system);
@@ -1539,12 +1539,12 @@ event_subsystem_dir(struct trace_array *tr, const char *name,
1539 dir->subsystem = system; 1539 dir->subsystem = system;
1540 file->system = dir; 1540 file->system = dir;
1541 1541
1542 entry = debugfs_create_file("filter", 0644, dir->entry, dir, 1542 entry = tracefs_create_file("filter", 0644, dir->entry, dir,
1543 &ftrace_subsystem_filter_fops); 1543 &ftrace_subsystem_filter_fops);
1544 if (!entry) { 1544 if (!entry) {
1545 kfree(system->filter); 1545 kfree(system->filter);
1546 system->filter = NULL; 1546 system->filter = NULL;
1547 pr_warn("Could not create debugfs '%s/filter' entry\n", name); 1547 pr_warn("Could not create tracefs '%s/filter' entry\n", name);
1548 } 1548 }
1549 1549
1550 trace_create_file("enable", 0644, dir->entry, dir, 1550 trace_create_file("enable", 0644, dir->entry, dir,
@@ -1585,9 +1585,9 @@ event_create_dir(struct dentry *parent, struct ftrace_event_file *file)
1585 d_events = parent; 1585 d_events = parent;
1586 1586
1587 name = ftrace_event_name(call); 1587 name = ftrace_event_name(call);
1588 file->dir = debugfs_create_dir(name, d_events); 1588 file->dir = tracefs_create_dir(name, d_events);
1589 if (!file->dir) { 1589 if (!file->dir) {
1590 pr_warn("Could not create debugfs '%s' directory\n", name); 1590 pr_warn("Could not create tracefs '%s' directory\n", name);
1591 return -1; 1591 return -1;
1592 } 1592 }
1593 1593
@@ -2228,7 +2228,7 @@ static inline int register_event_cmds(void) { return 0; }
2228/* 2228/*
2229 * The top level array has already had its ftrace_event_file 2229 * The top level array has already had its ftrace_event_file
2230 * descriptors created in order to allow for early events to 2230 * descriptors created in order to allow for early events to
2231 * be recorded. This function is called after the debugfs has been 2231 * be recorded. This function is called after the tracefs has been
2232 * initialized, and we now have to create the files associated 2232 * initialized, and we now have to create the files associated
2233 * to the events. 2233 * to the events.
2234 */ 2234 */
@@ -2311,16 +2311,16 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr)
2311 struct dentry *d_events; 2311 struct dentry *d_events;
2312 struct dentry *entry; 2312 struct dentry *entry;
2313 2313
2314 entry = debugfs_create_file("set_event", 0644, parent, 2314 entry = tracefs_create_file("set_event", 0644, parent,
2315 tr, &ftrace_set_event_fops); 2315 tr, &ftrace_set_event_fops);
2316 if (!entry) { 2316 if (!entry) {
2317 pr_warn("Could not create debugfs 'set_event' entry\n"); 2317 pr_warn("Could not create tracefs 'set_event' entry\n");
2318 return -ENOMEM; 2318 return -ENOMEM;
2319 } 2319 }
2320 2320
2321 d_events = debugfs_create_dir("events", parent); 2321 d_events = tracefs_create_dir("events", parent);
2322 if (!d_events) { 2322 if (!d_events) {
2323 pr_warn("Could not create debugfs 'events' directory\n"); 2323 pr_warn("Could not create tracefs 'events' directory\n");
2324 return -ENOMEM; 2324 return -ENOMEM;
2325 } 2325 }
2326 2326
@@ -2412,7 +2412,7 @@ int event_trace_del_tracer(struct trace_array *tr)
2412 2412
2413 down_write(&trace_event_sem); 2413 down_write(&trace_event_sem);
2414 __trace_remove_event_dirs(tr); 2414 __trace_remove_event_dirs(tr);
2415 debugfs_remove_recursive(tr->event_dir); 2415 tracefs_remove_recursive(tr->event_dir);
2416 up_write(&trace_event_sem); 2416 up_write(&trace_event_sem);
2417 2417
2418 tr->event_dir = NULL; 2418 tr->event_dir = NULL;
@@ -2534,10 +2534,10 @@ static __init int event_trace_init(void)
2534 if (IS_ERR(d_tracer)) 2534 if (IS_ERR(d_tracer))
2535 return 0; 2535 return 0;
2536 2536
2537 entry = debugfs_create_file("available_events", 0444, d_tracer, 2537 entry = tracefs_create_file("available_events", 0444, d_tracer,
2538 tr, &ftrace_avail_fops); 2538 tr, &ftrace_avail_fops);
2539 if (!entry) 2539 if (!entry)
2540 pr_warn("Could not create debugfs 'available_events' entry\n"); 2540 pr_warn("Could not create tracefs 'available_events' entry\n");
2541 2541
2542 if (trace_define_common_fields()) 2542 if (trace_define_common_fields())
2543 pr_warn("tracing: Failed to allocate common fields"); 2543 pr_warn("tracing: Failed to allocate common fields");
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 2d25ad1526bb..9cfea4c6d314 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -6,7 +6,6 @@
6 * is Copyright (c) Steven Rostedt <srostedt@redhat.com> 6 * is Copyright (c) Steven Rostedt <srostedt@redhat.com>
7 * 7 *
8 */ 8 */
9#include <linux/debugfs.h>
10#include <linux/uaccess.h> 9#include <linux/uaccess.h>
11#include <linux/ftrace.h> 10#include <linux/ftrace.h>
12#include <linux/slab.h> 11#include <linux/slab.h>
@@ -151,7 +150,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth,
151 * The curr_ret_stack is initialized to -1 and get increased 150 * The curr_ret_stack is initialized to -1 and get increased
152 * in this function. So it can be less than -1 only if it was 151 * in this function. So it can be less than -1 only if it was
153 * filtered out via ftrace_graph_notrace_addr() which can be 152 * filtered out via ftrace_graph_notrace_addr() which can be
154 * set from set_graph_notrace file in debugfs by user. 153 * set from set_graph_notrace file in tracefs by user.
155 */ 154 */
156 if (current->curr_ret_stack < -1) 155 if (current->curr_ret_stack < -1)
157 return -EBUSY; 156 return -EBUSY;
@@ -1432,7 +1431,7 @@ static const struct file_operations graph_depth_fops = {
1432 .llseek = generic_file_llseek, 1431 .llseek = generic_file_llseek,
1433}; 1432};
1434 1433
1435static __init int init_graph_debugfs(void) 1434static __init int init_graph_tracefs(void)
1436{ 1435{
1437 struct dentry *d_tracer; 1436 struct dentry *d_tracer;
1438 1437
@@ -1445,7 +1444,7 @@ static __init int init_graph_debugfs(void)
1445 1444
1446 return 0; 1445 return 0;
1447} 1446}
1448fs_initcall(init_graph_debugfs); 1447fs_initcall(init_graph_tracefs);
1449 1448
1450static __init int init_graph_trace(void) 1449static __init int init_graph_trace(void)
1451{ 1450{
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index d73f565b4e06..ed998fbf09ce 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1310,7 +1310,7 @@ static int unregister_kprobe_event(struct trace_kprobe *tk)
1310 return ret; 1310 return ret;
1311} 1311}
1312 1312
1313/* Make a debugfs interface for controlling probe points */ 1313/* Make a tracefs interface for controlling probe points */
1314static __init int init_kprobe_trace(void) 1314static __init int init_kprobe_trace(void)
1315{ 1315{
1316 struct dentry *d_tracer; 1316 struct dentry *d_tracer;
@@ -1323,20 +1323,20 @@ static __init int init_kprobe_trace(void)
1323 if (IS_ERR(d_tracer)) 1323 if (IS_ERR(d_tracer))
1324 return 0; 1324 return 0;
1325 1325
1326 entry = debugfs_create_file("kprobe_events", 0644, d_tracer, 1326 entry = tracefs_create_file("kprobe_events", 0644, d_tracer,
1327 NULL, &kprobe_events_ops); 1327 NULL, &kprobe_events_ops);
1328 1328
1329 /* Event list interface */ 1329 /* Event list interface */
1330 if (!entry) 1330 if (!entry)
1331 pr_warning("Could not create debugfs " 1331 pr_warning("Could not create tracefs "
1332 "'kprobe_events' entry\n"); 1332 "'kprobe_events' entry\n");
1333 1333
1334 /* Profile interface */ 1334 /* Profile interface */
1335 entry = debugfs_create_file("kprobe_profile", 0444, d_tracer, 1335 entry = tracefs_create_file("kprobe_profile", 0444, d_tracer,
1336 NULL, &kprobe_profile_ops); 1336 NULL, &kprobe_profile_ops);
1337 1337
1338 if (!entry) 1338 if (!entry)
1339 pr_warning("Could not create debugfs " 1339 pr_warning("Could not create tracefs "
1340 "'kprobe_profile' entry\n"); 1340 "'kprobe_profile' entry\n");
1341 return 0; 1341 return 0;
1342} 1342}
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 4f815fbce16d..19aff635841a 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -25,7 +25,7 @@
25#include <linux/seq_file.h> 25#include <linux/seq_file.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/smp.h> 27#include <linux/smp.h>
28#include <linux/debugfs.h> 28#include <linux/tracefs.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/ctype.h> 31#include <linux/ctype.h>
diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
index 75e19e86c954..6cf935316769 100644
--- a/kernel/trace/trace_stat.c
+++ b/kernel/trace/trace_stat.c
@@ -12,7 +12,7 @@
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/rbtree.h> 14#include <linux/rbtree.h>
15#include <linux/debugfs.h> 15#include <linux/tracefs.h>
16#include "trace_stat.h" 16#include "trace_stat.h"
17#include "trace.h" 17#include "trace.h"
18 18
@@ -65,7 +65,7 @@ static void reset_stat_session(struct stat_session *session)
65 65
66static void destroy_session(struct stat_session *session) 66static void destroy_session(struct stat_session *session)
67{ 67{
68 debugfs_remove(session->file); 68 tracefs_remove(session->file);
69 __reset_stat_session(session); 69 __reset_stat_session(session);
70 mutex_destroy(&session->stat_mutex); 70 mutex_destroy(&session->stat_mutex);
71 kfree(session); 71 kfree(session);
@@ -279,9 +279,9 @@ static int tracing_stat_init(void)
279 if (IS_ERR(d_tracing)) 279 if (IS_ERR(d_tracing))
280 return 0; 280 return 0;
281 281
282 stat_dir = debugfs_create_dir("trace_stat", d_tracing); 282 stat_dir = tracefs_create_dir("trace_stat", d_tracing);
283 if (!stat_dir) 283 if (!stat_dir)
284 pr_warning("Could not create debugfs " 284 pr_warning("Could not create tracefs "
285 "'trace_stat' entry\n"); 285 "'trace_stat' entry\n");
286 return 0; 286 return 0;
287} 287}
@@ -291,7 +291,7 @@ static int init_stat_file(struct stat_session *session)
291 if (!stat_dir && tracing_stat_init()) 291 if (!stat_dir && tracing_stat_init())
292 return -ENODEV; 292 return -ENODEV;
293 293
294 session->file = debugfs_create_file(session->ts->name, 0644, 294 session->file = tracefs_create_file(session->ts->name, 0644,
295 stat_dir, 295 stat_dir,
296 session, &tracing_stat_fops); 296 session, &tracing_stat_fops);
297 if (!session->file) 297 if (!session->file)