Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2930930pxb; Mon, 16 Nov 2020 00:37:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhC/q33B0RZgW1LZB3afOTgcH7mfsjgolvjZ9N/kMZFeRX19NIkwkFzPDkpga1XZlq3ddw X-Received: by 2002:a17:906:f2cc:: with SMTP id gz12mr9420045ejb.181.1605515828067; Mon, 16 Nov 2020 00:37:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605515828; cv=none; d=google.com; s=arc-20160816; b=XkqGce/ifgASMaDRHN/J64JNEs5GIGgIOyCGA1O3+kWmllGur1C4lp0KnCiDbIFMFt bVj1CyDds32eZWcydYKJR8l5r6YLVivTYCxTzJSQuc0mVGpuo5FkP2aWKhoAQkffcMt3 JzzRv3DI83lYh8VStHWnFW22eOLLBDOjrMPH1F2xiKVhUi4+h3QCAg9SAqo8ktTz9/X/ IbKNP5LXmsCwMg44ZbZjljynpUTWSY4C3f5wbukSJZHyb4p6/ji3xC+ofrxaLAguUq5n K0QDXMg1RjKwhSnpanLmCa0JPwnRRVmdYdy6rvjFx1lE3hYNtfoTP5QQfGBUhLvkHG+u nplg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=SRYtrp1LmkLivpva3+qQX+HB+WmtxRjfCI/1sY1/qPc=; b=ZThSKfkjkMaCkEh23mQqccNMgT3xbHJhZ85YCeIyVDVIvfY876mSwpNtbpS0cXCllS WqmwgN4vQ0Ii/lJIw8ZKR3m1efaRMRj7yZlfCw4V96ooMNsGF8jrS2+ckJLtPN5TIuWd cNrt2WDrZ2eXAxMWc2yUYP1Ax+JeHMHOrgiuT5ScPcaq30wZ1ChnIb60RR+e0MNcLGaM RMpXa/LCTONFysaaaX6gwKPFLksx4whB3RZRtS1S1YOGpwMbY2bCDAIk9ThGArDUQ12+ Nm7eIglv49Edvvexa5JTCgmPLZXwDcSf2mGWuHZXEt4DwL3RyZUHnp6KK+9n1bAusRlY 7dvw== 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 w26si1967234ejn.528.2020.11.16.00.36.45; Mon, 16 Nov 2020 00:37:08 -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 S1727228AbgKPId4 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 16 Nov 2020 03:33:56 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:2370 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbgKPId4 (ORCPT ); Mon, 16 Nov 2020 03:33:56 -0500 Received: from DGGEMM402-HUB.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4CZMmH5wmHz54hV; Mon, 16 Nov 2020 16:33:35 +0800 (CST) Received: from dggemi709-chm.china.huawei.com (10.3.20.108) by DGGEMM402-HUB.china.huawei.com (10.3.20.210) with Microsoft SMTP Server (TLS) id 14.3.487.0; Mon, 16 Nov 2020 16:33:43 +0800 Received: from dggemi761-chm.china.huawei.com (10.1.198.147) by dggemi709-chm.china.huawei.com (10.3.20.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Mon, 16 Nov 2020 16:33:43 +0800 Received: from dggemi761-chm.china.huawei.com ([10.9.49.202]) by dggemi761-chm.china.huawei.com ([10.9.49.202]) with mapi id 15.01.1913.007; Mon, 16 Nov 2020 16:33:43 +0800 From: "Song Bao Hua (Barry Song)" To: Catalin Marinas , Mike Rapoport , "liwei (CM)" CC: "will@kernel.org" , "Xiaqing (A)" , "Chenfeng (puck)" , butao , fengbaopeng , "nsaenzjulienne@suse.de" , "steve.capper@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , sujunfei , Linuxarm Subject: RE: [PATCH v2] arm64: mm: free unused memmap for sparse memory model that define VMEMMAP Thread-Topic: [PATCH v2] arm64: mm: free unused memmap for sparse memory model that define VMEMMAP Thread-Index: AQHWgeqeF9IRtLcIvk+OGBJGQD8vganK4CWw Date: Mon, 16 Nov 2020 08:33:43 +0000 Message-ID: References: <20200812010655.96339-1-liwei213@huawei.com> <20200817080405.GL969206@linux.ibm.com> <20200903120558.GB31409@gaia> In-Reply-To: <20200903120558.GB31409@gaia> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.201.147] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Catalin Marinas [mailto:catalin.marinas@arm.com] > Sent: Friday, September 4, 2020 12:06 AM > To: Mike Rapoport > Cc: liwei (CM) ; will@kernel.org; Xiaqing (A) > ; Chenfeng (puck) ; > butao ; fengbaopeng ; > nsaenzjulienne@suse.de; steve.capper@arm.com; Song Bao Hua (Barry Song) > ; linux-arm-kernel@lists.infradead.org; > linux-kernel@vger.kernel.org; sujunfei > Subject: Re: [PATCH v2] arm64: mm: free unused memmap for sparse memory > model that define VMEMMAP > > On Mon, Aug 17, 2020 at 11:04:05AM +0300, Mike Rapoport wrote: > > On Wed, Aug 12, 2020 at 09:06:55AM +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, this patch do it. > > > > I've been thinking about it a bit more and it seems that instead of > > freeing unused memory map it would be better to allocate the exact > > memory map from the beginning. > > > > In sparse_init_nid() we can replace PAGES_PER_SECTION parameter to > > __populate_section_memmap() with the calculated value for architectures > > that define HAVE_ARCH_PFN_VALID. > > Or just use a smaller PAGES_PER_SECTION and reduce the waste ;). > > Just to be clear, are you suggesting that we should use pfn_valid() on > the pages within a section to calculate the actual range? The > pfn_valid() implementation on arm64 checks for the validity of a sparse > section, so this would be called from within the sparse_init() code > path. I hope there's no dependency but I haven't checked. If it works, > it's fine by me, it solves the FLATMEM mem_map freeing as well. > > With 4KB pages on arm64, vmemmap_populate() stops at the pmd level, so > it always allocates PMD_SIZE. Wei's patch also only frees in PMD_SIZE > amounts. So, with a sizeof(struct page) of 64 (2^6), a PMD_SIZE mem_map > section would cover 2^(21-6) pages, so that's equivalent to a > SECTION_SIZE_BITS of 21-6+12 = 27. > > If we reduce SECTION_SIZE_BITS to 27 or less, this patch is a no-op. It would be the simplest way to fix this issue. It seems X86_64 is also using 27. @wei, has you ever tried to send a patch to change SECTION_SIZE_BITS to 27 for ARM64? > > -- > Catalin Thanks Barry