Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp7141825imm; Sun, 20 May 2018 19:54:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZozs34FJDIbLtqSsyx0PPIqQvGn7Dym97ooWc8RdohYXd7aokALUuUKurimswmn2T9BxBde X-Received: by 2002:a17:902:8f82:: with SMTP id z2-v6mr18780635plo.350.1526871260813; Sun, 20 May 2018 19:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526871260; cv=none; d=google.com; s=arc-20160816; b=02ICDphZ8s81TnZAMkVtBO07L3WVGRS75awFpdVvgDuh4xGvgoEjsXPWxGDJl87Tdr gMMhfHouPQ3UElGbnJ3dTrqp2M75thj4ntTLmkCcI1zz+rLkBb83of+zdjO3fqIrxnY2 U2jUiVO6fUYyex+XhjzgIA9SsFd5N16bMcM4AcvTrDj+jZbJ/fpSNn72pp+A7WHKQMyZ nqLFdPyyDsygylsrgA+M/MMumWg6DHwJpjYwoODVpVQsBkW7EZRkasSgvHTohOIoSghz 1BKplFOYdfiFv/z9VazpvexELLHzQ6O5Uki9IGDEbCEPA2qdDdogNHuE/6xuCN1cpWKu 9AWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=PY9B6rgZaImTKkmghIqMfmb+MjlxV42i3adaWvq0+js=; b=Xd/EkE6cyeHGy2B8HnNh+mvPxgx0DU+7R/avH0TcwNhX2UFRkjycYKNJgevpDe53W0 mhQnZ5lopTwNlcVyCiufFb0IRg01rQ9JpSJ+HgDh6GQ7qNVEBBt5CL4deF+H0AEx3fuL kvY/8AeEMqTRCkbSCo6RkJnWQohIrkq3qheQwHlm/6Bt35ji3gndud6ZNPZPAjxUsBJc uxVqPdtYFwBNy4GpuFx+2vh7tdY64KuyFPjyOafivyLi8z0/XzX2htvCRoNH5E/oRO5u bDHXKQ0sssYhE3/PqnuN2hMcn+bcko/CXVBb9OJGG5YEup2p9s/EuZ4xg5e2COkD+fN/ PPiw== 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 21-v6si13441795pfy.293.2018.05.20.19.54.06; Sun, 20 May 2018 19:54:20 -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 S1752311AbeEUCxv (ORCPT + 99 others); Sun, 20 May 2018 22:53:51 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38776 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751162AbeEUCxt (ORCPT ); Sun, 20 May 2018 22:53:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 194AD738E0; Mon, 21 May 2018 02:53:49 +0000 (UTC) Received: from dhcp-128-65.nay.redhat.com (ovpn-12-129.pek2.redhat.com [10.72.12.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F54E63F3C; Mon, 21 May 2018 02:53:41 +0000 (UTC) Date: Mon, 21 May 2018 10:53:37 +0800 From: Dave Young To: linux-kernel@vger.kernel.org, kexec@lists.infradead.org Cc: Cong Wang , Neil Horman , Ingo Molnar , "Eric W. Biederman" , Vivek Goyal , Tony Luck , Anton Vorontsov , Michael Ellerman , Benjamin Herrenschmidt , Martin Schwidefsky , Hari Bathini , dzickus@redhat.com, bhe@redhat.com, akpm@linux-foundation.org Subject: [PATCH] kdump: add default crashkernel reserve kernel config options Message-ID: <20180521025337.GA4627@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.5 (2018-04-13) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 21 May 2018 02:53:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 21 May 2018 02:53:49 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dyoung@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a rework of the crashkernel=auto patches back to 2009 although I'm not sure if below is the last version of the old effort: https://lkml.org/lkml/2009/8/12/61 https://lwn.net/Articles/345344/ I changed the original design, instead of adding the auto reserve logic in code, in this patch just introduce two kernel config options for the default crashkernel value in MB and the threshold of system memory in MB so that only reserve default when system memory is equal or above the threshold. With the kernel configs distributions can easily change the default values so that people do not need to manually set kernel cmdline for common use cases and one can still overwrite the default value with manual setup or disable it by using crashkernel=0 Signed-off-by: Dave Young --- Another difference is with original design the crashkernel size scales with system memory, according to test, large machine may need more memory in kdump kernel because of several factors: 1. cpu numbers, because of the percpu memory allocated for cpus. (kdump can use nr_cpus=1 to workaround this, but some arches do not support nr_cpus=X for example powerpc) 2. IO devices, large system can have a lot of io devices, although we can try to only add those device drivers we needed, it is still a problem because of some built-in drivers, some stacked logical devices eg. device mapper devices, acpi etc. Even if only considering the meta data for driver model it will still be a big number eg. sysfs files etc. 3. The minimum memory requirement for some device drivers are big, even if some of them have implemented low meory profile. It is usual to see 10M memory use for a storage driver. 4. user space initramfs size growing. Busybox is not usable if we need to add udev support and some complicate storage support. Use dracut with systemd, especially networking stuff need more memory. So probably add another kernel config option to scale the memory size eg. CRASHKERNEL_DEFAULT_SCALE_RATIO is also good to have, in RHEL we use base_value + system_mem >> (2^14) for x86. I'm still hesatating how to describe and add this option. Any suggestions will be appreciated. arch/Kconfig | 16 ++++++++++++++++ kernel/crash_core.c | 23 ++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) --- linux-x86.orig/arch/Kconfig +++ linux-x86/arch/Kconfig @@ -10,6 +10,22 @@ config KEXEC_CORE select CRASH_CORE bool +config CRASHKERNEL_DEFAULT_THRESHOLD_MB + int "System memory size threshold for kdump memory default reserving" + depends on CRASH_CORE + default 0 + help + CRASHKERNEL_DEFAULT_MB is used as default crashkernel value if + the system memory size is equal or bigger than the threshold. + +config CRASHKERNEL_DEFAULT_MB + int "Default crashkernel memory size reserved for kdump" + depends on CRASH_CORE + default 0 + help + This is used as the default kdump reserved memory size in MB. + crashkernel=X kernel cmdline can overwrite this value. + config HAVE_IMA_KEXEC bool --- linux-x86.orig/kernel/crash_core.c +++ linux-x86/kernel/crash_core.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -143,6 +144,24 @@ static int __init parse_crashkernel_simp return 0; } +static int __init get_crashkernel_default(unsigned long long system_ram, + unsigned long long *size) +{ + unsigned long long sz = CONFIG_CRASHKERNEL_DEFAULT_MB; + unsigned long long thres = CONFIG_CRASHKERNEL_DEFAULT_THRESHOLD_MB; + + thres *= SZ_1M; + sz *= SZ_1M; + + if (sz >= system_ram || system_ram < thres) { + pr_debug("crashkernel default size can not be used.\n"); + return -EINVAL; + } + *size = sz; + + return 0; +} + #define SUFFIX_HIGH 0 #define SUFFIX_LOW 1 #define SUFFIX_NULL 2 @@ -240,8 +259,10 @@ static int __init __parse_crashkernel(ch *crash_size = 0; *crash_base = 0; - ck_cmdline = get_last_crashkernel(cmdline, name, suffix); + if (!strstr(cmdline, "crashkernel=")) + return get_crashkernel_default(system_ram, crash_size); + ck_cmdline = get_last_crashkernel(cmdline, name, suffix); if (!ck_cmdline) return -EINVAL;