[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170815025625.1977-12-sergey.senozhatsky@gmail.com>
Date: Tue, 15 Aug 2017 11:56:23 +0900
From: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To: Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>
Cc: Jan Kara <jack@...e.cz>, Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
"Rafael J . Wysocki" <rjw@...ysocki.net>,
Eric Biederman <ebiederm@...ssion.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jslaby@...e.com>, Pavel Machek <pavel@....cz>,
Andreas Mohr <andi@...as.de>,
Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>,
linux-kernel@...r.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Subject: [RFC][PATCHv5 11/13] printk: always offload printing from user-space processes
console_lock() and, thus, console_unlock() can be executed by
user-space processes doing sys calls (e.g. tty, drm, etc.) so we
may end up in a situation when systemd loops in console_unlock()
printing kernel messages. Always offload printing duty from
user-space process (if we can safely wake up printk_kthread,
of course).
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
---
kernel/printk/printk.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 6da4e21c3b45..0ffbaa33280f 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -592,6 +592,13 @@ static inline bool console_offload_printing(void)
if (!is_printk_offloading_safe())
return false;
+ /*
+ * Always offload from user-space processes, we've got printk kthread
+ * for printing.
+ */
+ if (!(current->flags & PF_KTHREAD))
+ goto offload;
+
/* A new task - reset the counters. */
if (printing_task != current) {
printing_start_ts = local_clock() >> 30LL;
@@ -634,6 +641,7 @@ static inline bool console_offload_printing(void)
return true;
}
+offload:
/*
* We try to set `printk_kthread' CPU affinity to any online CPU
* except for this_cpu. Because otherwise `printk_kthread' may be
--
2.14.1
Powered by blists - more mailing lists