[RFC][PATCHv5 04/13] printk: add enforce_emergency parameter

Sergey Senozhatsky
2017-08-15T03:00:16Z

This param permits user-space to forcibly on/off printk emergency
mode via `/sys/module/printk/parameters/enforce_emergency' node.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
Documentation/admin-guide/kernel-parameters.txt | 7 +++++++
kernel/printk/printk.c | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b5b6d5d24596..001f578ec5f5 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3215,6 +3215,13 @@

default: off.

+ printk.enforce_emergency=
+ This parameter allows to disable/enable printing
+ offloading to printk kthread.
+ Format: <bool> (1 - emergency, 0 - permit offloading).
+
+ default: off.
+
processor.max_cstate= [HW,ACPI]
Limit processor to maximum C-state
max_cstate=9 overrides any DMI blacklist limit.
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 5d4b4beeebf5..3a0e78812818 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -455,9 +455,15 @@ static cpumask_var_t printk_offload_cpus;
static atomic_t printk_emergency __read_mostly;
/*
* Disable printk_kthread permanently. Unlike `oops_in_progress'
- * it doesn't go back to 0.
+ * it doesn't go back to 0 (unless set by user-space).
*/
static bool printk_enforce_emergency __read_mostly;
+
+module_param_named(enforce_emergency, printk_enforce_emergency,
+ bool, 0644);
+MODULE_PARM_DESC(printk_enforce_emergency,
+ "don't offload message printing to printk kthread");
+
/*
* The number of seconds a task can print before it offloads printing
* duty to printk_kthread. 0 indicates 'no limit'.
--
2.14.1