Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2338892pxu; Mon, 7 Dec 2020 04:12:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEpi3By/FUwDraMilmJVuo2BLhb/SgFovH2uTiyezjhQx2jeNJ4KRF3fmB7T6C5y/+D05b X-Received: by 2002:aa7:c0d6:: with SMTP id j22mr16347051edp.31.1607343160510; Mon, 07 Dec 2020 04:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607343160; cv=none; d=google.com; s=arc-20160816; b=sAeBohN1PfCGfiqFREVCj0AKv+gBVXXc1cmJt3XpOmz5nHmHwTY1MCi+4HbAzWbZCL IuvelWlEl0N+/+BRZFEGLYL3TG65mN+jG2wUHVT9Ss3qEc01kMnJfHAySvgbMtW1WwQ5 IvQD91zaL7mRkP7FdveOqcHuDaWMmhQaKmbxMOgvK0XdECa+hNN/WlHECmQ+LLoL83zP Zurxpa5OqTAWGJpkPUkqr31KJ4Sfxl2hmPxA+CjZHpM46nIIgR2S/7DvIwkluHzFUV9K KALGEQy/2eAtVAVmOXmEKGrIgJLi0e2a5TO/DbbIRvLKRArxI6gAyymp66f9a+P35P98 Gs+w== 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=w9rxQwXkvdhoWciH3JAV3YMOdeMrJi1OMupVTxntaTw=; b=bPQt/WlZ5AcknH80kCdO/k+NbMG7c4g4VHlnkg/ofYmPsvM0CKxLtBkRdWheLyTz0D KRuI++mbr49+qG4ow3Smo/hEsdf2w7zAfOITMiS/16BAGSKCzsgySaNCxiLw9NY9Fkt0 rP78TvCkuuX8FhPXyMpnc2ARG/f6qAXpovEGBF+hA7ssizfMANgvxB8gutz2rY8b2Rs4 0KJG03XYx5FfhDVgo1Llv5bhHsk5rottjAKoq1BHS0IsnBkXpsTmp4f/UtSfaTKhBYCQ Vy6bopOc+9ab708AS5TQX77zZbthTS5cE/5s1VzL/0tiLRvEK4ZeJPfFIejh0praOD8D pzjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si8162261edv.243.2020.12.07.04.12.17; Mon, 07 Dec 2020 04:12:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727151AbgLGMIc (ORCPT + 99 others); Mon, 7 Dec 2020 07:08:32 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]:4110 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbgLGMIc (ORCPT ); Mon, 7 Dec 2020 07:08:32 -0500 Received: from DGGEMM402-HUB.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4CqMWH1lvWzXkrx; Mon, 7 Dec 2020 20:07:23 +0800 (CST) Received: from dggpemm000001.china.huawei.com (7.185.36.245) by DGGEMM402-HUB.china.huawei.com (10.3.20.210) with Microsoft SMTP Server (TLS) id 14.3.487.0; Mon, 7 Dec 2020 20:07:49 +0800 Received: from [10.145.28.31] (10.145.28.31) by dggpemm000001.china.huawei.com (7.185.36.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1913.5; Mon, 7 Dec 2020 20:07:49 +0800 Subject: Re: [PATCH] arm64: mm: decrease the section size to reduce the memory reserved for the page map To: Anshuman Khandual , Mike Rapoport , Ard Biesheuvel CC: Barry Song , Linux ARM , Steve Capper , Marc Zyngier , Linux Kernel Mailing List , Catalin Marinas , , Will Deacon , Nicolas Saenz Julienne , , , References: <20201204014443.43329-1-liwei213@huawei.com> <20201204111347.GA844@willie-the-truck> <390f5f441d99a832f4b2425b46f6d971@kernel.org> <20201207094215.GC1112728@linux.ibm.com> <20201207100426.GE1112728@linux.ibm.com> <39d72e1c-b3b3-89d3-1a1a-3ee222d40761@arm.com> From: Wei Li Message-ID: <3d7a68d7-e33a-fd42-3362-5019feade7ce@huawei.com> Date: Mon, 7 Dec 2020 20:07:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <39d72e1c-b3b3-89d3-1a1a-3ee222d40761@arm.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.145.28.31] X-ClientProxiedBy: dggeme706-chm.china.huawei.com (10.1.199.102) To dggpemm000001.china.huawei.com (7.185.36.245) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (+ saberlily + jiapeng) On 2020/12/7 18:39, Anshuman Khandual wrote: > > > On 12/7/20 3:34 PM, Mike Rapoport wrote: >> On Mon, Dec 07, 2020 at 10:49:26AM +0100, Ard Biesheuvel wrote: >>> On Mon, 7 Dec 2020 at 10:42, Mike Rapoport wrote: >>>> >>>> On Mon, Dec 07, 2020 at 09:35:06AM +0000, Marc Zyngier wrote: >>>>> On 2020-12-07 09:09, Ard Biesheuvel wrote: >>>>>> (+ Marc) >>>>>> >>>>>> On Fri, 4 Dec 2020 at 12:14, Will Deacon wrote: >>>>>>> >>>>>>> On Fri, Dec 04, 2020 at 09:44:43AM +0800, Wei Li wrote: >>>>>>>> For the memory hole, sparse memory model that define SPARSEMEM_VMEMMAP >>>>>>>> do not free the reserved memory for the page map, decrease the section >>>>>>>> size can reduce the waste of reserved memory. >>>>>>>> >>>>>>>> Signed-off-by: Wei Li >>>>>>>> Signed-off-by: Baopeng Feng >>>>>>>> Signed-off-by: Xia Qing >>>>>>>> --- >>>>>>>> arch/arm64/include/asm/sparsemem.h | 2 +- >>>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>>>>>> >>>>>>>> diff --git a/arch/arm64/include/asm/sparsemem.h b/arch/arm64/include/asm/sparsemem.h >>>>>>>> index 1f43fcc79738..8963bd3def28 100644 >>>>>>>> --- a/arch/arm64/include/asm/sparsemem.h >>>>>>>> +++ b/arch/arm64/include/asm/sparsemem.h >>>>>>>> @@ -7,7 +7,7 @@ >>>>>>>> >>>>>>>> #ifdef CONFIG_SPARSEMEM >>>>>>>> #define MAX_PHYSMEM_BITS CONFIG_ARM64_PA_BITS >>>>>>>> -#define SECTION_SIZE_BITS 30 >>>>>>>> +#define SECTION_SIZE_BITS 27 >>>>>>> >>>>>>> We chose '30' to avoid running out of bits in the page flags. What >>>>>>> changed? >>>>>>> >>>>>>> With this patch, I can trigger: >>>>>>> >>>>>>> ./include/linux/mmzone.h:1170:2: error: Allocator MAX_ORDER exceeds >>>>>>> SECTION_SIZE >>>>>>> #error Allocator MAX_ORDER exceeds SECTION_SIZE >>>>>>> >>>>>>> if I bump up NR_CPUS and NODES_SHIFT. >>>>>>> >>>>>> >>>>>> Does this mean we will run into problems with the GICv3 ITS LPI tables >>>>>> again if we are forced to reduce MAX_ORDER to fit inside >>>>>> SECTION_SIZE_BITS? >>>>> >>>>> Most probably. We are already massively constraint on platforms >>>>> such as TX1, and dividing the max allocatable range by 8 isn't >>>>> going to make it work any better... >>>> >>>> I don't think MAX_ORDER should shrink. Even if SECTION_SIZE_BITS is >>>> reduced it should accomodate the existing MAX_ORDER. >>>> >>>> My two pennies. >>>> >>> >>> But include/linux/mmzone.h:1170 has this: >>> >>> #if (MAX_ORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS >>> #error Allocator MAX_ORDER exceeds SECTION_SIZE >>> #endif >>> >>> and Will managed to trigger it after applying this patch. >> >> Right, because with 64K pages section size of 27 bits is not enough to >> accomodate MAX_ORDER (2^13 pages of 64K). >> >> Which means that definition of SECTION_SIZE_BITS should take MAX_ORDER >> into account either statically with >> >> #ifdef ARM64_4K_PAGES >> #define SECTION_SIZE_BITS >> #elif ARM64_16K_PAGES >> #define SECTION_SIZE_BITS >> #elif ARM64_64K_PAGES >> #define SECTION_SIZE_BITS >> #else >> #error "and what is the page size?" >> #endif >> >> or dynamically, like e.g. ia64 does: >> >> #ifdef CONFIG_FORCE_MAX_ZONEORDER >> #if ((CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) > SECTION_SIZE_BITS) >> #undef SECTION_SIZE_BITS >> #define SECTION_SIZE_BITS (CONFIG_FORCE_MAX_ZONEORDER - 1 + PAGE_SHIFT) >> #endif > > I had proposed the same on the other thread here. But with this the > SECTION_SIZE_BITS becomes 22 in case of 4K page size reducing to an > extent where PMD based vmemmap mapping could not be created. Though > have not looked into much details yet. > > Using CONFIG_FORCE_MAX_ZONEORDER seems to the right thing to do. But > if that does not reasonably work for 4K pages, we might have to hard > code it as 27 to have huge page vmemmap mappings. > . >