diff options
Diffstat (limited to '')
-rw-r--r-- | debian/patches-rt/0030-printk-nbcon-Introduce-printing-kthreads.patch (renamed from debian/patches-rt/0033-printk-nbcon-Introduce-printing-kthreads.patch) | 104 |
1 files changed, 55 insertions, 49 deletions
diff --git a/debian/patches-rt/0033-printk-nbcon-Introduce-printing-kthreads.patch b/debian/patches-rt/0030-printk-nbcon-Introduce-printing-kthreads.patch index 12f69b52fc..85792a75e2 100644 --- a/debian/patches-rt/0033-printk-nbcon-Introduce-printing-kthreads.patch +++ b/debian/patches-rt/0030-printk-nbcon-Introduce-printing-kthreads.patch @@ -1,7 +1,7 @@ From: Thomas Gleixner <tglx@linutronix.de> Date: Fri, 22 Sep 2023 14:12:21 +0000 -Subject: [PATCH 33/48] printk: nbcon: Introduce printing kthreads -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.8/older/patches-6.8.2-rt11.tar.xz +Subject: [PATCH 30/46] printk: nbcon: Introduce printing kthreads +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/6.9/older/patches-6.9-rt5.tar.xz Provide the main implementation for running a printer kthread per nbcon console that is takeover/handover aware. @@ -12,10 +12,10 @@ Signed-off-by: Thomas Gleixner (Intel) <tglx@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- include/linux/console.h | 26 ++++++ - kernel/printk/internal.h | 28 +++++++ - kernel/printk/nbcon.c | 187 +++++++++++++++++++++++++++++++++++++++++++++-- - kernel/printk/printk.c | 33 ++++++++ - 4 files changed, 269 insertions(+), 5 deletions(-) + kernel/printk/internal.h | 26 ++++++ + kernel/printk/nbcon.c | 196 +++++++++++++++++++++++++++++++++++++++++++++-- + kernel/printk/printk.c | 31 +++++++ + 4 files changed, 271 insertions(+), 8 deletions(-) --- a/include/linux/console.h +++ b/include/linux/console.h @@ -25,18 +25,18 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #include <linux/rculist.h> +#include <linux/rcuwait.h> #include <linux/types.h> + #include <linux/vesa.h> - struct vc_data; -@@ -324,6 +325,8 @@ struct nbcon_drvdata { - * @nbcon_state: State for nbcon consoles +@@ -324,6 +325,8 @@ struct nbcon_write_context { * @nbcon_seq: Sequence number of the next record for nbcon to print + * @nbcon_driver_ctxt: Context available for driver non-printing operations * @pbufs: Pointer to nbcon private buffer + * @kthread: Printer kthread for this console + * @rcuwait: RCU-safe wait object for @kthread waking */ struct console { char name[16]; -@@ -372,6 +375,27 @@ struct console { +@@ -374,6 +377,27 @@ struct console { void (*write_atomic)(struct console *con, struct nbcon_write_context *wctxt); /** @@ -64,9 +64,9 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> * @device_lock: * * NBCON callback to begin synchronization with driver code. -@@ -431,6 +455,8 @@ struct console { - struct nbcon_drvdata *nbcon_drvdata; - +@@ -420,6 +444,8 @@ struct console { + atomic_long_t __private nbcon_seq; + struct nbcon_context __private nbcon_driver_ctxt; struct printk_buffers *pbufs; + struct task_struct *kthread; + struct rcuwait rcuwait; @@ -128,15 +128,6 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* * In !PRINTK builds we still export console_sem * semaphore and some of console functions (console_unlock()/etc.), so -@@ -153,6 +179,8 @@ static inline bool console_is_usable(str - - #endif /* CONFIG_PRINTK */ - -+extern bool have_boot_console; -+ - extern struct printk_buffers printk_shared_pbufs; - - /** --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -10,6 +10,7 @@ @@ -299,28 +290,45 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* Track the nbcon emergency nesting per CPU. */ static DEFINE_PER_CPU(unsigned int, nbcon_pcpu_emergency_nesting); static unsigned int early_nbcon_pcpu_emergency_nesting __initdata; -@@ -982,7 +1102,7 @@ static bool nbcon_atomic_emit_one(struct - * handed over or taken over. In both cases the context is no - * longer valid. +@@ -1012,7 +1132,7 @@ static bool nbcon_atomic_emit_one(struct + * The higher priority printing context takes over responsibility + * to print the pending records. */ - if (!nbcon_emit_next_record(wctxt)) + if (!nbcon_emit_next_record(wctxt, true)) - return true; + return false; nbcon_context_release(ctxt); -@@ -1091,7 +1211,7 @@ static bool __nbcon_atomic_flush_pending +@@ -1113,7 +1233,7 @@ static int __nbcon_atomic_flush_pending_ * handed over or taken over. In both cases the context is no * longer valid. */ - if (!nbcon_emit_next_record(&wctxt)) + if (!nbcon_emit_next_record(&wctxt, true)) - return true; + return -EAGAIN; - if (!ctxt->backlog) -@@ -1230,6 +1350,63 @@ void nbcon_cpu_emergency_exit(void) + if (!ctxt->backlog) { +@@ -1159,11 +1279,11 @@ static void nbcon_atomic_flush_pending_c + local_irq_restore(flags); + + /* +- * If flushing was successful but more records are available, this +- * context must flush those remaining records because there is no +- * other context that will do it. ++ * If flushing was successful but more records are available this ++ * context must flush those remaining records if the printer thread ++ * is not available to do it. + */ +- if (!err && prb_read_valid(prb, nbcon_seq_read(con), NULL)) { ++ if (!err && !con->kthread && prb_read_valid(prb, nbcon_seq_read(con), NULL)) { + stop_seq = prb_next_reserve_seq(prb); + goto again; + } +@@ -1315,6 +1435,63 @@ void nbcon_cpu_emergency_flush(void) + } } - /** ++/* + * nbcon_kthread_stop - Stop a printer thread + * @con: Console to operate on + */ @@ -377,19 +385,18 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> + sched_set_normal(con->kthread, -20); +} + -+/** + /** * nbcon_alloc - Allocate buffers needed by the nbcon console * @con: Console to allocate buffers for - * -@@ -1273,6 +1450,7 @@ void nbcon_init(struct console *con) +@@ -1360,6 +1537,7 @@ void nbcon_init(struct console *con, u64 /* nbcon_alloc() must have been called and successful! */ BUG_ON(!con->pbufs); + rcuwait_init(&con->rcuwait); - nbcon_seq_force(con, 0); + nbcon_seq_force(con, init_seq); nbcon_state_set(con, &state); } -@@ -1285,6 +1463,7 @@ void nbcon_free(struct console *con) +@@ -1372,6 +1550,7 @@ void nbcon_free(struct console *con) { struct nbcon_state state = { }; @@ -397,18 +404,17 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> nbcon_state_set(con, &state); /* Boot consoles share global printk buffers. */ +@@ -1440,6 +1619,7 @@ void nbcon_driver_release(struct console + */ + cookie = console_srcu_read_lock(); + if (console_is_usable(con, console_srcu_read_flags(con)) && ++ !con->kthread && + prb_read_valid(prb, nbcon_seq_read(con), NULL)) { + __nbcon_atomic_flush_pending_con(con, prb_next_reserve_seq(prb), false); + } --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c -@@ -483,7 +483,7 @@ static bool have_nbcon_console; - * the console lock. This is because boot consoles and nbcon consoles may - * have mapped the same hardware. - */ --static bool have_boot_console; -+bool have_boot_console; - - /* - * Specifies if the console lock/unlock dance is needed for console -@@ -2698,6 +2698,8 @@ void suspend_console(void) +@@ -2685,6 +2685,8 @@ void suspend_console(void) void resume_console(void) { struct console *con; @@ -417,7 +423,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> if (!console_suspend_enabled) return; -@@ -2714,6 +2716,14 @@ void resume_console(void) +@@ -2701,6 +2703,14 @@ void resume_console(void) */ synchronize_srcu(&console_srcu); @@ -432,7 +438,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> pr_flush(1000, true); } -@@ -3034,6 +3044,13 @@ static bool console_flush_all(bool do_co +@@ -3021,6 +3031,13 @@ static bool console_flush_all(bool do_co u64 printk_seq; bool progress; @@ -446,7 +452,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> if (!console_is_usable(con, flags)) continue; any_usable = true; -@@ -3327,9 +3344,23 @@ EXPORT_SYMBOL(console_stop); +@@ -3314,9 +3331,23 @@ EXPORT_SYMBOL(console_stop); void console_start(struct console *console) { |