summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0027-printk-Coordinate-direct-printing-in-panic.patch
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--debian/patches-rt/0027-printk-Coordinate-direct-printing-in-panic.patch (renamed from debian/patches-rt/0031-printk-Coordinate-direct-printing-in-panic.patch)79
1 files changed, 54 insertions, 25 deletions
diff --git a/debian/patches-rt/0031-printk-Coordinate-direct-printing-in-panic.patch b/debian/patches-rt/0027-printk-Coordinate-direct-printing-in-panic.patch
index 6f26bf7fc6..4893dd463f 100644
--- a/debian/patches-rt/0031-printk-Coordinate-direct-printing-in-panic.patch
+++ b/debian/patches-rt/0027-printk-Coordinate-direct-printing-in-panic.patch
@@ -1,7 +1,7 @@
From: John Ogness <john.ogness@linutronix.de>
Date: Wed, 22 Nov 2023 11:56:58 +0000
-Subject: [PATCH 31/50] printk: Coordinate direct printing in panic
-Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.7/older/patches-6.7-rt6.tar.xz
+Subject: [PATCH 27/48] printk: Coordinate direct printing in panic
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.8/older/patches-6.8.2-rt11.tar.xz
Perform printing by nbcon consoles on the panic CPU from the
printk() caller context in order to get panic messages printed
@@ -20,33 +20,57 @@ from the printk() caller context).
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- include/linux/printk.h | 2 +
+ include/linux/printk.h | 5 +++
kernel/panic.c | 2 +
- kernel/printk/printk.c | 53 ++++++++++++++++++++++++++++++++++++++++++-------
- 3 files changed, 50 insertions(+), 7 deletions(-)
+ kernel/printk/printk.c | 62 ++++++++++++++++++++++++++++++++++++++++++-------
+ 3 files changed, 61 insertions(+), 8 deletions(-)
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
-@@ -782,3 +782,5 @@ static inline void print_hex_dump_debug(
- print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true)
+@@ -195,6 +195,7 @@ void show_regs_print_info(const char *lo
+ extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold;
+ extern asmlinkage void dump_stack(void) __cold;
+ void printk_trigger_flush(void);
++void printk_legacy_allow_panic_sync(void);
+ extern void nbcon_driver_acquire(struct console *con);
+ extern void nbcon_driver_release(struct console *con);
+ void nbcon_atomic_flush_unsafe(void);
+@@ -278,6 +279,10 @@ static inline void printk_trigger_flush(
+ {
+ }
- #endif
++static inline void printk_legacy_allow_panic_sync(void)
++{
++}
+
-+void printk_legacy_allow_panic_sync(void);
+ static inline void nbcon_driver_acquire(struct console *con)
+ {
+ }
--- a/kernel/panic.c
+++ b/kernel/panic.c
-@@ -370,6 +370,8 @@ void panic(const char *fmt, ...)
- */
- atomic_notifier_call_chain(&panic_notifier_list, 0, buf);
+@@ -364,6 +364,8 @@ void panic(const char *fmt, ...)
+
+ panic_other_cpus_shutdown(_crash_kexec_post_notifiers);
+ printk_legacy_allow_panic_sync();
+
- panic_print_sys_info(false);
-
- kmsg_dump(KMSG_DUMP_PANIC);
+ /*
+ * Run any panic handlers, including those that might need to
+ * add information to the kmsg dump output.
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -2329,12 +2329,23 @@ int vprintk_store(int facility, int leve
+@@ -471,7 +471,9 @@ static DEFINE_MUTEX(syslog_lock);
+ static bool have_legacy_console;
+
+ /*
+- * Specifies if an nbcon console is registered.
++ * Specifies if an nbcon console is registered. If nbcon consoles are present,
++ * synchronous printing of legacy consoles will not occur during panic until
++ * the backtrace has been stored to the ringbuffer.
+ */
+ static bool have_nbcon_console;
+
+@@ -2335,12 +2337,29 @@ int vprintk_store(int facility, int leve
return ret;
}
@@ -54,11 +78,17 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+/*
+ * This acts as a one-way switch to allow legacy consoles to print from
-+ * the printk() caller context on a panic CPU.
++ * the printk() caller context on a panic CPU. It also attempts to flush
++ * the legacy consoles in this context.
+ */
+void printk_legacy_allow_panic_sync(void)
+{
+ legacy_allow_panic_sync = true;
++
++ if (printing_via_unlock && !in_nmi()) {
++ if (console_trylock())
++ console_unlock();
++ }
+}
+
asmlinkage int vprintk_emit(int facility, int level,
@@ -71,7 +101,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
/* Suppress unimportant messages after panic happens */
if (unlikely(suppress_printk))
-@@ -2350,15 +2361,43 @@ asmlinkage int vprintk_emit(int facility
+@@ -2356,15 +2375,42 @@ asmlinkage int vprintk_emit(int facility
if (level == LOGLEVEL_SCHED) {
level = LOGLEVEL_DEFAULT;
@@ -86,7 +116,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
- /* If called from the scheduler, we can not call up(). */
- if (!in_sched && printing_via_unlock) {
-+ if (!have_boot_console && have_nbcon_console) {
++ if (have_nbcon_console && !have_boot_console) {
+ bool is_panic_context = this_cpu_in_panic();
+
+ /*
@@ -105,20 +135,19 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+ *
+ * - When this CPU is in panic.
+ *
-+ * Note that if boot consoles are registered, the
-+ * console_lock/console_unlock dance must be relied upon
-+ * instead because nbcon consoles cannot print simultaneously
-+ * with boot consoles.
++ * Note that if boot consoles are registered, the console
++ * lock/unlock dance must be relied upon instead because nbcon
++ * consoles cannot print simultaneously with boot consoles.
+ */
+ if (is_panic_context)
-+ nbcon_atomic_flush_all();
++ nbcon_atomic_flush_pending();
+ }
+
+ if (do_trylock_unlock) {
/*
* The caller may be holding system-critical or
* timing-sensitive locks. Disable preemption during
-@@ -2378,10 +2417,10 @@ asmlinkage int vprintk_emit(int facility
+@@ -2384,10 +2430,10 @@ asmlinkage int vprintk_emit(int facility
preempt_enable();
}