From: Baoquan He <bhe@redhat.com>
To: dyoung@redhat.com
Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
akpm@linux-foundation.org, vgoyal@redhat.com, yinghai@kernel.org,
corbet@lwn.net
Subject: Re: [PATCH 1/3] kdump: extend crashkernel=range:size to dynamically increase reservation size
Date: Tue, 24 Oct 2017 14:00:44 +0800 [thread overview]
Message-ID: <20171024060044.GH27757@x1> (raw)
In-Reply-To: <20171024053901.703527837@redhat.com>
On 10/24/17 at 01:31pm, Dave Young wrote:
> crashkernel=range:size syntax allows to reserve specified size for system
> with total memory fall into the specified range. For example:
> crashkernel=2G-3G:128M,3G-:256M reserves 128M for system with memory >=2G
> and memory <3G, and reserves 256M for system with memory >= 3G
>
> In the above case 256M as a fixed value which can not fulfill very huge
> systems with large memory and IO devices. As memory size increases usually
> minimum memory requirement for booting will also increase. It is nearly
> impossible for a kernel to run with a fixed limited memory size for all
> kinds of systems.
>
> Thus extend the crashkernel=range:size to let user specify the scaling
> ratio in kernel cmdline like below:
> crashkernel=range:size^order, for example:
> crashkernel=2G-:128M^14 reserve 128M + (total_memory - 128M) >> 14
> for machines with over 2G memory.
Well, ah.., this look a little ugly and tricky. Leave this to other
reviewers to comment.
>
> Also s/start-[end]/[start]-end/ in kernel-parameters.txt according to code
>
> Signed-off-by: Dave Young <dyoung@redhat.com>
> ---
> Documentation/admin-guide/kernel-parameters.txt | 10 ++++--
> Documentation/kdump/kdump.txt | 7 ++--
> kernel/crash_core.c | 35 +++++++++++++++++++++---
> 3 files changed, 41 insertions(+), 11 deletions(-)
>
> --- linux-x86.orig/kernel/crash_core.c
> +++ linux-x86/kernel/crash_core.c
> @@ -31,7 +31,7 @@ static unsigned char *vmcoreinfo_data_sa
> /*
> * This function parses command lines in the format
> *
> - * crashkernel=ramsize-range:size[,...][@offset]
> + * crashkernel=ramsize-range:size[,...][@offset][^order]
> *
> * The function returns 0 on success and -EINVAL on failure.
> */
> @@ -41,6 +41,7 @@ static int __init parse_crashkernel_mem(
> unsigned long long *crash_base)
> {
> char *cur = cmdline, *tmp;
> + bool infinite_end = false;
>
> /* for each entry of the comma-separated list */
> do {
> @@ -93,13 +94,21 @@ static int __init parse_crashkernel_mem(
> /* match ? */
> if (system_ram >= start && system_ram < end) {
> *crash_size = size;
> + if (end == ULLONG_MAX)
> + infinite_end = true;
> break;
> }
> } while (*cur++ == ',');
>
> - if (*crash_size > 0) {
> - while (*cur && *cur != ' ' && *cur != '@')
> + if (*crash_size <= 0)
> + goto out;
> +
> + while (*cur && *cur != ' ') {
> + if (*cur != '@' && *cur != '^') {
> cur++;
> + continue;
> + }
> +
> if (*cur == '@') {
> cur++;
> *crash_base = memparse(cur, &tmp);
> @@ -107,10 +116,28 @@ static int __init parse_crashkernel_mem(
> pr_warn("Memory value expected after '@'\n");
> return -EINVAL;
> }
> - }
> + cur = tmp;
> + } else if (*cur == '^' && infinite_end ) {
> + unsigned long long shift, size;
> +
> + cur++;
> + shift = memparse(cur, &tmp);
> + if (cur == tmp) {
> + pr_warn("Memory reservation scale order expected after '^'\n");
> + return -EINVAL;
> + }
> + size = (system_ram - *crash_size) >> shift;
> + size = *crash_size + roundup(size, 1ULL << 20);
> + if (size < system_ram)
> + *crash_size = size;
> + cur = tmp;
> + } else
> + cur++;
> }
>
> return 0;
> +out:
> + return -EINVAL;
> }
>
> /*
> --- linux-x86.orig/Documentation/admin-guide/kernel-parameters.txt
> +++ linux-x86/Documentation/admin-guide/kernel-parameters.txt
> @@ -680,12 +680,14 @@
> is selected automatically. Check
> Documentation/kdump/kdump.txt for further details.
>
> - crashkernel=range1:size1[,range2:size2,...][@offset]
> + crashkernel=range1:size1[,range2:size2,...][@offset][^order]
> [KNL] Same as above, but depends on the memory
> in the running system. The syntax of range is
> - start-[end] where start and end are both
> - a memory unit (amount[KMG]). See also
> - Documentation/kdump/kdump.txt for an example.
> + [start]-end where start and end are both
> + a memory unit (amount[KMG]). In case the end of the
> + range is infinity '^order' can be used to scale
> + the size to size + (total_mem - start) >> 2^order
> + See also Documentation/kdump/kdump.txt for an example.
>
> crashkernel=size[KMG],high
> [KNL, x86_64] range could be above 4G. Allow kernel
> --- linux-x86.orig/Documentation/kdump/kdump.txt
> +++ linux-x86/Documentation/kdump/kdump.txt
> @@ -267,19 +267,20 @@ been removed from the machine.
>
> The syntax is:
>
> - crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
> + crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset][^order]
> range=start-[end]
>
> For example:
>
> - crashkernel=512M-2G:64M,2G-:128M
> + crashkernel=512M-2G:64M,2G-:128M^14
>
> 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
> + 3) if the RAM size is larger than 2G, then reserve:
> + 128M + (total_mem - 128M) >> 14
>
>
>
>
>
next prev parent reply other threads:[~2017-10-24 6:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 5:31 [PATCH 1/3] kdump: extend crashkernel=range:size to dynamically increase reservation size dyoung
2017-10-24 6:00 ` Baoquan He [this message]
2017-10-24 6:06 ` Dave Young
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171024060044.GH27757@x1 \
--to=bhe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=dyoung@redhat.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@redhat.com \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox