Message ID | 1685610013-33478-10-git-send-email-akaher@vmware.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | tracing: introducing eventfs | expand |
Hello, kernel test robot noticed "WARNING:possible_circular_locking_dependency_detected" on: commit: a3bb763435d444023d3bca5479da632c57724619 ("[PATCH v3 09/10] eventfs: moving tracing/events to eventfs") url: https://github.com/intel-lab-lkp/linux/commits/Ajay-Kaher/tracing-Require-all-trace-events-to-have-a-TRACE_SYSTEM/20230601-230657 base: https://git.kernel.org/cgit/linux/kernel/git/shuah/linux-kselftest.git next patch link: https://lore.kernel.org/all/1685610013-33478-10-git-send-email-akaher@vmware.com/ patch subject: [PATCH v3 09/10] eventfs: moving tracing/events to eventfs in testcase: kernel-selftests version: kernel-selftests-x86_64-60acb023-1_20230329 with following parameters: group: ftrace test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel. test-url: https://www.kernel.org/doc/Documentation/kselftest.txt compiler: gcc-12 test machine: 36 threads 1 sockets Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz (Cascade Lake) with 32G memory (please refer to attached dmesg/kmsg for entire log/backtrace) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <oliver.sang@intel.com> | Closes: https://lore.kernel.org/oe-lkp/202306102230.b5aa258d-oliver.sang@intel.com kern :warn : [ 173.884312] WARNING: possible circular locking dependency detected kern :warn : [ 173.884947] 6.4.0-rc1-00014-ga3bb763435d4 #1 Not tainted kern :warn : [ 173.885501] ------------------------------------------------------ kern :warn : [ 173.886125] ftracetest/2186 is trying to acquire lock: kern :warn : [ 173.886665] ffff88810045d368 (&sb->s_type->i_mutex_key#5){++++}-{3:3}, at: dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) kern :warn : [ 173.887638] but task is already holding lock: kern :warn : [ 173.888299] ffffffff84e6d640 (eventfs_rwsem/1){.+.+}-{3:3}, at: dcache_dir_open_wrapper (fs/tracefs/event_inode.c:364) kern :warn : [ 173.889183] which lock already depends on the new lock. kern :warn : [ 173.890101] the existing dependency chain (in reverse order) is: kern :warn : [ 173.890898] -> #1 (eventfs_rwsem/1){.+.+}-{3:3}: kern :warn : [ 173.891600] lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5693 kernel/locking/lockdep.c:5656) kern :warn : [ 173.892066] down_read_nested (kernel/locking/rwsem.c:1263 kernel/locking/rwsem.c:1646) kern :warn : [ 173.892553] eventfs_root_lookup (fs/tracefs/event_inode.c:283) kern :warn : [ 173.893058] __lookup_slow (include/linux/dcache.h:359 include/linux/dcache.h:364 fs/namei.c:1691) kern :warn : [ 173.893529] walk_component (include/linux/fs.h:790 fs/namei.c:1708 fs/namei.c:1998) kern :warn : [ 173.894006] path_lookupat (fs/namei.c:2455 fs/namei.c:2479) kern :warn : [ 173.894476] filename_lookup (fs/namei.c:2508) kern :warn : [ 173.894974] vfs_statx (fs/stat.c:239) kern :warn : [ 173.895410] vfs_fstatat (fs/stat.c:277) kern :warn : [ 173.895851] __do_sys_newfstatat (fs/stat.c:447) kern :warn : [ 173.896350] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) kern :warn : [ 173.896815] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) kern :warn : [ 173.897392] -> #0 (&sb->s_type->i_mutex_key#5){++++}-{3:3}: kern :warn : [ 173.898158] check_prev_add (kernel/locking/lockdep.c:3109) kern :warn : [ 173.898643] __lock_acquire (kernel/locking/lockdep.c:3228 kernel/locking/lockdep.c:3842 kernel/locking/lockdep.c:5074) kern :warn : [ 173.899133] lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5693 kernel/locking/lockdep.c:5656) kern :warn : [ 173.899610] down_write (arch/x86/include/asm/preempt.h:80 kernel/locking/rwsem.c:1304 kernel/locking/rwsem.c:1315 kernel/locking/rwsem.c:1574) kern :warn : [ 173.900054] dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) kern :warn : [ 173.900603] do_dentry_open (fs/open.c:920) kern :warn : [ 173.901081] do_open (fs/namei.c:3636) kern :warn : [ 173.901508] path_openat (fs/namei.c:3792) kern :warn : [ 173.901963] do_filp_open (fs/namei.c:3818) kern :warn : [ 173.902425] do_sys_openat2 (fs/open.c:1356) kern :warn : [ 173.902902] __x64_sys_openat (fs/open.c:1383) kern :warn : [ 173.903408] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) kern :warn : [ 173.903864] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) kern :warn : [ 173.904451] other info that might help us debug this: kern :warn : [ 173.905372] Possible unsafe locking scenario: kern :warn : [ 173.906049] CPU0 CPU1 kern :warn : [ 173.906538] ---- ---- kern :warn : [ 173.907027] rlock(eventfs_rwsem/1); kern :warn : [ 173.907464] lock(&sb->s_type->i_mutex_key#5); kern :warn : [ 173.908171] lock(eventfs_rwsem/1); kern :warn : [ 173.908800] lock(&sb->s_type->i_mutex_key#5); kern :warn : [ 173.909291] *** DEADLOCK *** kern :warn : [ 173.910026] 1 lock held by ftracetest/2186: kern :warn : [ 173.910488] #0: ffffffff84e6d640 (eventfs_rwsem/1){.+.+}-{3:3}, at: dcache_dir_open_wrapper (fs/tracefs/event_inode.c:364) kern :warn : [ 173.911413] stack backtrace: kern :warn : [ 173.911955] CPU: 13 PID: 2186 Comm: ftracetest Not tainted 6.4.0-rc1-00014-ga3bb763435d4 #1 kern :warn : [ 173.912777] Hardware name: Gigabyte Technology Co., Ltd. X299 UD4 Pro/X299 UD4 Pro-CF, BIOS F8a 04/27/2021 kern :warn : [ 173.913694] Call Trace: kern :warn : [ 173.914014] <TASK> kern :warn : [ 173.914305] dump_stack_lvl (lib/dump_stack.c:108) kern :warn : [ 173.914727] check_noncircular (kernel/locking/lockdep.c:2191) kern :warn : [ 173.915199] ? print_circular_bug (kernel/locking/lockdep.c:2167) kern :warn : [ 173.915676] ? mark_usage (kernel/locking/lockdep.c:4930) kern :warn : [ 173.916100] check_prev_add (kernel/locking/lockdep.c:3109) kern :warn : [ 173.916553] __lock_acquire (kernel/locking/lockdep.c:3228 kernel/locking/lockdep.c:3842 kernel/locking/lockdep.c:5074) kern :warn : [ 173.917003] ? mark_usage (kernel/locking/lockdep.c:4930) kern :warn : [ 173.917425] ? __lock_acquire (arch/x86/include/asm/bitops.h:228 arch/x86/include/asm/bitops.h:240 include/asm-generic/bitops/instrumented-non-atomic.h:142 kernel/locking/lockdep.c:228 kernel/locking/lockdep.c:3754 kernel/locking/lockdep.c:3810 kernel/locking/lockdep.c:5074) kern :warn : [ 173.917889] lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5693 kernel/locking/lockdep.c:5656) kern :warn : [ 173.918309] ? dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) kern :warn : [ 173.918822] ? lock_sync (kernel/locking/lockdep.c:5659) kern :warn : [ 173.919253] ? preempt_notifier_dec (kernel/sched/core.c:10108) kern :warn : [ 173.919729] ? lock_sync (kernel/locking/lockdep.c:5659) kern :warn : [ 173.920144] down_write (arch/x86/include/asm/preempt.h:80 kernel/locking/rwsem.c:1304 kernel/locking/rwsem.c:1315 kernel/locking/rwsem.c:1574) kern :warn : [ 173.920552] ? dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) kern :warn : [ 173.921064] ? down_write_killable_nested (kernel/locking/rwsem.c:1571) kern :warn : [ 173.921599] ? __lock_release+0x111/0x440 kern :warn : [ 173.922097] ? do_dentry_open (fs/open.c:872) kern :warn : [ 173.922540] dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) kern :warn : [ 173.923039] ? fsnotify_perm+0x13b/0x4a0 kern :warn : [ 173.923548] do_dentry_open (fs/open.c:920) kern :warn : [ 173.923982] ? eventfs_create_dir (fs/tracefs/event_inode.c:349) kern :warn : [ 173.924470] ? may_open (fs/namei.c:3265) kern :warn : [ 173.924869] do_open (fs/namei.c:3636) kern :warn : [ 173.925255] path_openat (fs/namei.c:3792) kern :warn : [ 173.926598] ? path_lookupat (fs/namei.c:3773) kern :warn : [ 173.927039] ? .slowpath (kernel/locking/qspinlock.c:317) kern :warn : [ 173.927454] ? lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5693 kernel/locking/lockdep.c:5656) kern :warn : [ 173.927889] ? __create_object (mm/kmemleak.c:678) kern :warn : [ 173.928347] do_filp_open (fs/namei.c:3818) kern :warn : [ 173.928768] ? may_open_dev (fs/namei.c:3812) kern :warn : [ 173.929202] ? _raw_spin_unlock (arch/x86/include/asm/preempt.h:95 include/linux/spinlock_api_smp.h:143 kernel/locking/spinlock.c:186) kern :warn : [ 173.929651] ? alloc_fd (fs/file.c:555 (discriminator 10)) kern :warn : [ 173.930060] ? getname_flags (fs/namei.c:206) kern :warn : [ 173.930544] do_sys_openat2 (fs/open.c:1356) kern :warn : [ 173.930979] ? build_open_flags (fs/open.c:1342) kern :warn : [ 173.931460] __x64_sys_openat (fs/open.c:1383) kern :warn : [ 173.931909] ? __ia32_compat_sys_open (fs/open.c:1383) kern :warn : [ 173.932416] ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4539) kern :warn : [ 173.933016] ? syscall_enter_from_user_mode (arch/x86/include/asm/irqflags.h:42 arch/x86/include/asm/irqflags.h:77 kernel/entry/common.c:111) kern :warn : [ 173.933552] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) kern :warn : [ 173.933966] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) kern :warn : [ 173.934500] RIP: 0033:0x7fc11f551e41 kern :warn : [ 173.934913] Code: 44 24 18 31 c0 41 83 e2 40 75 3e 89 f0 25 00 00 41 00 3d 00 00 41 00 74 30 89 f2 b8 01 01 00 00 48 89 fe bf 9c ff ff ff 0f 05 <48> 3d 00 f0 ff ff 77 3f 48 8b 54 24 18 64 48 2b 14 25 28 00 00 00 All code ======== 0: 44 24 18 rex.R and $0x18,%al 3: 31 c0 xor %eax,%eax 5: 41 83 e2 40 and $0x40,%r10d 9: 75 3e jne 0x49 b: 89 f0 mov %esi,%eax d: 25 00 00 41 00 and $0x410000,%eax 12: 3d 00 00 41 00 cmp $0x410000,%eax 17: 74 30 je 0x49 19: 89 f2 mov %esi,%edx 1b: b8 01 01 00 00 mov $0x101,%eax 20: 48 89 fe mov %rdi,%rsi 23: bf 9c ff ff ff mov $0xffffff9c,%edi 28: 0f 05 syscall 2a:* 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax <-- trapping instruction 30: 77 3f ja 0x71 32: 48 8b 54 24 18 mov 0x18(%rsp),%rdx 37: 64 48 2b 14 25 28 00 sub %fs:0x28,%rdx 3e: 00 00 Code starting with the faulting instruction =========================================== 0: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax 6: 77 3f ja 0x47 8: 48 8b 54 24 18 mov 0x18(%rsp),%rdx d: 64 48 2b 14 25 28 00 sub %fs:0x28,%rdx 14: 00 00 To reproduce: git clone https://github.com/intel/lkp-tests.git cd lkp-tests sudo bin/lkp install job.yaml # job file is attached in this email bin/lkp split-job --compatible job.yaml # generate the yaml file for lkp run sudo bin/lkp run generated-yaml-file # if come across any failure that blocks the test, # please remove ~/.lkp and /lkp dir to run from a clean state.
> Hello, > > kernel test robot noticed "WARNING:possible_circular_locking_dependency_detected" on: > > commit: a3bb763435d444023d3bca5479da632c57724619 ("[PATCH v3 09/10] eventfs: moving tracing/events to eventfs") > url: https://github.com/intel-lab-lkp/linux/commits/Ajay-Kaher/tracing-Require-all-trace-events-to-have-a-TRACE_SYSTEM/20230601-230657 > base: https://git.kernel.org/cgit/linux/kernel/git/shuah/linux-kselftest.git next > patch link: 1685610013-33478-10-git-send-email-akaher@vmware.com/">https://lore.kernel.org/all/1685610013-33478-10-git-send-email-akaher@vmware.com/ > patch subject: [PATCH v3 09/10] eventfs: moving tracing/events to eventfs > > in testcase: kernel-selftests > version: kernel-selftests-x86_64-60acb023-1_20230329 > with following parameters: > > group: ftrace > > test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel. > test-url: https://www.kernel.org/doc/Documentation/kselftest.txt > > > compiler: gcc-12 > test machine: 36 threads 1 sockets Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz (Cascade Lake) with 32G memory > > (please refer to attached dmesg/kmsg for entire log/backtrace) > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <oliver.sang@intel.com> > | Closes: 202306102230.b5aa258d-oliver.sang@intel.com">https://lore.kernel.org/oe-lkp/202306102230.b5aa258d-oliver.sang@intel.com > > > kern :warn : [ 173.884312] WARNING: possible circular locking dependency detected > kern :warn : [ 173.884947] 6.4.0-rc1-00014-ga3bb763435d4 #1 Not tainted > kern :warn : [ 173.885501] ------------------------------------------------------ > kern :warn : [ 173.886125] ftracetest/2186 is trying to acquire lock: > kern :warn : [ 173.886665] ffff88810045d368 (&sb->s_type->i_mutex_key#5){++++}-{3:3}, at: dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) > kern :warn : [ 173.887638] > but task is already holding lock: > kern :warn : [ 173.888299] ffffffff84e6d640 (eventfs_rwsem/1){.+.+}-{3:3}, at: dcache_dir_open_wrapper (fs/tracefs/event_inode.c:364) > kern :warn : [ 173.889183] > which lock already depends on the new lock. > > kern :warn : [ 173.890101] > the existing dependency chain (in reverse order) is: > kern :warn : [ 173.890898] > -> #1 (eventfs_rwsem/1){.+.+}-{3:3}: > kern :warn : [ 173.891600] lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5693 kernel/locking/lockdep.c:5656) > kern :warn : [ 173.892066] down_read_nested (kernel/locking/rwsem.c:1263 kernel/locking/rwsem.c:1646) > kern :warn : [ 173.892553] eventfs_root_lookup (fs/tracefs/event_inode.c:283) > kern :warn : [ 173.893058] __lookup_slow (include/linux/dcache.h:359 include/linux/dcache.h:364 fs/namei.c:1691) > kern :warn : [ 173.893529] walk_component (include/linux/fs.h:790 fs/namei.c:1708 fs/namei.c:1998) > kern :warn : [ 173.894006] path_lookupat (fs/namei.c:2455 fs/namei.c:2479) > kern :warn : [ 173.894476] filename_lookup (fs/namei.c:2508) > kern :warn : [ 173.894974] vfs_statx (fs/stat.c:239) > kern :warn : [ 173.895410] vfs_fstatat (fs/stat.c:277) > kern :warn : [ 173.895851] __do_sys_newfstatat (fs/stat.c:447) > kern :warn : [ 173.896350] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) > kern :warn : [ 173.896815] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) > kern :warn : [ 173.897392] > -> #0 (&sb->s_type->i_mutex_key#5){++++}-{3:3}: > kern :warn : [ 173.898158] check_prev_add (kernel/locking/lockdep.c:3109) > kern :warn : [ 173.898643] __lock_acquire (kernel/locking/lockdep.c:3228 kernel/locking/lockdep.c:3842 kernel/locking/lockdep.c:5074) > kern :warn : [ 173.899133] lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5693 kernel/locking/lockdep.c:5656) > kern :warn : [ 173.899610] down_write (arch/x86/include/asm/preempt.h:80 kernel/locking/rwsem.c:1304 kernel/locking/rwsem.c:1315 kernel/locking/rwsem.c:1574) > kern :warn : [ 173.900054] dcache_dir_open_wrapper (fs/tracefs/event_inode.c:373) > kern :warn : [ 173.900603] do_dentry_open (fs/open.c:920) > kern :warn : [ 173.901081] do_open (fs/namei.c:3636) > kern :warn : [ 173.901508] path_openat (fs/namei.c:3792) > kern :warn : [ 173.901963] do_filp_open (fs/namei.c:3818) > kern :warn : [ 173.902425] do_sys_openat2 (fs/open.c:1356) > kern :warn : [ 173.902902] __x64_sys_openat (fs/open.c:1383) > kern :warn : [ 173.903408] do_syscall_64 (arch/x86/entry/common.c:50 arch/x86/entry/common.c:80) > kern :warn : [ 173.903864] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120) > kern :warn : [ 173.904451] > other info that might help us debug this: > > kern :warn : [ 173.905372] Possible unsafe locking scenario: > > kern :warn : [ 173.906049] CPU0 CPU1 > kern :warn : [ 173.906538] ---- ---- > kern :warn : [ 173.907027] rlock(eventfs_rwsem/1); > kern :warn : [ 173.907464] lock(&sb->s_type->i_mutex_key#5); > kern :warn : [ 173.908171] lock(eventfs_rwsem/1); > kern :warn : [ 173.908800] lock(&sb->s_type->i_mutex_key#5); > kern :warn : [ 173.909291] > *** DEADLOCK *** Steve, this seems not to be a problem here as dcache_dir_open_wrapper() and eventfs_root_lookup() both lock eventfs_rwsem as read lock, however it’s known problem in Lockdep for rwlock: https://lpc.events/event/2/contributions/74/ And available patchset on Lockdep not upstreamed: https://lore.kernel.org/all/20190829083132.22394-1-duyuyang@gmail.com/ -Ajay
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 76820d3e9..a098d7153 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -374,6 +374,23 @@ static const struct super_operations tracefs_super_operations = { .show_options = tracefs_show_options, }; +static void tracefs_dentry_iput(struct dentry *dentry, struct inode *inode) +{ + struct tracefs_inode *ti; + + if (!dentry || !inode) + return; + + ti = get_tracefs(inode); + if (ti && ti->flags & TRACEFS_EVENT_INODE) + eventfs_set_ef_status_free(dentry); + iput(inode); +} + +static const struct dentry_operations tracefs_dentry_operations = { + .d_iput = tracefs_dentry_iput, +}; + static int trace_fill_super(struct super_block *sb, void *data, int silent) { static const struct tree_descr trace_files[] = {{""}}; @@ -396,6 +413,7 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent) goto fail; sb->s_op = &tracefs_super_operations; + sb->s_d_op = &tracefs_dentry_operations; tracefs_apply_options(sb, false); diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 0e373222a..696843d46 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -635,6 +635,7 @@ struct trace_event_file { struct list_head list; struct trace_event_call *event_call; struct event_filter __rcu *filter; + struct eventfs_file *ef; struct dentry *dir; struct trace_array *tr; struct trace_subsystem_dir *system; diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index b895c3346..b265ae2df 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1310,7 +1310,7 @@ struct trace_subsystem_dir { struct list_head list; struct event_subsystem *subsystem; struct trace_array *tr; - struct dentry *entry; + struct eventfs_file *ef; int ref_count; int nr_events; }; diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 16bc5ba45..94aa6f9c9 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -988,7 +988,8 @@ static void remove_subsystem(struct trace_subsystem_dir *dir) return; if (!--dir->nr_events) { - tracefs_remove(dir->entry); + if (dir->ef) + eventfs_remove(dir->ef); list_del(&dir->list); __put_system_dir(dir); } @@ -1009,7 +1010,8 @@ static void remove_event_file_dir(struct trace_event_file *file) tracefs_remove(dir); } - + if (file->ef) + eventfs_remove(file->ef); list_del(&file->list); remove_subsystem(file->system); free_event_filter(file->filter); @@ -2295,13 +2297,13 @@ create_new_subsystem(const char *name) return NULL; } -static struct dentry * +static struct eventfs_file * event_subsystem_dir(struct trace_array *tr, const char *name, struct trace_event_file *file, struct dentry *parent) { struct event_subsystem *system, *iter; struct trace_subsystem_dir *dir; - struct dentry *entry; + int res; /* First see if we did not already create this dir */ list_for_each_entry(dir, &tr->systems, list) { @@ -2309,7 +2311,7 @@ event_subsystem_dir(struct trace_array *tr, const char *name, if (strcmp(system->name, name) == 0) { dir->nr_events++; file->system = dir; - return dir->entry; + return dir->ef; } } @@ -2333,8 +2335,8 @@ event_subsystem_dir(struct trace_array *tr, const char *name, } else __get_system(system); - dir->entry = tracefs_create_dir(name, parent); - if (!dir->entry) { + dir->ef = eventfs_add_subsystem_dir(name, parent, &tr->eventfs_rwsem); + if (IS_ERR(dir->ef)) { pr_warn("Failed to create system directory %s\n", name); __put_system(system); goto out_free; @@ -2349,22 +2351,22 @@ event_subsystem_dir(struct trace_array *tr, const char *name, /* the ftrace system is special, do not create enable or filter files */ if (strcmp(name, "ftrace") != 0) { - entry = tracefs_create_file("filter", TRACE_MODE_WRITE, - dir->entry, dir, + res = eventfs_add_file("filter", TRACE_MODE_WRITE, + dir->ef, dir, &ftrace_subsystem_filter_fops); - if (!entry) { + if (res) { kfree(system->filter); system->filter = NULL; pr_warn("Could not create tracefs '%s/filter' entry\n", name); } - trace_create_file("enable", TRACE_MODE_WRITE, dir->entry, dir, + eventfs_add_file("enable", TRACE_MODE_WRITE, dir->ef, dir, &ftrace_system_enable_fops); } list_add(&dir->list, &tr->systems); - return dir->entry; + return dir->ef; out_free: kfree(dir); @@ -2418,7 +2420,7 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) { struct trace_event_call *call = file->event_call; struct trace_array *tr = file->tr; - struct dentry *d_events; + struct eventfs_file *ef_subsystem = NULL; const char *name; int ret; @@ -2430,24 +2432,24 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0)) return -ENODEV; - d_events = event_subsystem_dir(tr, call->class->system, file, parent); - if (!d_events) + ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent); + if (!ef_subsystem) return -ENOMEM; name = trace_event_name(call); - file->dir = tracefs_create_dir(name, d_events); - if (!file->dir) { + file->ef = eventfs_add_dir(name, ef_subsystem, &tr->eventfs_rwsem); + if (IS_ERR(file->ef)) { pr_warn("Could not create tracefs '%s' directory\n", name); return -1; } if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) - trace_create_file("enable", TRACE_MODE_WRITE, file->dir, file, + eventfs_add_file("enable", TRACE_MODE_WRITE, file->ef, file, &ftrace_enable_fops); #ifdef CONFIG_PERF_EVENTS if (call->event.type && call->class->reg) - trace_create_file("id", TRACE_MODE_READ, file->dir, + eventfs_add_file("id", TRACE_MODE_READ, file->ef, (void *)(long)call->event.type, &ftrace_event_id_fops); #endif @@ -2463,27 +2465,27 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) * triggers or filters. */ if (!(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) { - trace_create_file("filter", TRACE_MODE_WRITE, file->dir, + eventfs_add_file("filter", TRACE_MODE_WRITE, file->ef, file, &ftrace_event_filter_fops); - trace_create_file("trigger", TRACE_MODE_WRITE, file->dir, + eventfs_add_file("trigger", TRACE_MODE_WRITE, file->ef, file, &event_trigger_fops); } #ifdef CONFIG_HIST_TRIGGERS - trace_create_file("hist", TRACE_MODE_READ, file->dir, file, + eventfs_add_file("hist", TRACE_MODE_READ, file->ef, file, &event_hist_fops); #endif #ifdef CONFIG_HIST_TRIGGERS_DEBUG - trace_create_file("hist_debug", TRACE_MODE_READ, file->dir, file, + eventfs_add_file("hist_debug", TRACE_MODE_READ, file->ef, file, &event_hist_debug_fops); #endif - trace_create_file("format", TRACE_MODE_READ, file->dir, call, + eventfs_add_file("format", TRACE_MODE_READ, file->ef, call, &ftrace_event_format_fops); #ifdef CONFIG_TRACE_EVENT_INJECT if (call->event.type && call->class->reg) - trace_create_file("inject", 0200, file->dir, file, + eventfs_add_file("inject", 0200, file->ef, file, &event_inject_fops); #endif @@ -3636,21 +3638,22 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) { struct dentry *d_events; struct dentry *entry; + int error = 0; entry = trace_create_file("set_event", TRACE_MODE_WRITE, parent, tr, &ftrace_set_event_fops); if (!entry) return -ENOMEM; - d_events = tracefs_create_dir("events", parent); - if (!d_events) { + d_events = eventfs_create_events_dir("events", parent, &tr->eventfs_rwsem); + if (IS_ERR(d_events)) { pr_warn("Could not create tracefs 'events' directory\n"); return -ENOMEM; } - entry = trace_create_file("enable", TRACE_MODE_WRITE, d_events, + error = eventfs_add_top_file("enable", TRACE_MODE_WRITE, d_events, tr, &ftrace_tr_enable_fops); - if (!entry) + if (error) return -ENOMEM; /* There are not as crucial, just warn if they are not created */ @@ -3663,11 +3666,11 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) &ftrace_set_event_notrace_pid_fops); /* ring buffer internal formats */ - trace_create_file("header_page", TRACE_MODE_READ, d_events, + eventfs_add_top_file("header_page", TRACE_MODE_READ, d_events, ring_buffer_print_page_header, &ftrace_show_header_fops); - trace_create_file("header_event", TRACE_MODE_READ, d_events, + eventfs_add_top_file("header_event", TRACE_MODE_READ, d_events, ring_buffer_print_entry_header, &ftrace_show_header_fops); @@ -3755,7 +3758,7 @@ int event_trace_del_tracer(struct trace_array *tr) down_write(&trace_event_sem); __trace_remove_event_dirs(tr); - tracefs_remove(tr->event_dir); + eventfs_remove_events_dir(tr->event_dir); up_write(&trace_event_sem); tr->event_dir = NULL;