From: j.glisse@gmail.com
To: linux-kernel@vger.kernel.org
Cc: "Jérôme Glisse" <jglisse@redhat.com>,
"Ingo Molnar" <mingo@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Sasha Levin" <sasha.levin@oracle.com>
Subject: [PATCH] locking/lockdep: Fix expected depth value in __lock_release()
Date: Mon, 19 Oct 2015 15:30:28 -0400 [thread overview]
Message-ID: <1445283028-7865-1-git-send-email-j.glisse@gmail.com> (raw)
From: Jérôme Glisse <jglisse@redhat.com>
In __lock_release() we are removing one entry from the stack and
rebuilding the hash chain by re-adding entry above the entry we
just removed. If the entry removed was between 2 entry of same
class then this 2 entry might be coalesced into one single entry
which in turns means that the lockdep_depth value will not be
incremented and thus the expected lockdep_depth value after this
operation will be wrong triggering an unjustified WARN_ONCE() at
the end of __lock_release().
This patch adjust the expect depth value by decrementing it if
what was previously 2 entry inside the stack are coalesced into
only one entry.
Note that __lock_set_class() does not suffer from same issue as
it adds a new class and thus can not lead to coalescing of stack
entry.
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sasha Levin <sasha.levin@oracle.com>
---
kernel/locking/lockdep.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 4e49cc4..cac5e21 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3428,6 +3428,8 @@ found_it:
curr->curr_chain_key = hlock->prev_chain_key;
for (i++; i < depth; i++) {
+ int tmp = curr->lockdep_depth;
+
hlock = curr->held_locks + i;
if (!__lock_acquire(hlock->instance,
hlock_class(hlock)->subclass, hlock->trylock,
@@ -3435,6 +3437,13 @@ found_it:
hlock->nest_lock, hlock->acquire_ip,
hlock->references, hlock->pin_count))
return 0;
+ /*
+ * If nest_lock is true and the lock we just removed allow two
+ * lock of same class to be consolidated in only one held_lock
+ * then the lockdep_depth count will not increase as we expect
+ * it to. So adjust the expected depth value accordingly.
+ */
+ depth -= (curr->lockdep_depth == tmp);
}
/*
--
1.8.3.1
next reply other threads:[~2015-10-19 19:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 19:30 j.glisse [this message]
2015-10-20 12:18 ` Peter Zijlstra
2015-10-20 12:42 ` Jerome Glisse
2015-10-20 13:07 ` Peter Zijlstra
2015-10-20 14:40 ` Jerome Glisse
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=1445283028-7865-1-git-send-email-j.glisse@gmail.com \
--to=j.glisse@gmail.com \
--cc=jglisse@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=sasha.levin@oracle.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
all inboxes | Powered by JetHome®