[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9291bf01-d295-583c-399c-ea5b544be474@huawei.com>
Date: Sat, 25 Dec 2021 09:58:57 +0800
From: "Leizhen (ThunderTown)" <thunder.leizhen@...wei.com>
To: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
<x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>,
<linux-kernel@...r.kernel.org>, Dave Young <dyoung@...hat.com>,
Baoquan He <bhe@...hat.com>, Vivek Goyal <vgoyal@...hat.com>,
Eric Biederman <ebiederm@...ssion.com>,
<kexec@...ts.infradead.org>,
Catalin Marinas <catalin.marinas@....com>,
"Will Deacon" <will@...nel.org>,
<linux-arm-kernel@...ts.infradead.org>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
<devicetree@...r.kernel.org>, Jonathan Corbet <corbet@....net>,
<linux-doc@...r.kernel.org>
CC: Randy Dunlap <rdunlap@...radead.org>,
Feng Zhou <zhoufeng.zf@...edance.com>,
Kefeng Wang <wangkefeng.wang@...wei.com>,
"Chen Zhou" <dingguo.cz@...group.com>,
John Donnelly <John.p.donnelly@...cle.com>
Subject: Re: [PATCH v18 04/17] x86/setup: Add helper
parse_crashkernel_in_order()
On 2021/12/22 21:08, Zhen Lei wrote:
> Currently, there are two possible combinations of configurations.
> (1) crashkernel=X[@offset]
> (2) crashkernel=X,high, with or without crashkernel=X,low
>
> (1) has the highest priority, if it is configured correctly, (2) will be
> ignored. Similarly, in combination (2), crashkernel=X,low is valid only
> when crashkernel=X,high is valid.
>
> Putting the operations of parsing all "crashkernel=" configurations in one
> function helps to sort out the strong dependency.
>
> So add helper parse_crashkernel_in_order(). The "__maybe_unused" will be
> removed in the next patch.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
> ---
> arch/x86/kernel/setup.c | 51 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index d9080bfa131a654..f997074d36f2484 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -439,6 +439,57 @@ static int __init reserve_crashkernel_low(void)
> }
> #endif
>
> +#define CRASHKERNEL_MEM_NONE 0x0 /* crashkernel= is not exist or invalid */
> +#define CRASHKERNEL_MEM_CLASSIC 0x1 /* crashkernel=X[@offset] is valid */
> +#define CRASHKERNEL_MEM_HIGH 0x2 /* crashkernel=X,high is valid */
> +#define CRASHKERNEL_MEM_LOW 0x4 /* crashkernel=X,low is valid */
> +
> +/**
> + * parse_crashkernel_in_order - Parse all "crashkernel=" configurations in
> + * priority order until a valid combination is found.
> + * @cmdline: The bootup command line.
> + * @system_ram: Total system memory size.
> + * @crash_size: Save the memory size specified by "crashkernel=X[@offset]" or
> + * "crashkernel=X,high".
> + * @crash_base: Save the base address specified by "crashkernel=X@...set"
> + * @low_size: Save the memory size specified by "crashkernel=X,low"
> + *
> + * Returns the status flag of the parsing result of "crashkernel=", such as
> + * CRASHKERNEL_MEM_NONE, CRASHKERNEL_MEM_HIGH.
> + */
> +__maybe_unused
> +static int __init parse_crashkernel_in_order(char *cmdline,
> + unsigned long long system_ram,
> + unsigned long long *crash_size,
> + unsigned long long *crash_base,
> + unsigned long long *low_size)
I rethought yesterday that this function name is not self-annotated. In addition,
the meaning of the return value is not mainstream. It would be better to change it
to parse_crashkernel_high_low().
> +{
> + int ret, flag = CRASHKERNEL_MEM_NONE;
> +
> + BUG_ON(!crash_size || !crash_base || !low_size);
> +
> + /* crashkernel=X[@offset] */
> + ret = parse_crashkernel(cmdline, system_ram, crash_size, crash_base);
> + if (!ret && crash_size > 0)
> + return CRASHKERNEL_MEM_CLASSIC;
> +
> +#ifdef CONFIG_X86_64
> + /* crashkernel=X,high */
> + ret = parse_crashkernel_high(cmdline, system_ram, crash_size, crash_base);
> + if (ret || crash_size <= 0)
> + return CRASHKERNEL_MEM_NONE;
> +
> + flag = CRASHKERNEL_MEM_HIGH;
> +
> + /* crashkernel=Y,low */
> + ret = parse_crashkernel_low(cmdline, system_ram, low_size, crash_base);
> + if (!ret)
> + flag |= CRASHKERNEL_MEM_LOW;
> +#endif
> +
> + return flag;
> +}
> +
> static void __init reserve_crashkernel(void)
> {
> unsigned long long crash_size, crash_base, total_mem;
>
Powered by blists - more mailing lists