lkml.org 
[lkml]   [2017]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC][PATCHv5 11/13] printk: always offload printing from user-space processes
Date
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@gmail.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
\
 
 \ /
  Last update: 2017-08-15 05:01    [W:0.198 / U:16.472 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site