Messages in this thread | | | Date | Wed, 21 Jan 2015 15:47:36 -0500 | From | Steven Rostedt <> | Subject | Re: [RFC][PATCH 4/5] tracing: Have mkdir and rmdir be part of tracefs |
| |
On Wed, 21 Jan 2015 12:19:57 -0500 Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org> > > The tracing "instances" directory can create sub tracing buffers > with mkdir, and remove them with rmdir. As a mkdir will also create > all the files and directories that control the sub buffer the locks > needed to be released before doing so to avoid deadlock. This method > was not very robust, and could potentially have a race somewhere due > to the lock releasing within the removing of the directory. But this > was needed because debugfs did not provide a mkdir or rmdir method > from syscalls. > > Now that tracing has been converted over to tracefs, the tracefs file > system can be modified to accommodate this feature. Instead of needing > to release the locks, keep them locked but add a way to flag that they > are locked and do not need to be locked again. > > A struct trace_dir_ops is created that holds the methods to be called > for both mkdir and rmdir, as well as a pointer to let the tracefs subsystem > know that the current inode's lock is already held by the calling process. > > The pointer holds the current owner of the lock, and this is checked when > creating new files or removing old ones, and if the pointer matches current, > then the lock is not taken to avoid the deadlock.
Grumble, my tests triggered this bug with lockdep on:
Possible unsafe locking scenario:
CPU0 CPU1 ---- ---- lock(&sb->s_type->i_mutex_key#6); lock(trace_types_lock); lock(&sb->s_type->i_mutex_key#6); lock(trace_types_lock);
*** DEADLOCK ***
I need to take that trace_types_lock here, but it's true that that lock is held when these mutexes are taken. I'll have to spend a bit more time figuring out how to solve this :-/
-- Steve
| |