Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2161633rwb; Mon, 7 Nov 2022 09:52:05 -0800 (PST) X-Google-Smtp-Source: AMsMyM5OprA7Q+V51cFDKNPL/oJtLQiefK5eDtCrPuGF9QW05zGVwzHFKWZiHzMGqnyv1a4U7FHf X-Received: by 2002:a17:90a:d084:b0:213:8cf1:4d34 with SMTP id k4-20020a17090ad08400b002138cf14d34mr53914684pju.150.1667843525192; Mon, 07 Nov 2022 09:52:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667843525; cv=none; d=google.com; s=arc-20160816; b=PMrDgRsuSsKunBdvFt6mcACSV3+eHD7X92+K2SjIml627lEJY86sin2OfkWUNV4CUr keSDGPhonNDc5lnOA/wgctjrJ1jvCLTcEUokCS/bY1uswnqfNyisGNTOUPm5/23tbsCv q+JDuv7PlsaZi+mcvELivaAZzfU4RtwxhRGt7JNyjScp/YpbQEAr5B1FfF2w8nRl6kNS V4taZoYILLmzryHOOV8z3r+miN6AkF6f/HRH8xceONsiBmtfHB8iaTEqQXmAO7yzflN2 mWBpegNB1CmfARShHJlHEnrGW05ftFoa1GWuH3jLUBMcif00G/2NnVERyQMwNKjwuPzo RUFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=pKJU6RgaUVhR0le1ihW6nqNBA9AyBUDH339HYScO3P4=; b=ZSyTRoaeEtBPbg2rJaAFDM6Idjj72TX4KJtOR6CYrMngJMb2+OrAIgW4+dQeTs0Zc3 Ed0pgDzYwS9Esoo/cHpq5Z4uYRwXG9ONCPtQbuB8hHX7cbo5IeRpvNqw5d3WSPBj3WGS Tw5r+d7+oqdJ9pn0BrZHY+hKM6/vwt40DH/hP40su+oYhx3p/BTYNo8XOYuCtP+QQ6Vp W4Mc2j4n5664c5kzMk42lPmeCVIWNibpy5uX/Ybes7xLCR3VgdWOT/e9WRVLVdIQAr2L AqitHg3n8LuddWv81kRmBMEiVXsudgk1kIP+9ZR6v7s51fTaexa//sLczxNdHlqI+WEC 9OuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a1709026b4c00b0018862b8c9a2si10459562plt.12.2022.11.07.09.51.53; Mon, 07 Nov 2022 09:52:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231519AbiKGRN7 (ORCPT + 92 others); Mon, 7 Nov 2022 12:13:59 -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> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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