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 BBAB4C433FE for ; Mon, 7 Nov 2022 17:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232215AbiKGRN5 (ORCPT ); Mon, 7 Nov 2022 12:13:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbiKGRN4 (ORCPT ); Mon, 7 Nov 2022 12:13:56 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C55AA13F28; Mon, 7 Nov 2022 09:13:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C875B81195; Mon, 7 Nov 2022 17:13:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44E92C433C1; Mon, 7 Nov 2022 17:13:50 +0000 (UTC) Date: Mon, 7 Nov 2022 17:13:46 +0000 From: Catalin Marinas To: Zhen Lei Cc: Dave Young , Baoquan He , Vivek Goyal , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Will Deacon , linux-arm-kernel@lists.infradead.org, Jonathan Corbet , linux-doc@vger.kernel.org, "Eric W . Biederman" , Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou , John Donnelly , Dave Kleikamp Subject: Re: [PATCH v3 2/2] arm64: kdump: Support crashkernel=X fall back to reserve region above DMA zones Message-ID: References: <20220711090319.1604-1-thunder.leizhen@huawei.com> <20220711090319.1604-3-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220711090319.1604-3-thunder.leizhen@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Mon, Jul 11, 2022 at 05:03:19PM +0800, Zhen Lei wrote: > diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c > index 5390f361208ccf7..8539598f9e58b4d 100644 > --- a/arch/arm64/mm/init.c > +++ b/arch/arm64/mm/init.c > @@ -138,6 +138,7 @@ static void __init reserve_crashkernel(void) > unsigned long long crash_max = CRASH_ADDR_LOW_MAX; > char *cmdline = boot_command_line; > int ret; > + bool fixed_base; > > if (!IS_ENABLED(CONFIG_KEXEC_CORE)) > return; > @@ -166,15 +167,28 @@ static void __init reserve_crashkernel(void) > return; > } > > + fixed_base = !!crash_base; > crash_size = PAGE_ALIGN(crash_size); > > /* User specifies base address explicitly. */ > - if (crash_base) > + if (fixed_base) > crash_max = crash_base + crash_size; Not a fan of '!!', it is converted automatically. If you don't like the conversion, just initialise fixed_base to false and here: if (crash_base) { fixed_base = true; crash_max = crash_base + crash_size; } > +retry: > crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN, > crash_base, crash_max); > if (!crash_base) { > + /* > + * Attempt to fully allocate low memory failed, fall back > + * to high memory, the minimum required low memory will be > + * reserved later. > + */ I'm not sure this comment makes sense. If !crash_base, it doesn't mean the kernel failed to fully allocate low memory. crash_max here could be CRASH_ADDR_HIGH_MAX if crashkerne=X,high was specified. Maybe says something like "If the first attempt was for low memory, fall back to high ..." > + if (!fixed_base && (crash_max == CRASH_ADDR_LOW_MAX)) { > + crash_max = CRASH_ADDR_HIGH_MAX; > + crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; > + goto retry; > + } The retry logic looks fine, it only happens once as crash_max is updated. -- Catalin