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 X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8780C433E2 for ; Thu, 3 Sep 2020 12:07:17 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6AFE92072A for ; Thu, 3 Sep 2020 12:07:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hMgONx9c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6AFE92072A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bek8iX46VWQO/sxKvqZkLyjH+KHZYO2JSpgku/Ax1cc=; b=hMgONx9cu0owUbnd9ybROjkC9 njiul8c2vi4qmOCPC8iV8fz4pTl61XAEfel19KjxzNbs4ZWBvWPjTIlJsEI42DeNP+UaQ5WWqBvh3 q1pN9DdHaYtpWLZy8bqZ04hs4CDHgFoGDNgHXLHCtn3Z+3haMmgGmAMipICbVa9FVLnoCmJn5TPuM 1OssErU2W1MTldFNS/MCmHxOCkc7uGgJTt81u5i+gG0Y9mwhmyHX0++jZguUnC/6YU93bJsnu+blH 8vUyfU1e3Owme1iv9SjZmzmehdOfBlW9Hw4R3XyGDkjxRqbwkPn10X/IrExpkvs2Gpv3onOYK3HPs eRWCT3X/A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDo0F-0002EI-M2; Thu, 03 Sep 2020 12:06:07 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDo0C-0002Ck-2p for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 12:06:05 +0000 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 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-Disposition: inline In-Reply-To: <20200817080405.GL969206@linux.ibm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_080604_224382_5B1F243E X-CRM114-Status: GOOD ( 20.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: song.bao.hua@hisilicon.com, sujunfei2@hisilicon.com, linux-arm-kernel@lists.infradead.org, steve.capper@arm.com, puck.chen@hisilicon.com, saberlily.xia@hisilicon.com, linux-kernel@vger.kernel.org, fengbaopeng2@hisilicon.com, Wei Li , will@kernel.org, nsaenzjulienne@suse.de, butao@hisilicon.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel