All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Matthew Wilcox <willy@infradead.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:11:18 -0700	[thread overview]
Message-ID: <1540577478.66186.108.camel@acm.org> (raw)
In-Reply-To: <20181026174352.GT25444@bombadil.infradead.org>

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:
> > +++ b/include/linux/rwsem.h
> > @@ -41,6 +41,10 @@ struct rw_semaphore {
> >  #endif
> >  #ifdef CONFIG_DEBUG_LOCK_ALLOC
> >  	struct lockdep_map	dep_map;
> > +	/*
> > +	 * Number of up_write() calls that must skip rwsem_release().
> > +	 */
> > +	unsigned		nolockdep;
> 
> This reads a bit weird.  By definition, only one writer is allowed
> at a time.  And you can't call up_write() before down_write().
> So functionally, this is a bool, and the comment should at least
> ackowledge that, even if it remains implemented as an unsigned int.
> 
> I'd suggest the implementation uses '= 1' and '= 0' rather than ++ and --.

Hi Matthew,

That sounds like a good idea to me.

> > 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?

Thanks,

Bart.

  reply	other threads:[~2018-10-27  2:49 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 [this message]
2018-10-26 18:38     ` Matthew Wilcox
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=1540577478.66186.108.camel@acm.org \
    --to=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 \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.