Skip to content

Commit 20fb0c8

Browse files
committed
Revert "printk: Wait for the global console lock when the system is going down"
This reverts commit b87f023. 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b87f023 commit 20fb0c8

File tree

6 files changed

+0
-47
lines changed

6 files changed

+0
-47
lines changed

include/linux/printk.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ extern void printk_prefer_direct_enter(void);
174174
extern void printk_prefer_direct_exit(void);
175175

176176
extern bool pr_flush(int timeout_ms, bool reset_on_progress);
177-
extern void try_block_console_kthreads(int timeout_ms);
178177

179178
/*
180179
* Please don't use printk_ratelimit(), because it shares ratelimiting state
@@ -239,10 +238,6 @@ static inline bool pr_flush(int timeout_ms, bool reset_on_progress)
239238
return true;
240239
}
241240

242-
static inline void try_block_console_kthreads(int timeout_ms)
243-
{
244-
}
245-
246241
static inline int printk_ratelimit(void)
247242
{
248243
return 0;

kernel/panic.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,13 @@ void panic(const char *fmt, ...)
273273
* unfortunately means it may not be hardened to work in a
274274
* panic situation.
275275
*/
276-
try_block_console_kthreads(10000);
277276
smp_send_stop();
278277
} else {
279278
/*
280279
* If we want to do crash dump after notifier calls and
281280
* kmsg_dump, we will need architecture dependent extra
282281
* works in addition to stopping other CPUs.
283282
*/
284-
try_block_console_kthreads(10000);
285283
crash_smp_send_stop();
286284
}
287285

kernel/printk/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ enum printk_info_flags {
2020
LOG_CONT = 8, /* text is a fragment of a continuation line */
2121
};
2222

23-
extern bool block_console_kthreads;
24-
2523
__printf(4, 0)
2624
int vprintk_store(int facility, int level,
2725
const struct dev_printk_info *dev_info,

kernel/printk/printk.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@ static atomic_t console_kthreads_active = ATOMIC_INIT(0);
250250
#define console_kthread_printing_exit() \
251251
atomic_dec(&console_kthreads_active)
252252

253-
/* Block console kthreads to avoid processing new messages. */
254-
bool block_console_kthreads;
255-
256253
/*
257254
* Helper macros to handle lockdep when locking/unlocking console_sem. We use
258255
* macros instead of functions so that _RET_IP_ contains useful information.
@@ -3733,7 +3730,6 @@ static bool printer_should_wake(struct console *con, u64 seq)
37333730

37343731
if (con->blocked ||
37353732
console_kthreads_atomically_blocked() ||
3736-
block_console_kthreads ||
37373733
system_state > SYSTEM_RUNNING ||
37383734
oops_in_progress) {
37393735
return false;

kernel/printk/printk_safe.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include <linux/smp.h>
99
#include <linux/cpumask.h>
1010
#include <linux/printk.h>
11-
#include <linux/console.h>
1211
#include <linux/kprobes.h>
13-
#include <linux/delay.h>
1412

1513
#include "internal.h"
1614

@@ -52,33 +50,3 @@ asmlinkage int vprintk(const char *fmt, va_list args)
5250
return vprintk_default(fmt, args);
5351
}
5452
EXPORT_SYMBOL(vprintk);
55-
56-
/**
57-
* try_block_console_kthreads() - Try to block console kthreads and
58-
* make the global console_lock() avaialble
59-
*
60-
* @timeout_ms: The maximum time (in ms) to wait.
61-
*
62-
* Prevent console kthreads from starting processing new messages. Wait
63-
* until the global console_lock() become available.
64-
*
65-
* Context: Can be called in any context.
66-
*/
67-
void try_block_console_kthreads(int timeout_ms)
68-
{
69-
block_console_kthreads = true;
70-
71-
/* Do not wait when the console lock could not be safely taken. */
72-
if (this_cpu_read(printk_context) || in_nmi())
73-
return;
74-
75-
while (timeout_ms > 0) {
76-
if (console_trylock()) {
77-
console_unlock();
78-
return;
79-
}
80-
81-
udelay(1000);
82-
timeout_ms -= 1;
83-
}
84-
}

kernel/reboot.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ void kernel_restart_prepare(char *cmd)
7474
{
7575
blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
7676
system_state = SYSTEM_RESTART;
77-
try_block_console_kthreads(10000);
7877
usermodehelper_disable();
7978
device_shutdown();
8079
}
@@ -263,7 +262,6 @@ static void kernel_shutdown_prepare(enum system_states state)
263262
blocking_notifier_call_chain(&reboot_notifier_list,
264263
(state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
265264
system_state = state;
266-
try_block_console_kthreads(10000);
267265
usermodehelper_disable();
268266
device_shutdown();
269267
}

0 commit comments

Comments
 (0)