linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Mark Rutland <mark.rutland@arm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ajay Kaher <akaher@vmware.com>,
	chinglinyu@google.com, lkp@intel.com, namit@vmware.com,
	oe-lkp@lists.linux.dev, amakhalov@vmware.com,
	er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu,
	tkundu@vmware.com, vsirnapalli@vmware.com
Subject: Re: [PATCH 1/2 v3] eventfs: Remove eventfs_file and just use eventfs_inode
Date: Tue, 19 Sep 2023 21:18:04 -0400	[thread overview]
Message-ID: <20230919211804.230edf1e@gandalf.local.home> (raw)
In-Reply-To: <20230919184109.d2382bccfc208676c64df3fb@kernel.org>

On Tue, 19 Sep 2023 18:41:09 +0900
Masami Hiramatsu (Google) <mhiramat@kernel.org> wrote:

> > > >  	ti = get_tracefs(inode);
> > > >  	if (!(ti->flags & TRACEFS_EVENT_INODE))
> > > > @@ -375,10 +485,18 @@ static int eventfs_release(struct inode *inode, struct file *file)
> > > >  
> > > >  	ei = ti->private;
> > > >  	idx = srcu_read_lock(&eventfs_srcu);
> > > > -	list_for_each_entry_srcu(ef, &ei->e_top_files, list,
> > > > +	list_for_each_entry_srcu(ei_child, &ei->children, list,
> > > >  				 srcu_read_lock_held(&eventfs_srcu)) {
> > > >  		mutex_lock(&eventfs_mutex);
> > > > -		dentry = ef->dentry;
> > > > +		dentry = ei_child->dentry;
> > > > +		mutex_unlock(&eventfs_mutex);    
> > > 
> > > If someone add a directory via eventfs_create_dir() in parallel, is this
> > > local mutex_lock able to protect from that? (usually it may not happen.)  
> > 
> > That would require an event being added and created at the same time. Not
> > sure that is possible.
> > 
> > We could try it?  
> 
> Not sure, but both eventfs_release() and eventfs_create_dir() will be
> called from dynamic events, right? But the dynamic events will protect
> the create/delete operation with a mutex, so it should not happen if
> I understand correctly.
> But if the eventfs requires such external exclusion for the operation,
> it should be commented.

Hmm, actually looking at this, it's worse than what you stated. This is
called when a directory is closed. So if you had:

	open(dir);

	// look at all the content of this dir to create dentries

	// another task creates a new entry and looks at it too.

	close(dir);

Now we iterate over all the dentries of the dir and dput it.

I think this will cause the ref counts to get out of sync. I'll have to try
to create this scenario and see what happens.



> 
> >   
> > >   
> > > > +		if (dentry)
> > > > +			dput(dentry);
> > > > +	}
> > > > +
> > > > +	for (i = 0; i < ei->nr_entries; i++) {
> > > > +		mutex_lock(&eventfs_mutex);
> > > > +		dentry = ei->d_children[i];
> > > >  		mutex_unlock(&eventfs_mutex);    
> > > 
> > > Ditto. Maybe I'm misunderstanding how eventfs_mutex is used.  
> > 
> > I'll have to go back and look at this part on why I had this. I think it
> > was to make sure ei->d_children existed. But it may also need a test too. I
> > don't remember. :-/  

I believe this is to keep this and create_file_dentry() in sync.

But I need to look deeper. I'm still very new with understanding how all
this file system code works :-p

-- Steve


  reply	other threads:[~2023-09-20  1:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14 16:35 [PATCH 0/2 v3] tracing: Remove eventfs_files by use of callbacks Steven Rostedt
2023-09-14 16:35 ` [PATCH 1/2 v3] eventfs: Remove eventfs_file and just use eventfs_inode Steven Rostedt
2023-09-18 15:01   ` Masami Hiramatsu
2023-09-19  1:04     ` Steven Rostedt
2023-09-19  9:41       ` Masami Hiramatsu
2023-09-20  1:18         ` Steven Rostedt [this message]
2023-09-20 22:20           ` Steven Rostedt
2023-09-14 16:35 ` [PATCH 2/2 v3] tracing/selftests: Update kprobe args char/string to match new functions Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230919211804.230edf1e@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akaher@vmware.com \
    --cc=akpm@linux-foundation.org \
    --cc=amakhalov@vmware.com \
    --cc=chinglinyu@google.com \
    --cc=er.ajay.kaher@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=namit@vmware.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=srivatsa@csail.mit.edu \
    --cc=tkundu@vmware.com \
    --cc=vsirnapalli@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).