Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp57389ybi; Thu, 23 May 2019 23:34:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXpx88PvH77arJJpcYe0ZRoanBH7kTLk9w56V8atNzNOl5u0AJhvCG/fcr2Bh59jLjtKov X-Received: by 2002:a17:902:b581:: with SMTP id a1mr101644302pls.206.1558679651844; Thu, 23 May 2019 23:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558679651; cv=none; d=google.com; s=arc-20160816; b=trTrhF3HSozZoWGSYe6MV9D1+RJ/DONcGPTbXelbLVEA2QJxOTWKMqPoE863pQihu0 TXRYzIGs1/zIwnqU2XHxHjzHYGq/jRUKmnS5SD0Hjx0eVF8zeuruP2N4BNQKn5z2ANjo 81GNPi9Xpji/wRLeJFB3i8mzNcE7HUBO1WYbc60rAmKxU4y8gLrO/GV43dQXaicbc+b/ nX5Eqd47DQDnMxZsWVWwd599pdBeVzc415CgcY4QVyPYXbdArJ4Si5IRPgGeXDXDS/PI 77PII+87O+cIVYh5N/Z5TSVdy/RuQzO7pT5bywBFHh9Hobo8pfHDUc/WWSbrqkK69Qzj rSrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=VS1s6YZ3CmuSrTj7DKryZGxYuMfK7hoeteiiIW8N3oc=; b=gpwYmrX+Oyv4igQmc5vqJ5T9ox1D2lMhsc0ia2MzVgJRe8M1HiaBCJSLf8HWhH2AYm Hpz9W4QQkQOdmr6T4YlYR1FgPE2UE0ohpx9MymIviXlxhMJ+CXeS4uFPnuNKAJpHWiyT 6gFhyY3UJVVNqc2XRr4/27FIIfRCvtrqJz5UxxrfY//4Ss3B85w65rO4Gi7m9enW26ZE ZVD550CmndsfeUL/iSaJt7RLPTqkNJNBOIbQoXPNtGHaf2qeVfe+K3uDy1IMzl0Mop3h CVrQfyNmJGYn+KcT4YintosepmGipHpUgLDJi2IVrXzC7IQ4Rn2bEJAe2tvMHXcAE/kM 5Zng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si2852775pla.122.2019.05.23.23.33.51; Thu, 23 May 2019 23:34:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387936AbfEXGao (ORCPT + 99 others); Fri, 24 May 2019 02:30:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53302 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388185AbfEXGan (ORCPT ); Fri, 24 May 2019 02:30:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D38030044CA; Fri, 24 May 2019 06:30:41 +0000 (UTC) Received: from kasong-rh-laptop.pek2.redhat.com (wlc-trust-142.pek2.redhat.com [10.72.3.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16ED11001DED; Fri, 24 May 2019 06:30:33 +0000 (UTC) From: Kairui Song To: linux-kernel@vger.kernel.org Cc: Rahul Lakkireddy , "David S . Miller" , Eric Biederman , Alexey Dobriyan , Andrew Morton , Dave Young , "kexec@lists.infradead.org" , Bhupesh Sharma , Kairui Song Subject: [PATCH v3] vmcore: Add a kernel parameter vmcore_device_dump Date: Fri, 24 May 2019 14:29:22 +0800 Message-Id: <20190524062922.26399-1-kasong@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 24 May 2019 06:30:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since commit 2724273e8fd0 ("vmcore: add API to collect hardware dump in second kernel"), drivers is allowed to add device related dump data to vmcore as they want by using the device dump API. This have 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 vmcore_device_dump= kernel parameter, and disable device dump by default. User can enable it only if device dump data is required for debugging, and have the chance to increase the kdump reserved memory accordingly before device dump fails kdump. Signed-off-by: Kairui Song --- Update from V2: - Improve related docs Update from V1: - Use bool parameter to turn it on/off instead of letting user give the size limit. Size of device dump is hard to determine. Documentation/admin-guide/kernel-parameters.txt | 14 ++++++++++++++ fs/proc/Kconfig | 6 ++++-- fs/proc/vmcore.c | 13 +++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 138f6664b2e2..3706ad9e1d97 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5078,6 +5078,20 @@ decrease the size and leave more room for directly mapped kernel RAM. + vmcore_device_dump= [KNL,KDUMP] + Format: {"off" | "on"} + Depends on CONFIG_PROC_VMCORE_DEVICE_DUMP. + This parameter allows enable or disable device dump + for vmcore on kernel start-up. + Device dump allows drivers to append dump data to + vmcore so you can collect driver specified debug info. + Note that the drivers could append the data without + any limit, and the data is stored in memory, this may + bring a significant memory stress. If you want to turn + on this option, make sure you have reserved enough memory + with crashkernel= parameter. + default: off + vmcp_cma=nn[MG] [KNL,S390] Sets the memory size reserved for contiguous memory allocations for the vmcp device driver. diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig index 817c02b13b1d..1a7a38976bb0 100644 --- a/fs/proc/Kconfig +++ b/fs/proc/Kconfig @@ -56,8 +56,10 @@ config PROC_VMCORE_DEVICE_DUMP recovery kernel's initramfs to collect its underlying device snapshot. - If you say Y here, the collected device dumps will be added - as ELF notes to /proc/vmcore. + If you say Y here, a new kernel parameter 'vmcore_device_dump' + will be available. You can then enable device dump by passing + 'vmcore_device_dump=on' to kernel, the collected device dumps + will be added as ELF notes to /proc/vmcore. config PROC_SYSCTL bool "Sysctl support (/proc/sys)" if EXPERT diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index 3fe90443c1bb..d1b608b0efad 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -53,6 +53,8 @@ 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_enabled; #endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ /* Device Dump Size */ @@ -1451,6 +1453,11 @@ int vmcore_add_device_dump(struct vmcoredd_data *data) size_t data_size; int ret; + if (!vmcoredd_enabled) { + pr_err_once("Device dump is disabled\n"); + return -EINVAL; + } + if (!data || !strlen(data->dump_name) || !data->vmcoredd_callback || !data->size) return -EINVAL; @@ -1502,6 +1509,12 @@ int vmcore_add_device_dump(struct vmcoredd_data *data) return ret; } EXPORT_SYMBOL(vmcore_add_device_dump); + +static int __init vmcoredd_parse_cmdline(char *arg) +{ + return kstrtobool(arg, &vmcoredd_enabled); +} +__setup("vmcore_device_dump=", vmcoredd_parse_cmdline); #endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ /* Free all dumps in vmcore device dump list */ -- 2.21.0