Skip to contentSkip to conversation

lockdep: Fix lock_is_held on recursion

PATCH In review Peter Zijlstra 3 participants 4 messages Jun 6, 2011 – Jun 7, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockdep: Fix lock_is_held on recursion

Subject: lockdep: Fix lock_is_held on recursion
From: Peter Zijlstra <[email protected]>
Date: Mon Jun 06 12:32:43 CEST 2011

The main lock_is_held() user is lockdep_assert_held(), avoid false assertions in lockdep_off() sections by unconditionally reporting the lock is taken.

[ the reason this is important is a lockdep_assert_held() in ttwu()
which triggers a warning under lockdep_off() as in printk() which can trigger another wakeup and lock up due to spinlock recursion ]

---

kernel/lockdep.c +1 -1
Index: linux-2.6/kernel/lockdep.c
===================================================================
@@ -3426,7 +3426,7 @@ int lock_is_held(struct lockdep_map *loc
 	int ret = 0;
 
 	if (unlikely(current->lockdep_recursion))
-		return ret;
+		return 1; /* avoid false negative lockdep_assert_held */
 
 	raw_local_irq_save(flags);
 	check_flags(flags);
#1 lore raw

[tip:sched/urgent] lockdep: Fix lock_is_held() on recursion

Commit-ID:  f2513cde93f0957d5dc6c09bc24b0cccd27d8e1d
Gitweb:     http://git.kernel.org/tip/f2513cde93f0957d5dc6c09bc24b0cccd27d8e1d
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Mon, 6 Jun 2011 12:32:43 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 7 Jun 2011 12:25:50 +0200

lockdep: Fix lock_is_held() on recursion

The main lock_is_held() user is lockdep_assert_held(), avoid false assertions in lockdep_off() sections by unconditionally reporting the lock is taken.

[ the reason this is important is a lockdep_assert_held() in ttwu()
which triggers a warning under lockdep_off() as in printk() which can trigger another wakeup and lock up due to spinlock recursion, as reported and heroically debugged by Arne Jansen ]

---
 kernel/lockdep.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/lockdep.c +1 -1
index 63437d0..298c927 100644
@@ -3426,7 +3426,7 @@ int lock_is_held(struct lockdep_map *lock)
 	int ret = 0;
 
 	if (unlikely(current->lockdep_recursion))
-		return ret;
+		return 1; /* avoid false negative lockdep_assert_held() */
 
 	raw_local_irq_save(flags);
 	check_flags(flags);
#2 lore raw

Re: [tip:sched/urgent] lockdep: Fix lock_is_held() on recursion

Quoted 18 lines · tip-bot for Peter Zijlstra
Commit-ID:  f2513cde93f0957d5dc6c09bc24b0cccd27d8e1d
Gitweb:     http://git.kernel.org/tip/f2513cde93f0957d5dc6c09bc24b0cccd27d8e1d
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Mon, 6 Jun 2011 12:32:43 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 7 Jun 2011 12:25:50 +0200

lockdep: Fix lock_is_held() on recursion

The main lock_is_held() user is lockdep_assert_held(), avoid false assertions in lockdep_off() sections by unconditionally reporting the lock is taken.

[ the reason this is important is a lockdep_assert_held() in ttwu()
which triggers a warning under lockdep_off() as in printk() which can trigger another wakeup and lock up due to spinlock recursion, as reported and heroically debugged by Arne Jansen ]

Quoted 4 lines

Not _that_ critical for stable since the offending lockdep_assert_held() doesn't exist in .39, still definitely won't hurt.

#3 lore raw

Re: [tip:sched/urgent] lockdep: Fix lock_is_held() on recursion

Quoted 19 lines · Peter Zijlstra
Quoted 18 lines · tip-bot for Peter Zijlstra
Commit-ID:  f2513cde93f0957d5dc6c09bc24b0cccd27d8e1d
Gitweb:     http://git.kernel.org/tip/f2513cde93f0957d5dc6c09bc24b0cccd27d8e1d
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Mon, 6 Jun 2011 12:32:43 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 7 Jun 2011 12:25:50 +0200

lockdep: Fix lock_is_held() on recursion

The main lock_is_held() user is lockdep_assert_held(), avoid false assertions in lockdep_off() sections by unconditionally reporting the lock is taken.

[ the reason this is important is a lockdep_assert_held() in ttwu()
which triggers a warning under lockdep_off() as in printk() which can trigger another wakeup and lock up due to spinlock recursion, as reported and heroically debugged by Arne Jansen ]

Quoted 7 lines
Quoted 4 lines

Not _that_ critical for stable since the offending lockdep_assert_held() doesn't exist in .39, still definitely won't hurt.

Correct, the bug was hard enough to find, i didnt want someone else to trigger a similar one. There's numerous lockdep_assert_held() instances all around the tree.

Thanks,

Ingo