summaryrefslogtreecommitdiffstats
path: root/debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:39:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:39:59 +0000
commit27d3313807296c3943a96ceef8c2b7279cb56962 (patch)
tree7d08e78c36ab6437b403fc7cd8c23e41f135c7a3 /debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch
parentMerging upstream version 6.7.7. (diff)
downloadlinux-27d3313807296c3943a96ceef8c2b7279cb56962.tar.xz
linux-27d3313807296c3943a96ceef8c2b7279cb56962.zip
Adding debian version 6.7.7-1.debian/6.7.7-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch')
-rw-r--r--debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch135
1 files changed, 135 insertions, 0 deletions
diff --git a/debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch b/debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch
new file mode 100644
index 0000000000..8360fe1876
--- /dev/null
+++ b/debian/patches-rt/0042-printk-nbcon-Start-printing-threads.patch
@@ -0,0 +1,135 @@
+From: John Ogness <john.ogness@linutronix.de>
+Date: Tue, 5 Dec 2023 14:09:31 +0000
+Subject: [PATCH 42/50] printk: nbcon: Start printing threads
+Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.7/older/patches-6.7-rt6.tar.xz
+
+If there are no boot consoles, the printing threads are started
+in early_initcall.
+
+If there are boot consoles, the printing threads are started
+after the last boot console has unregistered. The printing
+threads do not need to be concerned about boot consoles because
+boot consoles cannot register once a non-boot console has
+registered.
+
+Until a printing thread of a console has started, that console
+will print using atomic_write() in the printk() caller context.
+
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/printk/internal.h | 2 ++
+ kernel/printk/nbcon.c | 18 +++++++++++++++++-
+ kernel/printk/printk.c | 14 ++++++++++++++
+ 3 files changed, 33 insertions(+), 1 deletion(-)
+
+--- a/kernel/printk/internal.h
++++ b/kernel/printk/internal.h
+@@ -44,6 +44,7 @@ enum printk_info_flags {
+ };
+
+ extern struct printk_ringbuffer *prb;
++extern bool printk_threads_enabled;
+ extern bool have_legacy_console;
+ extern bool have_boot_console;
+
+@@ -161,6 +162,7 @@ static inline void nbcon_kthread_wake(st
+
+ static inline void nbcon_kthread_wake(struct console *con) { }
+ static inline void nbcon_kthread_create(struct console *con) { }
++#define printk_threads_enabled (false)
+ #define printing_via_unlock (false)
+
+ /*
+--- a/kernel/printk/nbcon.c
++++ b/kernel/printk/nbcon.c
+@@ -205,6 +205,8 @@ static void nbcon_seq_try_update(struct
+ }
+ }
+
++bool printk_threads_enabled __ro_after_init;
++
+ /**
+ * nbcon_context_try_acquire_direct - Try to acquire directly
+ * @ctxt: The context of the caller
+@@ -1401,7 +1403,7 @@ void nbcon_kthread_create(struct console
+ if (!(con->flags & CON_NBCON) || !con->write_thread)
+ return;
+
+- if (con->kthread)
++ if (!printk_threads_enabled || con->kthread)
+ return;
+
+ /*
+@@ -1427,6 +1429,19 @@ void nbcon_kthread_create(struct console
+ sched_set_normal(con->kthread, -20);
+ }
+
++static int __init printk_setup_threads(void)
++{
++ struct console *con;
++
++ console_list_lock();
++ printk_threads_enabled = true;
++ for_each_console(con)
++ nbcon_kthread_create(con);
++ console_list_unlock();
++ return 0;
++}
++early_initcall(printk_setup_threads);
++
+ /**
+ * nbcon_alloc - Allocate buffers needed by the nbcon console
+ * @con: Console to allocate buffers for
+@@ -1477,6 +1492,7 @@ void nbcon_init(struct console *con)
+ init_irq_work(&con->irq_work, nbcon_irq_work);
+ nbcon_seq_force(con, con->seq);
+ nbcon_state_set(con, &state);
++ nbcon_kthread_create(con);
+ }
+
+ /**
+--- a/kernel/printk/printk.c
++++ b/kernel/printk/printk.c
+@@ -2388,6 +2388,9 @@ asmlinkage int vprintk_emit(int facility
+ *
+ * - When this CPU is in panic.
+ *
++ * - When booting, before the printing threads have been
++ * started.
++ *
+ * - During shutdown, since the printing threads may not get
+ * a chance to print the final messages.
+ *
+@@ -2397,6 +2400,7 @@ asmlinkage int vprintk_emit(int facility
+ * with boot consoles.
+ */
+ if (is_panic_context ||
++ !printk_threads_enabled ||
+ (system_state > SYSTEM_RUNNING)) {
+ nbcon_atomic_flush_all();
+ }
+@@ -3692,6 +3696,7 @@ EXPORT_SYMBOL(register_console);
+ /* Must be called under console_list_lock(). */
+ static int unregister_console_locked(struct console *console)
+ {
++ bool is_boot_con = (console->flags & CON_BOOT);
+ bool found_legacy_con = false;
+ bool found_nbcon_con = false;
+ bool found_boot_con = false;
+@@ -3763,6 +3768,15 @@ static int unregister_console_locked(str
+ if (!found_nbcon_con)
+ have_nbcon_console = false;
+
++ /*
++ * When the last boot console unregisters, start up the
++ * printing threads.
++ */
++ if (is_boot_con && !have_boot_console) {
++ for_each_console(c)
++ nbcon_kthread_create(c);
++ }
++
+ return res;
+ }
+