Skip to contentSkip to conversation

lockdep: fix incorrect state name

PATCH In review Peter Zijlstra 2 participants 2 messages Mar 4, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockdep: fix incorrect state name

Subject: lockdep: fix incorrect state name
From: Peter Zijlstra <[email protected]>
Date: Wed Mar 04 13:51:13 CET 2009

In the recent mark_lock_irq() rework a bug snuck in that would report the state of write locks causing irq inversion under a read lock as a read lock.

Fix this by masking the read bit of the state when validating write dependencies.

---
 kernel/lockdep.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/lockdep.c +3 -2
Index: linux-2.6/kernel/lockdep.c
===================================================================
@@ -2016,7 +2016,8 @@ typedef int (*check_usage_f)(struct task
 			     enum lock_usage_bit bit, const char *name);
 
 static int
-mark_lock_irq(struct task_struct *curr, struct held_lock *this, int new_bit)
+mark_lock_irq(struct task_struct *curr, struct held_lock *this,
+		enum lock_usage_bit new_bit)
 {
 	int excl_bit = exclusive_bit(new_bit);
 	int read = new_bit & 1;
@@ -2044,7 +2045,7 @@ mark_lock_irq(struct task_struct *curr, 
 	 * states.
 	 */
 	if ((!read || !dir || STRICT_READ_CHECKS) &&
-			!usage(curr, this, excl_bit, state_name(new_bit)))
+			!usage(curr, this, excl_bit, state_name(new_bit & ~1)))
 		return 0;
 
 	/*
#1 lore raw
Commit-ID:  1c21f14ec48a2256fb03682b24dddd23eacdc96f
Gitweb:     http://git.kernel.org/tip/1c21f14ec48a2256fb03682b24dddd23eacdc96f
Author:     "Peter Zijlstra" <[email protected]>
AuthorDate: Wed, 4 Mar 2009 13:51:13 +0100
Commit:     Ingo Molnar <[email protected]>
CommitDate: Wed, 4 Mar 2009 18:38:33 +0100

lockdep: fix incorrect state name

In the recent mark_lock_irq() rework a bug snuck in that would report the state of write locks causing irq inversion under a read lock as a read lock.

Fix this by masking the read bit of the state when validating write dependencies.

LKML-Reference: <1236172646.5330.7450.camel@laptop>

---
 kernel/lockdep.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/lockdep.c +3 -2
index 022d2ed..ef6584f 100644
@@ -2015,7 +2015,8 @@ typedef int (*check_usage_f)(struct task_struct *, struct held_lock *,
 			     enum lock_usage_bit bit, const char *name);
 
 static int
-mark_lock_irq(struct task_struct *curr, struct held_lock *this, int new_bit)
+mark_lock_irq(struct task_struct *curr, struct held_lock *this,
+		enum lock_usage_bit new_bit)
 {
 	int excl_bit = exclusive_bit(new_bit);
 	int read = new_bit & 1;
@@ -2043,7 +2044,7 @@ mark_lock_irq(struct task_struct *curr, struct held_lock *this, int new_bit)
 	 * states.
 	 */
 	if ((!read || !dir || STRICT_READ_CHECKS) &&
-			!usage(curr, this, excl_bit, state_name(new_bit)))
+			!usage(curr, this, excl_bit, state_name(new_bit & ~1)))
 		return 0;
 
 	/*