Skip to content

Commit 2079395

Browse files
oleg-nesterovpmladek
authored andcommitted
printk_legacy_map: use LD_WAIT_CONFIG instead of LD_WAIT_SLEEP
printk_legacy_map is used to hide lock nesting violations caused by legacy drivers and is using the wrong override type. LD_WAIT_SLEEP is for always sleeping lock types such as mutex_t. LD_WAIT_CONFIG is for lock type which are sleeping while spinning on PREEMPT_RT such as spinlock_t. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Reviewed-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://patch.msgid.link/20251026150726.GA23223@redhat.com [pmladek@suse.com: Fixed indentation.] Signed-off-by: Petr Mladek <pmladek@suse.com>
1 parent daeed15 commit 2079395

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

kernel/printk/printk.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,21 +2982,18 @@ bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
29822982
}
29832983

29842984
/*
2985-
* Legacy console printing from printk() caller context does not respect
2986-
* raw_spinlock/spinlock nesting. For !PREEMPT_RT the lockdep warning is a
2987-
* false positive. For PREEMPT_RT the false positive condition does not
2988-
* occur.
2989-
*
2990-
* This map is used to temporarily establish LD_WAIT_SLEEP context for the
2991-
* console write() callback when legacy printing to avoid false positive
2992-
* lockdep complaints, thus allowing lockdep to continue to function for
2993-
* real issues.
2985+
* The legacy console always acquires a spinlock_t from its printing
2986+
* callback. This violates lock nesting if the caller acquired an always
2987+
* spinning lock (raw_spinlock_t) while invoking printk(). This is not a
2988+
* problem on PREEMPT_RT because legacy consoles print always from a
2989+
* dedicated thread and never from within printk(). Therefore we tell
2990+
* lockdep that a sleeping spin lock (spinlock_t) is valid here.
29942991
*/
29952992
#ifdef CONFIG_PREEMPT_RT
29962993
static inline void printk_legacy_allow_spinlock_enter(void) { }
29972994
static inline void printk_legacy_allow_spinlock_exit(void) { }
29982995
#else
2999-
static DEFINE_WAIT_OVERRIDE_MAP(printk_legacy_map, LD_WAIT_SLEEP);
2996+
static DEFINE_WAIT_OVERRIDE_MAP(printk_legacy_map, LD_WAIT_CONFIG);
30002997

30012998
static inline void printk_legacy_allow_spinlock_enter(void)
30022999
{

0 commit comments

Comments
 (0)