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 B80ACC433F5 for ; Fri, 27 May 2022 08:56:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37DF98D0003; Fri, 27 May 2022 04:56:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 32CFE8D0001; Fri, 27 May 2022 04:56:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EF378D0003; Fri, 27 May 2022 04:56:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0D5FB8D0001 for ; Fri, 27 May 2022 04:56:19 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id CD8998074C for ; Fri, 27 May 2022 08:56:18 +0000 (UTC) X-FDA: 79510916436.01.F7A719B Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id 24A6940047 for ; Fri, 27 May 2022 08:56:09 +0000 (UTC) Received: from kwepemi100011.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4L8dt45DhwzjWxw; Fri, 27 May 2022 16:55:08 +0800 (CST) Received: from kwepemi500016.china.huawei.com (7.221.188.220) by kwepemi100011.china.huawei.com (7.221.188.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 27 May 2022 16:56:11 +0800 Received: from kwepemi500016.china.huawei.com ([7.221.188.220]) by kwepemi500016.china.huawei.com ([7.221.188.220]) with mapi id 15.01.2375.024; Fri, 27 May 2022 16:56:11 +0800 From: "Zhouguanghui (OS Kernel)" To: Anshuman Khandual , "akpm@linux-foundation.org" , "rppt@kernel.org" , "will@kernel.org" CC: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-arm-kernel@lists.infradead.org" , "xuqiang (M)" Subject: Re: [PATCH v2] arm64: Expand the static memblock memory table Thread-Topic: [PATCH v2] arm64: Expand the static memblock memory table Thread-Index: AQHYaePxMXVmORJiq0CmXcJ5Ica/dg== Date: Fri, 27 May 2022 08:56:11 +0000 Message-ID: <5d9390e36e6148e49284af3a7233accb@huawei.com> References: <20220517114309.10228-1-zhouguanghui1@huawei.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.178.157] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 24A6940047 X-Stat-Signature: zbaysefkuh1xwy1fxhkok7tiit8ubmds Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of zhouguanghui1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhouguanghui1@huawei.com X-HE-Tag: 1653641769-548709 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: Hi Anshuman,=0A= =0A= =1B$B:_=1B(B 2022/5/18 12:40, Anshuman Khandual =1B$B Hi Zhou,=0A= > =0A= > A small nit.=0A= > =0A= > This changes generic memblock to accommodate arm64 specific scenario.=0A= > Keeping the subject line as 'mm/memblock: ...' might be better.=0A= > =0A= =0A= I will add memblock to the subject line.=0A= =0A= > On 5/17/22 17:13, Zhou Guanghui wrote:=0A= >> In a system using HBM, a multi-bit ECC error occurs, and the BIOS=0A= >> saves the corresponding area (for example, 2 MB). When the system=0A= >> restarts next time, these areas are isolated and not reported or=0A= >> reported as EFI_UNUSABLE_MEMORY. Both of them lead to an increase=0A= > =0A= > Which cases dont get reported rather than as EFI_UNUSABLE_MEMORY ? Is=0A= > this supported on arm64 platform via mainline kernel ?=0A= > =0A= =0A= The BIOS determines how to report the memory area that cannot be used to = =0A= the kernel. Do not report the memory area to the kernel or inform the =0A= kernel that the memory area is unusable.=0A= =0A= >> in the number of memblocks, whereas EFI_UNUSABLE_MEMORY leads to=0A= >> a larger number of memblocks.=0A= >>=0A= >> For example, if the EFI_UNUSABLE_MEMORY type is reported:=0A= >> ...=0A= >> memory[0x92] [0x0000200834a00000-0x0000200835bfffff], 0x0000000001200= 000 bytes on node 7 flags: 0x0=0A= >> memory[0x93] [0x0000200835c00000-0x0000200835dfffff], 0x0000000000200= 000 bytes on node 7 flags: 0x4=0A= >> memory[0x94] [0x0000200835e00000-0x00002008367fffff], 0x0000000000a00= 000 bytes on node 7 flags: 0x0=0A= >> memory[0x95] [0x0000200836800000-0x00002008369fffff], 0x0000000000200= 000 bytes on node 7 flags: 0x4=0A= >> memory[0x96] [0x0000200836a00000-0x0000200837bfffff], 0x0000000001200= 000 bytes on node 7 flags: 0x0=0A= >> memory[0x97] [0x0000200837c00000-0x0000200837dfffff], 0x0000000000200= 000 bytes on node 7 flags: 0x4=0A= >> memory[0x98] [0x0000200837e00000-0x000020087fffffff], 0x0000000048200= 000 bytes on node 7 flags: 0x0=0A= >> memory[0x99] [0x0000200880000000-0x0000200bcfffffff], 0x0000000350000= 000 bytes on node 6 flags: 0x0=0A= >> memory[0x9a] [0x0000200bd0000000-0x0000200bd01fffff], 0x0000000000200= 000 bytes on node 6 flags: 0x4=0A= >> memory[0x9b] [0x0000200bd0200000-0x0000200bd07fffff], 0x0000000000600= 000 bytes on node 6 flags: 0x0=0A= >> memory[0x9c] [0x0000200bd0800000-0x0000200bd09fffff], 0x0000000000200= 000 bytes on node 6 flags: 0x4=0A= >> memory[0x9d] [0x0000200bd0a00000-0x0000200fcfffffff], 0x00000003ff600= 000 bytes on node 6 flags: 0x0=0A= >> memory[0x9e] [0x0000200fd0000000-0x0000200fd01fffff], 0x0000000000200= 000 bytes on node 6 flags: 0x4=0A= >> memory[0x9f] [0x0000200fd0200000-0x0000200fffffffff], 0x000000002fe00= 000 bytes on node 6 flags: 0x0=0A= > =0A= > Got it.=0A= > =0A= >> ...=0A= >>=0A= >> If the size of the init memblock regions is exceeded before the=0A= >> array size can be resized, the excess memory will be lost.=0A= > =0A= > Could you please elaborate more on why additional memblock regions can=0A= > not be accommodated via memblock array resizing ?=0A= > =0A= =0A= As described in the memblock_double_array function: We don't allow =0A= resizing until we know about the reserved regions of memory that aren' =0A= not suitable for allocation.=0A= =0A= >>=0A= >> Signed-off-by: Zhou Guanghui =0A= >> ---=0A= >> arch/arm64/include/asm/memory.h | 9 +++++++++=0A= >> mm/memblock.c | 14 +++++++++-----=0A= >> 2 files changed, 18 insertions(+), 5 deletions(-)=0A= >>=0A= >> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/me= mory.h=0A= >> index 0af70d9abede..eda61c0389c4 100644=0A= >> --- a/arch/arm64/include/asm/memory.h=0A= >> +++ b/arch/arm64/include/asm/memory.h=0A= >> @@ -364,6 +364,15 @@ void dump_mem_limit(void);=0A= >> # define INIT_MEMBLOCK_RESERVED_REGIONS (INIT_MEMBLOCK_REGIONS + NR_CP= US + 1)=0A= >> #endif=0A= >> =0A= >> +/*=0A= >> + * memory regions which marked with flag MEMBLOCK_NOMAP may divide a co= ntinuous=0A= >> + * memory block into multiple parts. As a result, the number of memory = regions=0A= >> + * is large.=0A= >> + */=0A= >> +#ifdef CONFIG_EFI=0A= > =0A= > Could not memblock regions tagged with MEMBLOCK_NOMAP flag not present=0A= > on non-EFI systems ? Just wondering, are there not some other scenarios= =0A= > which will also require expanded static memblock array.=0A= =0A= Systems using devicetree can also have "no-map" memory. However, in this = =0A= case, the expanded static memblock array is required only when a large =0A= number of such no-map reserved memories are manually added. I don't know = =0A= if any users will do that.=0A= =0A= Documentation/devicetree/bindings/reserved-memory/reserved-memory.yaml=0A= =0A= As to whether other scenarios also require expanded static memblock =0A= arrays, I really don't know.=0A= =0A= > =0A= >> +#define INIT_MEMBLOCK_MEMORY_REGIONS 1024=0A= >> +#endif=0A= >> +=0A= >> #include =0A= >> =0A= >> #endif /* __ASM_MEMORY_H */=0A= >> diff --git a/mm/memblock.c b/mm/memblock.c=0A= >> index e4f03a6e8e56..7c63571a69d7 100644=0A= >> --- a/mm/memblock.c=0A= >> +++ b/mm/memblock.c=0A= >> @@ -29,6 +29,10 @@=0A= >> # define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS=0A= >> #endif=0A= >> =0A= >> +#ifndef INIT_MEMBLOCK_MEMORY_REGIONS=0A= >> +#define INIT_MEMBLOCK_MEMORY_REGIONS INIT_MEMBLOCK_REGIONS=0A= >> +#endif=0A= > =0A= > Why create an additional macro INIT_MEMBLOCK_MEMORY_REGIONS ? Why cannot= =0A= > INIT_MEMBLOCK_REGIONS be defined in the platform directly like the other= =0A= > macro INIT_MEMBLOCK_RESERVED_REGIONS ?=0A= > =0A= =0A= The number of reserved memblocks does not need to be increased.=0A= =0A= >> +=0A= >> /**=0A= >> * DOC: memblock overview=0A= >> *=0A= >> @@ -55,9 +59,9 @@=0A= >> * the allocator metadata. The "memory" and "reserved" types are nicel= y=0A= >> * wrapped with struct memblock. This structure is statically=0A= >> * initialized at build time. The region arrays are initially sized to= =0A= >> - * %INIT_MEMBLOCK_REGIONS for "memory" and %INIT_MEMBLOCK_RESERVED_REGI= ONS=0A= >> - * for "reserved". The region array for "physmem" is initially sized to= =0A= >> - * %INIT_PHYSMEM_REGIONS.=0A= >> + * %INIT_MEMBLOCK_MEMORY_REGIONS for "memory" and=0A= >> + * %INIT_MEMBLOCK_RESERVED_REGIONS for "reserved". The region array=0A= >> + * for "physmem" is initially sized to %INIT_PHYSMEM_REGIONS.=0A= >> * The memblock_allow_resize() enables automatic resizing of the regio= n=0A= >> * arrays during addition of new regions. This feature should be used= =0A= >> * with care so that memory allocated for the region array will not=0A= >> @@ -102,7 +106,7 @@ unsigned long min_low_pfn;=0A= >> unsigned long max_pfn;=0A= >> unsigned long long max_possible_pfn;=0A= >> =0A= >> -static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOC= K_REGIONS] __initdata_memblock;=0A= >> +static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOC= K_MEMORY_REGIONS] __initdata_memblock;=0A= >> static struct memblock_region memblock_reserved_init_regions[INIT_MEMB= LOCK_RESERVED_REGIONS] __initdata_memblock;=0A= >> #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP=0A= >> static struct memblock_region memblock_physmem_init_regions[INIT_PHYSM= EM_REGIONS];=0A= >> @@ -111,7 +115,7 @@ static struct memblock_region memblock_physmem_init_= regions[INIT_PHYSMEM_REGIONS=0A= >> struct memblock memblock __initdata_memblock =3D {=0A= >> .memory.regions =3D memblock_memory_init_regions,=0A= >> .memory.cnt =3D 1, /* empty dummy entry */=0A= >> - .memory.max =3D INIT_MEMBLOCK_REGIONS,=0A= >> + .memory.max =3D INIT_MEMBLOCK_MEMORY_REGIONS,=0A= >> .memory.name =3D "memory",=0A= >> =0A= >> .reserved.regions =3D memblock_reserved_init_regions,=0A= > =0A= > - Anshuman=0A= > =0A= =0A= Thanks, Anshuman=0A=