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.

Revert "printk: Wait for the global console lock when the system is going down"

This reverts commit b87f02307d3cfbda768520f0687c51ca77e14fc3.

The testing of 5.19 release candidates revealed missing synchronization
between early and regular console functionality.

It would be possible to start the console kthreads later as a workaround.
But it is clear that console lock serialized console drivers between
each other. It opens a big area of possible problems that were not
considered by people involved in the development and review.

printk() is crucial for debugging kernel issues and console output is
very important part of it. The number of consoles is huge and a proper
review would take some time. As a result it need to be reverted for 5.19.

Link: https://lore.kernel.org/r/YrBdjVwBOVgLfHyb@alley
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220623145157.21938-2-pmladek@suse.com

-47
-5
include/linux/printk.h
··· 174 174 extern void printk_prefer_direct_exit(void); 175 175 176 176 extern bool pr_flush(int timeout_ms, bool reset_on_progress); 177 - extern void try_block_console_kthreads(int timeout_ms); 178 177 179 178 /* 180 179 * Please don't use printk_ratelimit(), because it shares ratelimiting state ··· 236 237 static inline bool pr_flush(int timeout_ms, bool reset_on_progress) 237 238 { 238 239 return true; 239 - } 240 - 241 - static inline void try_block_console_kthreads(int timeout_ms) 242 - { 243 240 } 244 241 245 242 static inline int printk_ratelimit(void)
-2
kernel/panic.c
··· 273 273 * unfortunately means it may not be hardened to work in a 274 274 * panic situation. 275 275 */ 276 - try_block_console_kthreads(10000); 277 276 smp_send_stop(); 278 277 } else { 279 278 /* ··· 280 281 * kmsg_dump, we will need architecture dependent extra 281 282 * works in addition to stopping other CPUs. 282 283 */ 283 - try_block_console_kthreads(10000); 284 284 crash_smp_send_stop(); 285 285 } 286 286
-2
kernel/printk/internal.h
··· 20 20 LOG_CONT = 8, /* text is a fragment of a continuation line */ 21 21 }; 22 22 23 - extern bool block_console_kthreads; 24 - 25 23 __printf(4, 0) 26 24 int vprintk_store(int facility, int level, 27 25 const struct dev_printk_info *dev_info,
-4
kernel/printk/printk.c
··· 250 250 #define console_kthread_printing_exit() \ 251 251 atomic_dec(&console_kthreads_active) 252 252 253 - /* Block console kthreads to avoid processing new messages. */ 254 - bool block_console_kthreads; 255 - 256 253 /* 257 254 * Helper macros to handle lockdep when locking/unlocking console_sem. We use 258 255 * macros instead of functions so that _RET_IP_ contains useful information. ··· 3730 3733 3731 3734 if (con->blocked || 3732 3735 console_kthreads_atomically_blocked() || 3733 - block_console_kthreads || 3734 3736 system_state > SYSTEM_RUNNING || 3735 3737 oops_in_progress) { 3736 3738 return false;
-32
kernel/printk/printk_safe.c
··· 8 8 #include <linux/smp.h> 9 9 #include <linux/cpumask.h> 10 10 #include <linux/printk.h> 11 - #include <linux/console.h> 12 11 #include <linux/kprobes.h> 13 - #include <linux/delay.h> 14 12 15 13 #include "internal.h" 16 14 ··· 50 52 return vprintk_default(fmt, args); 51 53 } 52 54 EXPORT_SYMBOL(vprintk); 53 - 54 - /** 55 - * try_block_console_kthreads() - Try to block console kthreads and 56 - * make the global console_lock() avaialble 57 - * 58 - * @timeout_ms: The maximum time (in ms) to wait. 59 - * 60 - * Prevent console kthreads from starting processing new messages. Wait 61 - * until the global console_lock() become available. 62 - * 63 - * Context: Can be called in any context. 64 - */ 65 - void try_block_console_kthreads(int timeout_ms) 66 - { 67 - block_console_kthreads = true; 68 - 69 - /* Do not wait when the console lock could not be safely taken. */ 70 - if (this_cpu_read(printk_context) || in_nmi()) 71 - return; 72 - 73 - while (timeout_ms > 0) { 74 - if (console_trylock()) { 75 - console_unlock(); 76 - return; 77 - } 78 - 79 - udelay(1000); 80 - timeout_ms -= 1; 81 - } 82 - }
-2
kernel/reboot.c
··· 74 74 { 75 75 blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); 76 76 system_state = SYSTEM_RESTART; 77 - try_block_console_kthreads(10000); 78 77 usermodehelper_disable(); 79 78 device_shutdown(); 80 79 } ··· 262 263 blocking_notifier_call_chain(&reboot_notifier_list, 263 264 (state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL); 264 265 system_state = state; 265 - try_block_console_kthreads(10000); 266 266 usermodehelper_disable(); 267 267 device_shutdown(); 268 268 }