Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Oleg Nesterov and committed by
Petr Mladek
20793955 daeed159

+7 -10
+7 -10
kernel/printk/printk.c
··· 2982 2982 } 2983 2983 2984 2984 /* 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. 2994 2991 */ 2995 2992 #ifdef CONFIG_PREEMPT_RT 2996 2993 static inline void printk_legacy_allow_spinlock_enter(void) { } 2997 2994 static inline void printk_legacy_allow_spinlock_exit(void) { } 2998 2995 #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); 3000 2997 3001 2998 static inline void printk_legacy_allow_spinlock_enter(void) 3002 2999 {