Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6600263iob; Wed, 11 May 2022 00:48:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyvASekyT1q/KNAxAMCYOzIDnIiQzXgzaFSQbZylaX+OUv7WSy1VRGEZsKt14Tf01Zp8nV X-Received: by 2002:a17:907:8a14:b0:6f4:4365:dc07 with SMTP id sc20-20020a1709078a1400b006f44365dc07mr22313469ejc.693.1652255300847; Wed, 11 May 2022 00:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652255300; cv=none; d=google.com; s=arc-20160816; b=s3Y9S667wCS0RyZof8YG6asLmmZgAsd3iTGf1IKEbyLABwVhEhTbDGQV39hoOY7jnk EMQZMixmRAScI1noAG0XFatTIR12li2bMNDbLBW5XOTclQJpUd3z/uuSoRE8Vj2vBw7+ NeAZBCwztMrBQ6q4InRpHCDrBYIesIRvz798z1xnmcf/elV8lTcD5wl4N43Js19OyQzG jqv9t4WI9uQqLa33motAHkSDqFFSxvnL6ITVTalsnvVvHbgC0LlamMm/zZ/MGEw6ZFWn WrUSOGY2T1LeKiMv67kFqEWN+5kV1wdRhDFBYWhFQmAPw3LuZZvRalqHOceULgbptyAu 5ElQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=mrdBCOnUoFav6LUKDsG9BeEnSrJDPqVOXdqXFBcwt4g=; b=pQkEBJCTl7P88ursna1J5P0VKS3FcLbEjaFRswHwamU+yC/Cz/22lf9rcAnEoAe/v2 BEd9+7PRl0z02ojbqDRwvsMuXRExOtG1bLpnMX5Al5676H2YK5GL8yoRQlOHK7jr5cIL +vwb85csc/n7W1gAl5TdrcZTqRi6AK6x43t0exxRZZt2zbCz5ipa6ZT/fAepB7uPWHKJ jH3Op0Xm1HUgTPIYc+0/SxEIHsrRAE4/B3kuUd4uby4ebNhdWmR5TolFHPic0RlZh9jg IoZpqTnSuQUMl9MAFFh97dN/4+ro4gH/sgZnXPwpWzULRER7K3kK4RQEHlNfWn5O0qbr 5BdA== 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 ht16-20020a170907609000b006f3911626bfsi1643653ejc.604.2022.05.11.00.47.51; Wed, 11 May 2022 00:48:20 -0700 (PDT) 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 S236201AbiEKDYf (ORCPT + 99 others); Tue, 10 May 2022 23:24:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231142AbiEKDYc (ORCPT ); Tue, 10 May 2022 23:24:32 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D8560E9; Tue, 10 May 2022 20:24:31 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KygDj1QKRzGpk3; Wed, 11 May 2022 11:21:41 +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.24; Wed, 11 May 2022 11:24:29 +0800 Received: from thunder-town.china.huawei.com (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.24; Wed, 11 May 2022 11:24:28 +0800 From: Zhen Lei To: Dave Young , Baoquan He , Vivek Goyal , , , Catalin Marinas , Will Deacon , , Jonathan Corbet , CC: Zhen Lei , "Eric W . Biederman" , Randy Dunlap , Feng Zhou , Kefeng Wang , "Chen Zhou" , John Donnelly , Dave Kleikamp Subject: [PATCH] arm64: kdump: Do not allocate crash low memory if not needed Date: Wed, 11 May 2022 11:20:32 +0800 Message-ID: <20220511032033.426-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 When "crashkernel=X,high" is specified, the specified "crashkernel=Y,low" memory is not required in the following corner cases: 1. If both CONFIG_ZONE_DMA and CONFIG_ZONE_DMA32 are disabled, it means that the devices can access any memory. 2. If the system memory is small, the crash high memory may be allocated from the DMA zones. If that happens, there's no need to allocate another crash low memory because there's already one. Add condition '(crash_base >= CRASH_ADDR_LOW_MAX)' to determine whether the 'high' memory is allocated above DMA zones. Note: when both CONFIG_ZONE_DMA and CONFIG_ZONE_DMA32 are disabled, the entire physical memory is DMA accessible, CRASH_ADDR_LOW_MAX equals 'PHYS_MASK + 1'. Signed-off-by: Zhen Lei --- Documentation/admin-guide/kernel-parameters.txt | 5 +++-- arch/arm64/mm/init.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f6ff55840751a78..1b543c3109f4851 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -823,7 +823,7 @@ low memory is needed to make sure DMA buffers for 32-bit devices won't run out. Kernel would try to allocate at least 256M below 4G automatically. - This one let user to specify own low range under 4G + This one lets the user specify own low range under 4G for second kernel instead. 0: to disable low allocation. It will be ignored when crashkernel=X,high is not used @@ -832,7 +832,8 @@ [KNL, ARM64] range in low memory. This one lets the user specify a low range in the DMA zone for the crash dump kernel. - It will be ignored when crashkernel=X,high is not used. + It will be ignored when crashkernel=X,high is not used + or memory reserved is located in the DMA zones. cryptomgr.notests [KNL] Disable crypto self-tests diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 18ba66c90991ea0..ac510fb6a2c0189 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -170,7 +170,8 @@ static void __init reserve_crashkernel(void) return; } - if (crash_low_size && reserve_crashkernel_low(crash_low_size)) { + if ((crash_base >= CRASH_ADDR_LOW_MAX) && + crash_low_size && reserve_crashkernel_low(crash_low_size)) { memblock_phys_free(crash_base, crash_size); return; } -- 2.25.1