Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1830564ybl; Thu, 5 Dec 2019 07:42:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyjE3vqbD5EFbOzb3paVFsh/1dq8zo0DBvx160DYbcUhn75YbfY2ccIakiuxN/PrurCgGUk X-Received: by 2002:a9d:39b5:: with SMTP id y50mr7152576otb.162.1575560521751; Thu, 05 Dec 2019 07:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575560521; cv=none; d=google.com; s=arc-20160816; b=TZpFE5v3Ax/i9euuKvjUSN1Olb6TIc/9CUlVtHRj2p6q5/APpafRCPS9Sl42M0xUp7 zABkzZQ0i6IKjrl6wdTYsa+N4pHq+EMWDZPyHW31yyLrgfMJwPliLrRfUkLhOAHzH4PF 918bMhrcs7oe5fRk5Iszdxk27JNfiW/a3zE2ukEn9UbAImB71ZOJiJdBp1rDUY9DDqrp 2VPS2h4jprmJa+/B8c+fiI6D198KhN+RvJZ0h/RZTf4OK2rErUn79kLGbH2wKlmpMi3/ eFUYVGGRwWPSY5Li/hNoq0odfugyu+vNfOCAeqInt9uqOoVy6nQs/6JIlpKJ/ZQGonKL nIZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wqt17/O8Y7rvBVYZ7o7fDZNIdNzlEfuRTH0+EnFXCwc=; b=Bv9mDWnAjlPCs8oUeunuDC/EkG2EN1GMPQXywAyLZz7wbWNOs5P4YsZGDk1CQsuBfB ieGzTsdcEdUgox8IgP8Du/P7KBMhTIOE86Lq0CuOrQO39yE6QcdM0Gg61+eHtXgFfJxs V6L+D2cYGByI82fapBiSJhmZSRCwIlxeKx4ODQfdaHLpmVyM5/hiSMqmiGKg4z+gru7j j5adV1mElgdX5n8Q33kAt+IK+1MG5Az9X9/ZdWoTCuj7Pvi7clsot3wLm49Ihgp+yD1B XmzfYQ6nuuVV/iC4UiF1R5/1osg5oH8xND+CXqQ8ngYw9hwnxeMYOm3w42IzhzHTg5ui 5Anw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gopFO7C0; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si5120978otr.166.2019.12.05.07.41.47; Thu, 05 Dec 2019 07:42:01 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gopFO7C0; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729547AbfLEPkE (ORCPT + 99 others); Thu, 5 Dec 2019 10:40:04 -0500 Received: from mail-qv1-f68.google.com ([209.85.219.68]:34734 "EHLO mail-qv1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbfLEPkD (ORCPT ); Thu, 5 Dec 2019 10:40:03 -0500 Received: by mail-qv1-f68.google.com with SMTP id o18so1440355qvf.1 for ; Thu, 05 Dec 2019 07:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wqt17/O8Y7rvBVYZ7o7fDZNIdNzlEfuRTH0+EnFXCwc=; b=gopFO7C09s5VI0YWLdHIV8Et9ssr/FP3k+hUed9ePI3ydQFxj2sbiOyXu7BNb/9GXO mc8y1s7KCJZbosyl9HU/Ukd40/bYXZG4l6/1Gqq2Y4Trs00I2z0GA+A/cVU8AipuMyVV oTKmV9MXE37xTST6BT5C50yi2iaIWXiMMIjhAnajHSaKi2Fs6CSTh2w1M5QtzkHEFF9C TLytajpjsKROHrfy3GwelE5y0dt0mUUhKpmSuh5an5XpeFjpXmZsRKgmLjDoa1Jh7wzo ZmdNRdwOy8aCjVeNYrEtzEFfHU92q7Cf4xL+6Wus2vy61eEQ7vwSGrzjSmTKT3Ec7nD3 d1HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wqt17/O8Y7rvBVYZ7o7fDZNIdNzlEfuRTH0+EnFXCwc=; b=mvv9/FWQEdVwiR7YSXsohkv0/3Y6x0xmE+Ns56TqX6fSUNNkBxw2hEAy+PmIs/lRkP nz9hblyUXtabY+AN0OB9x7f1OI0Sf0I/SqbjWyaAHn6QFVeL9SJGV8Ryufn9671GOAhY WjmifW+awYmAwlMb/1LhprGOnrwSdgbt04Ue7+vukk14liBd6P87H5dUWQ23F3ZaioTs XuTRuZXMiJCkZD3vB82o1kK1ser/DKQHc6nUICZdAVd040aQ+JpHvpewZi8Cyn4ikMgY XmUVrYSVyQ19l6yDMGg7R41QL7eJ37Wi8iJhX3VbPUe+LxZ5WEFEZbjoZhbmO+DinnAo jSUg== X-Gm-Message-State: APjAAAWxTt4gaAbC/89o813KUms9wZjZ/PTfmuaxV/OxESI0KJlNiE7g JGLZAuPSE7STxuNTNZpJSp9JTyYM9WDzlmMQ8vt2U8Vj X-Received: by 2002:ad4:4364:: with SMTP id u4mr8094171qvt.27.1575560401814; Thu, 05 Dec 2019 07:40:01 -0800 (PST) MIME-Version: 1.0 References: <174DB3D9-8C97-4022-A5B5-6A3E007440AF@oracle.com> In-Reply-To: <174DB3D9-8C97-4022-A5B5-6A3E007440AF@oracle.com> From: Vitaly Mayatskih Date: Thu, 5 Dec 2019 10:39:50 -0500 Message-ID: Subject: Re: [PATCH ] kernel/crash_core.c - Add crashkernel=auto for x86 and Arm To: John Donnelly Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This generally depends on what goes into initrd. Kernel can't know upfront how big is kdump's initrd going to be. For example, I have systems with <1TB RAM and 750MB reserved for crashkernel. Don't think crashkernel=auto can be generalized. RHEL can implement =auto, because this is a controlled environment (well, in most cases). On Wed, Dec 4, 2019 at 11:21 AM John Donnelly wrote: > > This adds crashkernel=auto feature to configure reserved memory for > vmcore creation to both x86 and Arm platform as implemenented in > RH 4.18.0-147.el8 kernels. The values have been adjusted for x86 and > Arm based from 5.4.0 kernel crash testing. > > Signed-off-by: John Donnelly > Tested-by: John Donnelly > --- > Documentation/admin-guide/kdump/kdump.rst | 12 ++++++++++ > kernel/crash_core.c | 28 +++++++++++++++++++++-- > 2 files changed, 38 insertions(+), 2 deletions(-) > > diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst > index ac7e131d2935..7635bbb4ab34 100644 > --- a/Documentation/admin-guide/kdump/kdump.rst > +++ b/Documentation/admin-guide/kdump/kdump.rst > @@ -285,6 +285,18 @@ 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 if you have enough memory. The threshold > +is 1G on x86_64, 2G on arm64, ppc64 and ppc64le. The threshold is 4G for s390x. > +If your system memory is less than the threshold crashkernel=auto will not > +reserve memory. > + > +The automatically reserved memory size varies based on architecture. > +The size changes according to system memory size like below: > + x86_64: 1G-64G:160M,64G-1T:280M,1T-:512M > + s390x: 4G-64G:160M,64G-1T:256M,1T-:512M > + arm64: 2G-:768M > + ppc64: 2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G > + > > > Boot into System Kernel > diff --git a/kernel/crash_core.c b/kernel/crash_core.c > index 9f1557b98468..564aca60e57f 100644 > --- a/kernel/crash_core.c > +++ b/kernel/crash_core.c > @@ -7,6 +7,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -39,6 +40,15 @@ static int __init parse_crashkernel_mem(char *cmdline, > unsigned long long *crash_base) > { > char *cur = cmdline, *tmp; > + unsigned long long total_mem = system_ram; > + > + /* > + * Firmware sometimes reserves some memory regions for it's own use. > + * so we get less than actual system memory size. > + * Workaround this by round up the total size to 128M which is > + * enough for most test cases. > + */ > + total_mem = roundup(total_mem, SZ_128M); > > /* for each entry of the comma-separated list */ > do { > @@ -83,13 +93,13 @@ static int __init parse_crashkernel_mem(char *cmdline, > return -EINVAL; > } > cur = tmp; > - if (size >= system_ram) { > + if (size >= total_mem) { > pr_warn("crashkernel: invalid size\n"); > return -EINVAL; > } > > /* match ? */ > - if (system_ram >= start && system_ram < end) { > + if (total_mem >= start && total_mem < end) { > *crash_size = size; > break; > } > @@ -248,6 +258,20 @@ static int __init __parse_crashkernel(char *cmdline, > if (suffix) > return parse_crashkernel_suffix(ck_cmdline, crash_size, > suffix); > + > + if (strncmp(ck_cmdline, "auto", 4) == 0) { > +#ifdef CONFIG_X86_64 > + ck_cmdline = "1G-64G:160M,64G-1T:280M,1T-:512M"; > +#elif defined(CONFIG_S390) > + ck_cmdline = "4G-64G:160M,64G-1T:256M,1T-:512M"; > +#elif defined(CONFIG_ARM64) > + ck_cmdline = "2G-:768M"; > +#elif defined(CONFIG_PPC64) > + ck_cmdline = "2G-4G:384M,4G-16G:512M,16G-64G:1G,64G-128G:2G,128G-:4G"; > +#endif > + pr_info("Using crashkernel=auto, the size chosen is a best effort estimation.\n"); > + } > + > /* > * if the commandline contains a ':', then that's the extended > * syntax -- if not, it must be the classic syntax > -- > 2.20.1 > > -- wbr, Vitaly