lkml.org 
[lkml]   [2022]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/4] printk: Drop console_sem during panic
Date
If another CPU is in panic, we are about to be halted. Try to gracefully
drop console_sem and allow the panic CPU to grab it easily.

Suggested-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
kernel/printk/printk.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ca253ac07615..c2dc8ebd9509 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2668,7 +2668,7 @@ void console_unlock(void)

for (;;) {
size_t ext_len = 0;
- int handover;
+ int handover, pcpu;
size_t len;

skip:
@@ -2739,6 +2739,12 @@ void console_unlock(void)
if (handover)
return;

+ /* Allow panic_cpu to take over the consoles safely */
+ pcpu = atomic_read(&panic_cpu);
+ if (unlikely(pcpu != PANIC_CPU_INVALID &&
+ pcpu != raw_smp_processor_id()))
+ break;
+
if (do_cond_resched)
cond_resched();
}
--
2.30.2
\
 
 \ /
  Last update: 2022-01-21 20:03    [W:0.099 / U:1.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site