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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B461C433EF for ; Wed, 11 May 2022 01:10:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 449AC6B0071; Tue, 10 May 2022 21:10:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F7126B0072; Tue, 10 May 2022 21:10:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E6206B0073; Tue, 10 May 2022 21:10:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1BE336B0071 for ; Tue, 10 May 2022 21:10:14 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E553F21D11 for ; Wed, 11 May 2022 01:10:13 +0000 (UTC) X-FDA: 79451681106.15.21304C9 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf02.hostedemail.com (Postfix) with ESMTP id 925C2800AE for ; Wed, 11 May 2022 01:10:05 +0000 (UTC) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4KycCP71LWzCsY7; Wed, 11 May 2022 09:05:21 +0800 (CST) Received: from huawei.com (10.175.112.208) by kwepemi500016.china.huawei.com (7.221.188.220) 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 09:10:08 +0800 From: Zhou Guanghui To: , CC: , , , Subject: [PATCH] memblock: config the number of init memblock regions Date: Wed, 11 May 2022 01:05:30 +0000 Message-ID: <20220511010530.60962-1-zhouguanghui1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected X-Stat-Signature: 3ih5h8pgbjznr8a93ufc1c4stsqbhbnu Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of zhouguanghui1@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhouguanghui1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 925C2800AE X-HE-Tag: 1652231405-118829 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: During early boot, the number of memblocks may exceed 128(some memory areas are not reported to the kernel due to test failures. As a result, contiguous memory is divided into multiple parts for reporting). If the size of the init memblock regions is exceeded before the array size can be resized, the excess memory will be lost. Signed-off-by: Zhou Guanghui --- mm/Kconfig | 8 ++++++++ mm/memblock.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/Kconfig b/mm/Kconfig index 034d87953600..c6881802cccc 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -89,6 +89,14 @@ config SPARSEMEM_VMEMMAP pfn_to_page and page_to_pfn operations. This is the most efficient option when sufficient kernel resources are available. +config MEMBLOCK_INIT_REGIONS + int "Number of init memblock regions" + range 128 1024 + default 128 + help + The number of init memblock regions which used to track "memory" and + "reserved" memblocks during early boot. + config HAVE_MEMBLOCK_PHYS_MAP bool diff --git a/mm/memblock.c b/mm/memblock.c index e4f03a6e8e56..6893d26b750e 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -22,7 +22,7 @@ #include "internal.h" -#define INIT_MEMBLOCK_REGIONS 128 +#define INIT_MEMBLOCK_REGIONS CONFIG_MEMBLOCK_INIT_REGIONS #define INIT_PHYSMEM_REGIONS 4 #ifndef INIT_MEMBLOCK_RESERVED_REGIONS -- 2.17.1