Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp611023pxk; Thu, 3 Sep 2020 08:12:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLH5tjqLQy12ZfPcOCY1VSTnUSlpWExnjZUxym2hFlIULsLyz9T+XhmbXtOTmblzwvh+xE X-Received: by 2002:aa7:df14:: with SMTP id c20mr3655971edy.334.1599145949163; Thu, 03 Sep 2020 08:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599145949; cv=none; d=google.com; s=arc-20160816; b=Qlt1Xzk2OcKOw7Y/sCXID5qGz/W4PQNSumcLrnLcYTXkGvQ41FXmMlFqdC5Ux1vA9M kY+0vqttDsRG68abGfs85DG1evnJufmgsgxOLOVUB327NF/zkN9zrMpFnNb8qy5Y9Xb5 UnaC9hzUix7vTwnVyEZ8SYQAaqMLM7HQiCTYbzXJdEb+3e2WX8KH4Q++e7VQkEybEFJW 2TwIl4ZUdCoQQDiDFcx1EyRe25LyFFhU71e3WxYAFh/6Q2GAn+298ycuyASENTi2kmQJ iio3ZcFV77/x8xKgSCpFqlLEsPya0zlHPEi5y3LjNs8trxBAG0nJly/eWj+rGJ+GM+fZ b77w== 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=zdDnTDcf/yroZpB+JjnAYPFlWhg4KsLlz+2mhj5YLYk=; b=KQYQBYXBk+Izh5qc8HTDu3aa8JjkViZawFIEMf+o5vTvC26uhX0lIp6MClYjvkw8kw +B4O+QoPYEKtwi4dCE0TfMysoEjW7iAIdgkuID4Vj6Mx/lEFFpNdvahv0MuAmNWtziQe HHs1CG37XJS/l/qFKgBUlatPdci9BTtA2I+HQopm/Srho1FeQHNYiCrBCh4gVBQubHRv Z6z09yEDfQKS1ZUC61bI2YCOTDGZXNom5waGQ8Hrnp1zx1sSiOzA0lqtup8B9gwMkoOP WYwKvDwvlFyQCxnc9du2mhEhLgWSDI8N+ju18te41ZXfZZl4j9H6m7AkcYAyf06j+tET mfaw== 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 c3si1835581edr.295.2020.09.03.08.12.06; Thu, 03 Sep 2020 08:12:29 -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 S1729274AbgICPLX (ORCPT + 99 others); Thu, 3 Sep 2020 11:11:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:56310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728876AbgICMbA (ORCPT ); Thu, 3 Sep 2020 08:31:00 -0400 Received: from gaia (unknown [46.69.195.48]) (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 1ABA520639; Thu, 3 Sep 2020 12:06:00 +0000 (UTC) Date: Thu, 3 Sep 2020 13:05:58 +0100 From: Catalin Marinas To: Mike Rapoport Cc: Wei Li , will@kernel.org, saberlily.xia@hisilicon.com, puck.chen@hisilicon.com, butao@hisilicon.com, fengbaopeng2@hisilicon.com, nsaenzjulienne@suse.de, steve.capper@arm.com, song.bao.hua@hisilicon.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sujunfei2@hisilicon.com Subject: Re: [PATCH v2] arm64: mm: free unused memmap for sparse memory model that define VMEMMAP Message-ID: <20200903120558.GB31409@gaia> References: <20200812010655.96339-1-liwei213@huawei.com> <20200817080405.GL969206@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200817080405.GL969206@linux.ibm.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 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. -- Catalin