public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ming Lei <tom.leiming@gmail.com>
Subject: Re: [PATCH 2/2] lockdep: Don't only check recursive read locks once in a sequence
Date: Thu, 19 Nov 2009 16:55:55 +0100	[thread overview]
Message-ID: <20091119155549.GB4967@nowhere> (raw)
In-Reply-To: <4B03C1A7.4070305@cn.fujitsu.com>

On Wed, Nov 18, 2009 at 05:43:03PM +0800, Lai Jiangshan wrote:
> Frederic Weisbecker wrote:
> > Say we have the following locks:
> > A (rwlock, Aw: writelock, Ar: recursive read lock)
> > B (normal lock)
> > 
> > and the following sequences:
> > Ar -> B -> Ar
> > Aw -> B
> > 
> > This won't be detected as a lock inversion
> 
> """
> read-preference <==> read-recursive ability  (rwlock)
> otherwise ==> read-recursive disability      (rwsem)
> """



I don't understand the idea of "read-preference". And btw I
don't understand why rwsem read locks are not considered as
recursive in lockdep.


 
> If "B -> Ar" is always after "Ar", it's NOT a really
> lock inversion because rwlock is read-preference, we
> can ignore all "Ar" which are after "B".



It's not a lock inversion in itself because it's legal to have:

Ar -> B -> Ar



> If sometimes "B -> Ar" is not after "Ar",
> then we have these sequences:
> B -> Ar
> Aw -> B
> 
> Lockdep can detects it now(without this patch applied).
> 
> Maybe I have misunderstood your patch.



Well.
In my example we have this sequence first:

Ar -> B -> Ar

And this second one:

Aw -> B

In the lockdep tree, the read lock won't even be registered,
so we'll just have Aw -> B in the tree.

If we insert these in the tree, we'll have one branch that will
look like that:

			Aw
                         |
                         B
                         |
                         Ar

Like we do with any other kind of lock. We just plug the dependencies
between them. We know that B depends on Aw, but Ar also depends on B.
Although the merged sequence might never happen, there is still a risk
and the above is not legal.


  reply	other threads:[~2009-11-19 15:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-18  1:06 [PATCH 0/2] lockdep: Improvements for rwlocks dependency inversion detection Frederic Weisbecker
2009-11-18  1:06 ` [PATCH 1/2] lockdep: Include recursive read-locks dependencies in the tree Frederic Weisbecker
2009-11-18 10:26   ` Peter Zijlstra
2009-11-19 16:07     ` Frederic Weisbecker
2009-11-18  1:06 ` [PATCH 2/2] lockdep: Don't only check recursive read locks once in a sequence Frederic Weisbecker
2009-11-18  9:43   ` Lai Jiangshan
2009-11-19 15:55     ` Frederic Weisbecker [this message]
2009-11-19 17:13       ` Peter Zijlstra
2009-11-20  0:57         ` Frederic Weisbecker

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=20091119155549.GB4967@nowhere \
    --to=fweisbec@gmail.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tom.leiming@gmail.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