lkml.org 
[lkml]   [2017]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCH 2/4] printk: offload printing from wake_up_klogd_work_func()
Date
Offload printing of printk_deferred() messages from IRQ context
to a schedulable printing kthread, when possible (the same way
we do it in vprintk_emit()). Otherwise, console_unlock() can
force the printing CPU to spend unbound amount of time flushing
kernel messages from IRQ context.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
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 1c4232ca2e6a..6e00073a7331 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2735,9 +2735,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_enabled()) {
+ 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.12.0
\
 
 \ /
  Last update: 2017-03-06 13:55    [W:0.150 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site