[PATCH v12 2/3] printk: Make wake_up_klogd_work_func() async
From: Sergey Senozhatsky
Date: Fri May 13 2016 - 08:21:39 EST
From: Jan Kara <jack@xxxxxxx>
Offload printing of scheduler deferred messages from IRQ context
to a schedulable printing kthread, when possible (the same way we
do it in vprintk_emit()). Otherwise, the CPU can spend unbounded
amount of time doing printing in console_unlock() from IRQ.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
Signed-off-by: Jan Kara <jack@xxxxxxx>
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
---
kernel/printk/printk.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index c0e49ff..0fb0c04 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2881,9 +2881,16 @@ static void wake_up_klogd_work_func(struct irq_work *irq_work)
int pending = __this_cpu_xchg(printk_pending, 0);
if (pending & PRINTK_PENDING_OUTPUT) {
- /* If trylock fails, someone else is doing the printing */
- if (console_trylock())
- console_unlock();
+ if (printk_kthread) {
+ wake_up_process(printk_kthread);
+ } else {
+ /*
+ * If trylock fails, someone else is doing
+ * the printing
+ */
+ if (console_trylock())
+ console_unlock();
+ }
}
if (pending & PRINTK_PENDING_WAKEUP)
--
2.8.2.372.g63a3502