From patchwork Fri May 7 01:04:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12243793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 150C2C433B4 for ; Fri, 7 May 2021 01:04:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A222F610FA for ; Fri, 7 May 2021 01:04:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A222F610FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 391016B00B3; Thu, 6 May 2021 21:04:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33F736B00B4; Thu, 6 May 2021 21:04:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 145F86B00B5; Thu, 6 May 2021 21:04:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id E17256B00B3 for ; Thu, 6 May 2021 21:04:34 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A532A181AEF23 for ; Fri, 7 May 2021 01:04:34 +0000 (UTC) X-FDA: 78112639668.19.BE4F982 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf22.hostedemail.com (Postfix) with ESMTP id A7EB5C0001FE for ; Fri, 7 May 2021 01:04:26 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A3C261041; Fri, 7 May 2021 01:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1620349473; bh=FQF8djJT0KzhqELEGFSpdi0mXRoyiiCyMFvSe5r+J8o=; h=Date:From:To:Subject:In-Reply-To:From; b=qHkT+rMeBieB3lUX2QdKLWqzzajJfUFC7jO422uqhR7Y5RXgm6Njlx2roHhPBHDcj Su/YWJmBCVfm6ZYOyO/WLnDKL2GYaW2VFqLsghhZa5MDphewZY1yXrVPnNZzkH9I70 loMC5HFyam8q+1uazQ/XAPowkG47uQJ3KQHXmUiY= Date: Thu, 06 May 2021 18:04:32 -0700 From: Andrew Morton To: akpm@linux-foundation.org, andreyknvl@google.com, bhe@redhat.com, christian.brauner@ubuntu.com, colin.king@canonical.com, corbet@lwn.net, dyoung@redhat.com, frederic@kernel.org, gpiccoli@canonical.com, john.p.donnelly@oracle.com, jpoimboe@redhat.com, keescook@chromium.org, linux-mm@kvack.org, masahiroy@kernel.org, mchehab+huawei@kernel.org, mike.kravetz@oracle.com, mingo@kernel.org, mm-commits@vger.kernel.org, paulmck@kernel.org, peterz@infradead.org, rdunlap@infradead.org, rostedt@goodmis.org, rppt@kernel.org, saeed.mirzamohammadi@oracle.com, samitolvanen@google.com, sboyd@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, vgoyal@redhat.com, yifeifz2@illinois.edu Subject: [patch 48/91] kernel/crash_core: add crashkernel=auto for vmcore creation Message-ID: <20210507010432.IN24PudKT%akpm@linux-foundation.org> In-Reply-To: <20210506180126.03e1baee7ca52bedb6cc6003@linux-foundation.org> User-Agent: s-nail v14.8.16 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=qHkT+rMe; dmarc=none; spf=pass (imf22.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: e1y16kjit9ahhm7xedjrw8f6q9uohwty X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A7EB5C0001FE Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620349466-212799 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Saeed Mirzamohammadi Subject: kernel/crash_core: add crashkernel=auto for vmcore creation This adds crashkernel=auto feature to configure reserved memory for vmcore creation. CONFIG_CRASH_AUTO_STR is defined to be set for different kernel distributions and different archs based on their needs. Link: https://lkml.kernel.org/r/20210223174153.72802-1-saeed.mirzamohammadi@oracle.com Signed-off-by: Saeed Mirzamohammadi Signed-off-by: John Donnelly Tested-by: John Donnelly ed-by: Dave Young Cc: Baoquan He Cc: Vivek Goyal Cc: Jonathan Corbet Cc: "Paul E. McKenney" Cc: Randy Dunlap Cc: Thomas Gleixner Cc: Mauro Carvalho Chehab Cc: Mike Kravetz Cc: "Guilherme G. Piccoli" Cc: Kees Cook Cc: "Peter Zijlstra (Intel)" Cc: Ingo Molnar Cc: "Steven Rostedt (VMware)" Cc: YiFei Zhu Cc: Josh Poimboeuf Cc: Mike Rapoport Cc: Masahiro Yamada Cc: Sami Tolvanen Cc: Frederic Weisbecker Cc: Christian Brauner Cc: Stephen Boyd Cc: Andrey Konovalov Cc: Colin Ian King Signed-off-by: Andrew Morton --- Documentation/admin-guide/kdump/kdump.rst | 3 +- Documentation/admin-guide/kernel-parameters.txt | 6 ++++ arch/Kconfig | 20 ++++++++++++++ kernel/crash_core.c | 7 ++++ 4 files changed, 35 insertions(+), 1 deletion(-) --- a/arch/Kconfig~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +++ a/arch/Kconfig @@ -14,6 +14,26 @@ menu "General architecture-dependent opt config CRASH_CORE bool +config CRASH_AUTO_STR + string "Memory reserved for crash kernel" + depends on CRASH_CORE + default "1G-64G:128M,64G-1T:256M,1T-:512M" + help + This configures the reserved memory dependent + on the value of System RAM. The syntax is: + crashkernel=:[,:,...][@offset] + range=start-[end] + + For example: + crashkernel=512M-2G:64M,2G-:128M + + This would mean: + + 1) if the RAM is smaller than 512M, then don't reserve anything + (this is the "rescue" case) + 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M + 3) if the RAM size is larger than 2G, then reserve 128M + config KEXEC_CORE select CRASH_CORE bool --- a/Documentation/admin-guide/kdump/kdump.rst~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +++ a/Documentation/admin-guide/kdump/kdump.rst @@ -285,7 +285,8 @@ This would mean: 2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M 3) if the RAM size is larger than 2G, then reserve 128M - +Or you can use crashkernel=auto to choose the crash kernel memory size +based on the recommended configuration set for each arch. Boot into System Kernel ======================= --- a/Documentation/admin-guide/kernel-parameters.txt~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +++ a/Documentation/admin-guide/kernel-parameters.txt @@ -751,6 +751,12 @@ a memory unit (amount[KMG]). See also Documentation/admin-guide/kdump/kdump.rst for an example. + crashkernel=auto + [KNL] This parameter will set the reserved memory for + the crash kernel based on the value of the CRASH_AUTO_STR + that is the best effort estimation for each arch. See also + arch/Kconfig for further details. + crashkernel=size[KMG],high [KNL, X86-64] range could be above 4G. Allow kernel to allocate physical memory region from top, so could --- a/kernel/crash_core.c~kernel-crash_core-add-crashkernel=auto-for-vmcore-creation +++ a/kernel/crash_core.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -250,6 +251,12 @@ static int __init __parse_crashkernel(ch if (suffix) return parse_crashkernel_suffix(ck_cmdline, crash_size, suffix); +#ifdef CONFIG_CRASH_AUTO_STR + if (strncmp(ck_cmdline, "auto", 4) == 0) { + ck_cmdline = CONFIG_CRASH_AUTO_STR; + pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n"); + } +#endif /* * if the commandline contains a ':', then that's the extended * syntax -- if not, it must be the classic syntax