From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 307DBC4332F for ; Sat, 25 Dec 2021 01:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232140AbhLYB7C (ORCPT ); Fri, 24 Dec 2021 20:59:02 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:33910 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbhLYB7B (ORCPT ); Fri, 24 Dec 2021 20:59:01 -0500 Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JLRt15xQxzcc3c; Sat, 25 Dec 2021 09:58:33 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 09:58:58 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 09:58:57 +0800 Subject: Re: [PATCH v18 04/17] x86/setup: Add helper parse_crashkernel_in_order() To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , "H . Peter Anvin" , , Dave Young , Baoquan He , Vivek Goyal , Eric Biederman , , Catalin Marinas , "Will Deacon" , , Rob Herring , Frank Rowand , , Jonathan Corbet , CC: Randy Dunlap , Feng Zhou , Kefeng Wang , "Chen Zhou" , John Donnelly References: <20211222130820.1754-1-thunder.leizhen@huawei.com> <20211222130820.1754-5-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <9291bf01-d295-583c-399c-ea5b544be474@huawei.com> Date: Sat, 25 Dec 2021 09:58:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20211222130820.1754-5-thunder.leizhen@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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@offset" > + * @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; > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 752C3C433EF for ; Sat, 25 Dec 2021 02:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:CC:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Kf3vhuyObNcWJuTJlu1DPahrI2hgh3CErujbGa0f4C8=; b=HkQ1zoW0KrXJSVp8rv2Tj+cnjk 6dwIEyyv+q0FGfjzfDQ7rydX7JfRKVfPFQfnKNA/IIpp6yA5ddRu1SItI7fe3ZA+xspEhc4pQDZTC EMJB9Qimh9JwE9lOnj7Sgje5GG6dVKhSyTPVk/chpMVeyKZBXmH3QOOlFtkpgYXVzXqz7/5e3aE34 Jz/nLcOgsXFuK5paj/v3dXQAnujknGc4Dbn0djvGM0D86r381itb/vXdn7jm5Y+RyArrlLB3sL9/H B2PauqURox4E4DQYTPJ4SsH8jPz7tHrT8I44cUDzlES9ps3rBUih5VvX0bHIylio+HD9MKg1BiGha uN5Z13ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0wKx-00EaFw-0t; Sat, 25 Dec 2021 01:59:07 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0wKr-00EaDw-KV; Sat, 25 Dec 2021 01:59:03 +0000 Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JLRt15xQxzcc3c; Sat, 25 Dec 2021 09:58:33 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 09:58:58 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Sat, 25 Dec 2021 09:58:57 +0800 Subject: Re: [PATCH v18 04/17] x86/setup: Add helper parse_crashkernel_in_order() To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , "H . Peter Anvin" , , Dave Young , Baoquan He , Vivek Goyal , Eric Biederman , , Catalin Marinas , "Will Deacon" , , Rob Herring , Frank Rowand , , Jonathan Corbet , CC: Randy Dunlap , Feng Zhou , Kefeng Wang , "Chen Zhou" , John Donnelly References: <20211222130820.1754-1-thunder.leizhen@huawei.com> <20211222130820.1754-5-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <9291bf01-d295-583c-399c-ea5b544be474@huawei.com> Date: Sat, 25 Dec 2021 09:58:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20211222130820.1754-5-thunder.leizhen@huawei.com> Content-Language: en-US X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211224_175902_059999_1CDA02B9 X-CRM114-Status: GOOD ( 26.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > --- > 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@offset" > + * @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; > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Subject: Re: [PATCH v18 04/17] x86/setup: Add helper parse_crashkernel_in_order() References: <20211222130820.1754-1-thunder.leizhen@huawei.com> <20211222130820.1754-5-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <9291bf01-d295-583c-399c-ea5b544be474@huawei.com> Date: Sat, 25 Dec 2021 09:58:57 +0800 MIME-Version: 1.0 In-Reply-To: <20211222130820.1754-5-thunder.leizhen@huawei.com> Content-Language: en-US List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, Dave Young , Baoquan He , Vivek Goyal , Eric Biederman , kexec@lists.infradead.org, Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Jonathan Corbet , linux-doc@vger.kernel.org Cc: Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou , John Donnelly 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 > --- > 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@offset" > + * @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; > _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec