From: Frederic Weisbecker <fweisbec@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ming Lei <tom.leiming@gmail.com>
Subject: [PATCH 2/2] lockdep: Don't only check recursive read locks once in a sequence
Date: Wed, 18 Nov 2009 02:06:38 +0100 [thread overview]
Message-ID: <1258506398-5151-3-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1258506398-5151-1-git-send-email-fweisbec@gmail.com>
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 because in the sequence
of locks held by the current task, if we have a same class acquired
as read-recursive several times, only the first one will be checked
in the tree (although all of them are checked for deadlocks in the
current held sequence).
Fix it by always adding recursive read locks in the dependency tree.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ming Lei <tom.leiming@gmail.com>
---
kernel/lockdep.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index a6f7440..13d1d54 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -1949,9 +1949,9 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
hlock->read = 2;
/*
* Add dependency only if this lock is not the head
- * of the chain, and if it's not a secondary read-lock:
+ * of the chain.
*/
- if (!chain_head && ret != 2)
+ if (!chain_head)
if (!check_prevs_add(curr, hlock))
return 0;
graph_unlock();
--
1.6.2.3
next prev parent reply other threads:[~2009-11-18 1:06 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 ` Frederic Weisbecker [this message]
2009-11-18 9:43 ` [PATCH 2/2] lockdep: Don't only check recursive read locks once in a sequence Lai Jiangshan
2009-11-19 15:55 ` Frederic Weisbecker
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=1258506398-5151-3-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.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 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.