public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Vladislav Bolkhovitin <vst@vlnb.net>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Lockdep and rw_semaphores
Date: Wed, 14 Sep 2011 05:40:13 +0100	[thread overview]
Message-ID: <20110914044013.GD2203@ZenIV.linux.org.uk> (raw)
In-Reply-To: <4E70098D.2050504@vlnb.net>

On Tue, Sep 13, 2011 at 09:55:25PM -0400, Vladislav Bolkhovitin wrote:

> > thread 1:
> > 	down_read(&A); /* got it */
> > thread 2:
> > 	down_read(&B); /* got it */
> > thread 3:
> > 	down_write(&A);	/* blocked until thread 1 releases A */

That's the only thread here doing down_write() on A

> > thread 4:
> > 	down_write(&B);	/* blocked until thread 2 releases B */

... and that's the only thread here doing down_write() on B.  And neither
of those is holding any other locks.  No nesting.

> 1. Reverse read locking isn't always a deadlock. For instance, if only 1 write
> thread participating and doesn't do nested write locking, which is a quite valid
> scenario, because by design of rw locks they are used with many readers and
> limited amount of rare writers.

Um?  If you mean that here we have two threads doing down_write(), remember
that you've got two locks.

> So, it should be better if this warning is issued, if there is >1 thread write
> locking detected on any participated rw lock, and illustrated with a correct
> explanation.

Which would be which threads, in the situation described above?  Again,
we have no nesting for writes and we have one thread attempting down_write()
for any given lock.  Two locks, two writers in total...

  reply	other threads:[~2011-09-14  4:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-11  1:34 Lockdep and rw_semaphores Vladislav Bolkhovitin
2011-09-11  2:38 ` Al Viro
2011-09-13  2:19   ` Vladislav Bolkhovitin
2011-09-13  5:17     ` Al Viro
2011-09-14  1:55       ` Vladislav Bolkhovitin
2011-09-14  4:40         ` Al Viro [this message]
2011-09-15  2:16           ` Vladislav Bolkhovitin
2011-09-13 14:07     ` David Howells

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=20110914044013.GD2203@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vst@vlnb.net \
    /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