[RFC][PATCHv5 08/13] printk: set watchdog_thresh as maximum value for atomic_print_limit

From: Sergey Senozhatsky
Date: Mon Aug 14 2017 - 23:00:36 EST


There is no point in setting `atomic_print_limit' significantly
larger than watchdog's lockup threshold. This highly increases
the chances of lockups. Watchdog's softlockup threshold is
`2 * watchdog_thresh', but we limit `atomic_print_limit' to just
`watchdog_thresh'.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
---
kernel/printk/printk.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index b14e35f94596..12284aa30025 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -545,6 +545,19 @@ int printk_emergency_end_sync(void)
}
EXPORT_SYMBOL_GPL(printk_emergency_end_sync);

+/*
+ * We offload to make watchdog lockup detector happy, there is little
+ * point (no point at all) in setting `atomic_print_limit' larger than
+ * `watchdog_thresh'.
+ */
+static inline void adj_atomic_print_limit(void)
+{
+#ifdef CONFIG_LOCKUP_DETECTOR
+ if (watchdog_thresh && atomic_print_limit > watchdog_thresh)
+ atomic_print_limit = watchdog_thresh;
+#endif
+}
+
/*
* Under heavy printing load or with a slow serial console (or both)
* console_unlock() can stall CPUs, which can result in soft/hard-lockups,
@@ -580,6 +593,8 @@ static inline bool console_offload_printing(void)
if (current == printk_kthread)
return false;

+ adj_atomic_print_limit();
+
if (!time_after_eq(now, printing_start_ts + atomic_print_limit))
return false;

--
2.14.1