vmcore: add a kernel parameter novmcoredd
authorKairui Song <kasong@redhat.com>
Tue, 16 Jul 2019 23:26:39 +0000 (16:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 17 Jul 2019 02:23:21 +0000 (19:23 -0700)
Since commit 2724273e8fd0 ("vmcore: add API to collect hardware dump in
second kernel"), drivers are allowed to add device related dump data to
vmcore as they want by using the device dump API.  This has a potential
issue, the data is stored in memory, drivers may append too much data
and use too much memory.  The vmcore is typically used in a kdump kernel
which runs in a pre-reserved small chunk of memory.  So as a result it
will make kdump unusable at all due to OOM issues.

So introduce new 'novmcoredd' command line option.  User can disable
device dump to reduce memory usage.  This is helpful if device dump is
using too much memory, disabling device dump could make sure a regular
vmcore without device dump data is still available.

[akpm@linux-foundation.org: tweak documentation]
[akpm@linux-foundation.org: vmcore.c needs moduleparam.h]
Link: http://lkml.kernel.org/r/20190528111856.7276-1-kasong@redhat.com
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Bhupesh Sharma <bhsharma@redhat.com>
Cc: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Cc: "David S . Miller" <davem@davemloft.net>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/admin-guide/kernel-parameters.txt
fs/proc/Kconfig
fs/proc/vmcore.c

index f8b62360b18cf6c565a7bf68f8168477cf417589..bf8221abfe0aaa77d2ec52a4819c34ab8874d5a9 100644 (file)
                        /sys/module/printk/parameters/console_suspend) to
                        turn on/off it dynamically.
 
+       novmcoredd      [KNL,KDUMP]
+                       Disable device dump. Device dump allows drivers to
+                       append dump data to vmcore so you can collect driver
+                       specified debug info.  Drivers can append the data
+                       without any limit and this data is stored in memory,
+                       so this may cause significant memory stress.  Disabling
+                       device dump can help save memory but the driver debug
+                       data will be no longer available.  This parameter
+                       is only available when CONFIG_PROC_VMCORE_DEVICE_DUMP
+                       is set.
+
        noaliencache    [MM, NUMA, SLAB] Disables the allocation of alien
                        caches in the slab allocator.  Saves per-node memory,
                        but will impact performance.
index 4c3dcb718961d1a13d27465b3bf3fea6c8744d95..cba429db95d940e3641d3981064622e90a6475e9 100644 (file)
@@ -58,7 +58,8 @@ config PROC_VMCORE_DEVICE_DUMP
          snapshot.
 
          If you say Y here, the collected device dumps will be added
-         as ELF notes to /proc/vmcore.
+         as ELF notes to /proc/vmcore. You can still disable device
+         dump using the kernel command line option 'novmcoredd'.
 
 config PROC_SYSCTL
        bool "Sysctl support (/proc/sys)" if EXPERT
index 57957c91c6dffc4db696b84630c4fa94cc52e408..7bcc92add72c1f1559e48eed956a58ec91ac824e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/crash_dump.h>
 #include <linux/list.h>
+#include <linux/moduleparam.h>
 #include <linux/mutex.h>
 #include <linux/vmalloc.h>
 #include <linux/pagemap.h>
@@ -54,6 +55,9 @@ static struct proc_dir_entry *proc_vmcore;
 /* Device Dump list and mutex to synchronize access to list */
 static LIST_HEAD(vmcoredd_list);
 static DEFINE_MUTEX(vmcoredd_mutex);
+
+static bool vmcoredd_disabled;
+core_param(novmcoredd, vmcoredd_disabled, bool, 0);
 #endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */
 
 /* Device Dump Size */
@@ -1452,6 +1456,11 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
        size_t data_size;
        int ret;
 
+       if (vmcoredd_disabled) {
+               pr_err_once("Device dump is disabled\n");
+               return -EINVAL;
+       }
+
        if (!data || !strlen(data->dump_name) ||
            !data->vmcoredd_callback || !data->size)
                return -EINVAL;