Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2804538rwb; Mon, 7 Nov 2022 18:48:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM5MyGeaVdj+65Kis5IZKpMTvq7wEZD1O0A/NP4iJ2mYRjy7qwQp2cwWtB2V/7IqoUprfNrB X-Received: by 2002:a17:907:86a1:b0:7ac:c5c3:9c80 with SMTP id qa33-20020a17090786a100b007acc5c39c80mr52202682ejc.37.1667875716561; Mon, 07 Nov 2022 18:48:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667875716; cv=none; d=google.com; s=arc-20160816; b=pJ+MB7zWQ9ZNAFgQ6hDfCkYCQahSgmMxAGYUcAQpUlppBracFirE2FY/gBmH8Gmic6 jnBA0DV4CD/3Llje8JDE8Cuj+k8xGRkD5KCRPIW8mAYrYJFLw2igxKc7nx5oNXjBdkrh rQvxY77fjkDafJ42wRnoJU2oLBJX4NJqKS+OFr9Pbekck+mzuQAau816H+MNlgO2Dfb0 Z8auqXn4TOcVMg32oza/y4D7SbhNxjy5wCKU2LAdEtVZRVIpreOrsQTGoCVNW+h9SMDF zJYyR7kcMohbVE48BowHxFVHXaZ5F+p4DI+l6Ziz+ca8B4ylBGrzfMBZ3eN00LI66bK6 TSyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=AEz9hit70cfObiJU7RmA2eb+fCR2or2WsSwlwWjN3N4=; b=MXjbI5x7ttiF9OXWu1Tu5rHeRX9ZxV7JEQdUvat2Yfbo/Zkamo168MCc4wGFPb8bbe FQGPbYW0nUNAJ/w5JAkNrr5mkQKbMzjGQ4r+ZhglDnOuD03X/jyy0G+WV8CqxgiSmXuF HuGi6fnFRTgSPQa1FRX3OWlDwa+vZYAEgzCZSj03Xw0XrveBIeAamtcF0FmWd/dPiYcX 67RMIS1QmV+V6shFjPAVXW/Sbaubf55fP02hhrfp6D4iumoznwk6WrNq4VKIwxSW/IbX pCYxNHyh/lgTt6YPO4HK8liTPif1nOdj5VWH6xBd/eIA8wYiOxAtrDSOy2fxVC2SyhQz U4bQ== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a056402280f00b0046184b7c4besi11947183ede.462.2022.11.07.18.48.15; Mon, 07 Nov 2022 18:48:36 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbiKHCGo (ORCPT + 91 others); Mon, 7 Nov 2022 21:06:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232060AbiKHCGm (ORCPT ); Mon, 7 Nov 2022 21:06:42 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D0C13CEE; Mon, 7 Nov 2022 18:06:41 -0800 (PST) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N5rx81X4gzJnYV; Tue, 8 Nov 2022 10:03:40 +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.2375.31; Tue, 8 Nov 2022 10:06:40 +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.2375.31; Tue, 8 Nov 2022 10:06:39 +0800 Subject: Re: [PATCH v3 2/2] arm64: kdump: Support crashkernel=X fall back to reserve region above DMA zones To: Catalin Marinas CC: Dave Young , Baoquan He , Vivek Goyal , , , Will Deacon , , Jonathan Corbet , , "Eric W . Biederman" , Randy Dunlap , Feng Zhou , Kefeng Wang , Chen Zhou , John Donnelly , "Dave Kleikamp" References: <20220711090319.1604-1-thunder.leizhen@huawei.com> <20220711090319.1604-3-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <6b20a203-6aab-2b87-9b95-814aeb79b5bd@huawei.com> Date: Tue, 8 Nov 2022 10:06:38 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 2022/11/8 1:13, Catalin Marinas wrote: > 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; OK, This way would be better. > 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 ..." This description is accurate. I'll update. Thanks. > >> + 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. > -- Regards, Zhen Lei