Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1257116ybh; Thu, 23 Jul 2020 04:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGiPPJqQKJfDdr4TXp0nktrjZHNLCCKGv01AHjzCC/q9kv0hId/gO6CNCDRd596ZBslYDw X-Received: by 2002:a17:906:7250:: with SMTP id n16mr4088762ejk.290.1595503934907; Thu, 23 Jul 2020 04:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595503934; cv=none; d=google.com; s=arc-20160816; b=LcGHim2kVwnObRCY3Mz0kWTjOHVjY/sBJ14FfCUiGc6DStHqggS65v8ncJKD2zzwQY LhZ8zj922I4S9aS1aPzqqxQ/nTobljv63jCEx3Pzvtc2X4RdnNHw6z7ffCqHvAMkbGmu gyEalbCwV5M7n6NvSzPAnLxGD1GeQ5MD/eeO8c6zoXwUvet7R/2C7t1IByqxYily2Qvc TuLRIJm0n9dYF0E9VS+kGs/1WXI3uh+J7EV4KPXbrJK+yK6CdS+iJA3Mfo1e2d1oBGSx +BkznuTGCfUAforO8jwAFgpTVoOU8RS9kf3i8ZP17QilXU0/KD4UQ2amlk7kp3187bJw J/dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QxPiyEANLrfU5wPT1B7eZeSL6LWwRzZkIV0opqmjBdY=; b=pwuQ7DqZkq3fqjj+zhuk5q7GdvUDZLFLTZHCKm6RSqUnAaJf8gR/9jVAVzGvbwWwSo PzZ2JW8N4K01ucyxY0nW/w1lET81OOAODFpoIM8oNXq09xs4E3Oi25Cp0BNSh+QBZoFS p8gilaUEAO75IEvSezeDEzd67TrK1eL/ENCeDKIXueby6ENVR1c4k6Jca8x1cO4I2Lvy FfHsx2IB5hoM11Ih0gdwv04p19v/QJPR5Y53jJKDG395ZRmrG/iraHe7T76lDTSgY4nb H3xa2nfm1MWrq/25EDDGsGkjqdJ5KEaiJ76EBNWiYWe7n0nEm7B7Z1sDTmA8aS4HUWNt Q7tw== 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 d26si1905716ejy.594.2020.07.23.04.31.52; Thu, 23 Jul 2020 04:32:14 -0700 (PDT) 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 S1728674AbgGWL3c (ORCPT + 99 others); Thu, 23 Jul 2020 07:29:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:39154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbgGWL3c (ORCPT ); Thu, 23 Jul 2020 07:29:32 -0400 Received: from gaia (unknown [95.146.230.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A9D120709; Thu, 23 Jul 2020 11:29:29 +0000 (UTC) Date: Thu, 23 Jul 2020 12:29:26 +0100 From: Catalin Marinas To: "liwei (CM)" Cc: Mike Rapoport , "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 , zhaojiapeng Subject: Re: =?utf-8?B?562U5aSNOiDnrZTlpI06IFtQQVRD?= =?utf-8?Q?H=5D_arm64=3A_mm=3A_fre?= =?utf-8?Q?e?= unused memmap for sparse memory model that define VMEMMAP Message-ID: <20200723112926.GB7315@gaia> References: <20200721073203.107862-1-liwei213@huawei.com> <20200722060705.GK802087@linux.ibm.com> <1699CE87DE933F49876AD744B5DC140F2312E948@dggemm526-mbx.china.huawei.com> <20200722124910.GE27540@gaia> <1699CE87DE933F49876AD744B5DC140F2312F0D6@dggemm526-mbx.china.huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1699CE87DE933F49876AD744B5DC140F2312F0D6@dggemm526-mbx.china.huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 22, 2020 at 01:40:34PM +0000, liwei (CM) wrote: > Catalin Marinas wrote: > > On Wed, Jul 22, 2020 at 08:41:17AM +0000, liwei (CM) wrote: > > > Mike Rapoport wrote: > > > > On Tue, Jul 21, 2020 at 03:32:03PM +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. > > > > > > > > Are there numbers showing how much memory is actually freed? > > > > > > > > The freeing of empty memmap would become rather complex with these > > > > changes, do the memory savings justify it? > > > > > > In the sparse memory model, the size of a section is 1 GB > > > (SECTION_SIZE_BITS 30) by default. > > > > Can we reduce SECTION_SIZE_BITS instead? Say 26? > > Yes, you are right, reduce SECTION_SIZE_BITS to 26 can save almost the > same memory as the patch. > > 1) However, it is not clear whether changing the section size has any > other impact. Well, we should analyse this. > 2) Just like the flat memory model and the sparse memory model that > does not define VMEMMAP, both of them have their own ways to free > unused memmap. I think we've given a similar way for sparse memory > define VMEMMAP. I think we did it for flatmem initially (on arm32) and added support for sparsemem later on, so free_unused_memmap() had to cope with sparse sections. On arm64 we introduced vmemmap support and didn't bother with the freeing at all because of the added complexity of the vmemmap page tables. I wonder whether we should just disallow flatmem and non-vmemmap sparsemem on arm64. Is there any value in keeping them around? > 3) This explicit free unused memmap method does reduce unnecessary > memory waste for users who do not notice the section size > modification. But if we changed SECTION_SIZE_BITS in the mainline kernel, then we wouldn't need additional code to free the unused memmap. -- Catalin