Skip to content

Commit f01eb36

Browse files
committed
[BKL] add 'might_sleep()' to the outermost lock taker
As shown by the previous patch (6698e34: "tty: Fix BKL taken under a spinlock bug introduced in the BKL split") the BKL removal is prone to some subtle issues, where removing the BKL in one place may in fact make a previously nested BKL call the new outer call, and then prone to nasty deadlocks with other spinlocks. In general, we should never take the BKL while we're holding a spinlock, so let's just add a "might_sleep()" to it (even though the BKL doesn't technically sleep - at least not yet), and we'll get nice warnings the next time this kind of problem happens during BKL removal. Acked-and-Tested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6698e34 commit f01eb36

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎lib/kernel_lock.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ void __lockfunc _lock_kernel(const char *func, const char *file, int line)
122122

123123
trace_lock_kernel(func, file, line);
124124

125-
if (likely(!depth))
125+
if (likely(!depth)) {
126+
might_sleep();
126127
__lock_kernel();
128+
}
127129
current->lock_depth = depth;
128130
}
129131

0 commit comments

Comments
 (0)