From: Oleg Nesterov <oleg@redhat.com>
To: Ingo Molnar <mingo@elte.hu>, Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Anton Arapov <anton@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Michal Marek <mmarek@suse.cz>,
Mikulas Patocka <mpatocka@redhat.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Q: __lockdep_no_validate__ (Was: [PATCH -mm 0/3] percpu_rw_semaphore: lockdep + config)
Date: Mon, 19 Nov 2012 14:54:12 +0100 [thread overview]
Message-ID: <20121119135412.GA24476@redhat.com> (raw)
In-Reply-To: <20121118190257.GA9660@redhat.com>
On 11/18, Oleg Nesterov wrote:
>
> On 11/11, Oleg Nesterov wrote:
> >
> It turns out, lockdep annotations are not that simple due to internal
> locks used by percpu_rw_semaphore. To clarify, it is actually simple
> but lockdep_set_novalidate_class() doesn't seem to actually work, and
> more importantly, it must not be used according to checkpatch.pl.
Still, is __lockdep_no_validate__ logic correct? I am just curious.
Consider the following code,
DEFINE_MUTEX(m1);
DEFINE_MUTEX(m2);
DEFINE_MUTEX(mx);
static void trigger_lockdep_bug(bool novalidate)
{
if (novalidate)
lockdep_set_novalidate_class(&mx);
// m1 -> mx -> m2
mutex_lock(&m1);
mutex_lock(&mx);
mutex_lock(&m2);
mutex_unlock(&m2);
mutex_unlock(&mx);
mutex_unlock(&m1);
// m2 -> m1 ; should trigger the warning
mutex_lock(&m2);
mutex_lock(&m1);
mutex_unlock(&m1);
mutex_unlock(&m2);
}
trigger_lockdep_bug(false) works correctly, but novalidate => true
confuses (I think) lockdep and it doesn't detect the trivial deadlock.
check_prev_add(m1, mx) still adds the new dependency, but then it is
ignored because of __lockdep_no_validate__ check.
Certainly I do not understand this code (and I am sure I will never
understand it even if I try ;) But perhaps something like below makes
sense? Or I misunderstood the purpose of lockdep_set_novalidate_class?
Thanks,
Oleg.
--- x/kernel/lockdep.c
+++ x/kernel/lockdep.c
@@ -1935,7 +1939,8 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
* Only non-recursive-read entries get new dependencies
* added:
*/
- if (hlock->read != 2) {
+ if (hlock->read != 2 &&
+ hlock->instance->key != &__lockdep_no_validate__) {
if (!check_prev_add(curr, hlock, next,
distance, trylock_loop))
return 0;
prev parent reply other threads:[~2012-11-19 13:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-18 19:02 [PATCH -mm 0/3] percpu_rw_semaphore: lockdep + config Oleg Nesterov
2012-11-18 19:03 ` [PATCH 1/3] percpu_rw_semaphore: kill ->writer_mutex, add ->write_ctr Oleg Nesterov
2012-11-18 19:03 ` [PATCH 2/3] percpu_rw_semaphore: add the lockdep annotations Oleg Nesterov
2012-11-19 23:05 ` Andrew Morton
2012-11-20 16:31 ` Oleg Nesterov
2012-11-18 19:03 ` [PATCH 3/3] percpu_rw_semaphore: introduce CONFIG_PERCPU_RWSEM Oleg Nesterov
2012-11-19 13:54 ` Oleg Nesterov [this message]
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=20121119135412.GA24476@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anton@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mmarek@suse.cz \
--cc=mpatocka@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=torvalds@linux-foundation.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 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).