linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	Johannes Berg <johannes.berg@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>, Theodore Ts'o <tytso@mit.edu>
Subject: Re: [PATCH RFC] kernel/locking, fs/direct-io: Introduce and use down_write_nolockdep()
Date: Fri, 26 Oct 2018 11:38:33 -0700	[thread overview]
Message-ID: <20181026183833.GU25444@bombadil.infradead.org> (raw)
In-Reply-To: <1540577478.66186.108.camel@acm.org>

On Fri, Oct 26, 2018 at 11:11:18AM -0700, Bart Van Assche wrote:
> On Fri, 2018-10-26 at 10:43 -0700, Matthew Wilcox wrote:
> > On Fri, Oct 26, 2018 at 09:49:05AM -0700, Bart Van Assche wrote:
> > > diff --git a/mm/rmap.c b/mm/rmap.c
> > > index 1e79fac3186b..2a953d3b7431 100644
> > > --- a/mm/rmap.c
> > > +++ b/mm/rmap.c
> > > @@ -81,6 +81,7 @@ static inline struct anon_vma *anon_vma_alloc(void)
> > >  
> > >  	anon_vma = kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
> > >  	if (anon_vma) {
> > > +		init_rwsem(&anon_vma->rwsem);
> > >  		atomic_set(&anon_vma->refcount, 1);
> > >  		anon_vma->degree = 1;	/* Reference for first vma */
> > >  		anon_vma->parent = anon_vma;
> > 
> > Why is this needed?  The anon_vma_ctor() already calls init_rwsem().
> > 
> > (I suspect this is one of those ctors that isn't actually useful and
> > should be inlined into anon_vma_alloc())
> 
> Without that call I noticed that the "nolockdep" variable was sometimes set
> when down_write() got called. Does that mean that it can happen that an
> anon_vma structure is freed without releasing anon_vma->rwsem?

How strange.  The only call to down_write_nolockdep() you added (in this
patch) was for the inode->i_mutex.  So how could that possibly affect
the anon_vma->rwsem?  Are you seeing some kind of corruption here?

Maybe try initialising ->nolockdep with some 32-bit magic value,
and reporting if it's not 0 or the magic value will lead to some kind
of insight?

  reply	other threads:[~2018-10-27  3:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-26 16:49 [PATCH RFC] kernel/locking, fs/direct-io: Introduce and use down_write_nolockdep() Bart Van Assche
2018-10-26 17:43 ` Matthew Wilcox
2018-10-26 18:11   ` Bart Van Assche
2018-10-26 18:38     ` Matthew Wilcox [this message]
2018-10-26 19:12       ` Bart Van Assche
2018-10-27  5:37 ` Dave Chinner
2018-10-28 17:58   ` Peter Zijlstra
2018-10-28 20:34     ` Christoph Hellwig
2018-10-28 20:45     ` Bart Van Assche

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=20181026183833.GU25444@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=bvanassche@acm.org \
    --cc=johannes.berg@intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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).