[RFC][PATCHv6 03/12] printk: consider watchdogs thresholds for offloading

Sergey Senozhatsky
2017-12-04T13:49:02Z

There are several watchdogs, using different timeout values, so
we need to set printk offloading threshold appropriately. This
patch set extends offloading_threshold() to take RCU, softlockup
and hardlockup timeouts into consideration.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
kernel/printk/printk.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f4e84f83bff5..3d4df3f02854 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -492,10 +492,29 @@ void printk_emergency_end(void)
}
EXPORT_SYMBOL_GPL(printk_emergency_end);

+/*
+ * Adjust max timeout value in the following order:
+ * a) 1/2 of RCU stall timeout - it is usually the largest
+ * b) 1/2 of hardlockup threshold (if enabled) - lower than softlockup
+ * c) 1/2 of softlockup threshold (if enabled)
+ * e) default value - 10 seconds
+ */
static inline int offloading_threshold(void)
{
+ int timeout = CONFIG_RCU_CPU_STALL_TIMEOUT / 2 + 1;
+
+#ifdef CONFIG_LOCKUP_DETECTOR
+ /* Hardlockup detector has a sample_period of `watchdog_thresh'. */
+ if ((watchdog_enabled & NMI_WATCHDOG_ENABLED) && watchdog_thresh)
+ return min(timeout, watchdog_thresh / 2) + 1;
+
+ /* Softlockup uses '2 * watchdog_thresh' as a threshold value. */
+ if ((watchdog_enabled & SOFT_WATCHDOG_ENABLED) && watchdog_thresh)
+ return min(timeout, watchdog_thresh) + 1;
+#endif
+
/* Default threshold value is 10 seconds */
- return 10;
+ return min(10, timeout);
}

/*
--
2.15.1