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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 AD03DC433DB for ; Thu, 11 Mar 2021 07:52:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD96564FB6 for ; Thu, 11 Mar 2021 07:52:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD96564FB6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 139F88D027C; Thu, 11 Mar 2021 02:52:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C2A18D0250; Thu, 11 Mar 2021 02:52:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7E4D8D027C; Thu, 11 Mar 2021 02:52:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0054.hostedemail.com [216.40.44.54]) by kanga.kvack.org (Postfix) with ESMTP id C82AA8D0250 for ; Thu, 11 Mar 2021 02:52:21 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8833D181AF5D0 for ; Thu, 11 Mar 2021 07:52:21 +0000 (UTC) X-FDA: 77906825682.05.C25BA91 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf27.hostedemail.com (Postfix) with ESMTP id CB2708019142 for ; Thu, 11 Mar 2021 07:52:16 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9C9801FB; Wed, 10 Mar 2021 23:52:19 -0800 (PST) Received: from [10.163.66.3] (unknown [10.163.66.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D9E2B3F70D; Wed, 10 Mar 2021 23:52:16 -0800 (PST) Subject: Re: [RFC] mm: Enable generic pfn_valid() to handle early sections with memmap holes To: Mike Rapoport Cc: linux-mm@kvack.org, Russell King , Catalin Marinas , Will Deacon , Andrew Morton , David Hildenbrand , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1615174073-10520-1-git-send-email-anshuman.khandual@arm.com> From: Anshuman Khandual Message-ID: <003d8a4b-9687-3e9a-c27b-908db280b44c@arm.com> Date: Thu, 11 Mar 2021 13:22:53 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Stat-Signature: 718od58cem9acte47aoyg55ckebm8zcd X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CB2708019142 Received-SPF: none (arm.com>: No applicable sender policy available) receiver=imf27; identity=mailfrom; envelope-from=""; helo=foss.arm.com; client-ip=217.140.110.172 X-HE-DKIM-Result: none/none X-HE-Tag: 1615449136-70042 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 3/8/21 2:25 PM, Mike Rapoport wrote: > Hi Anshuman, > > On Mon, Mar 08, 2021 at 08:57:53AM +0530, Anshuman Khandual wrote: >> Platforms like arm and arm64 have redefined pfn_valid() because their early >> memory sections might have contained memmap holes caused by memblock areas >> tagged with MEMBLOCK_NOMAP, which should be skipped while validating a pfn >> for struct page backing. This scenario could be captured with a new option >> CONFIG_HAVE_EARLY_SECTION_MEMMAP_HOLES and then generic pfn_valid() can be >> improved to accommodate such platforms. This reduces overall code footprint >> and also improves maintainability. > > I wonder whether arm64 would still need to free parts of its memmap after free_unused_memmap() is applicable when CONFIG_SPARSEMEM_VMEMMAP is not enabled. I am not sure whether there still might be some platforms or boards which would benefit from this. Hence lets just keep this unchanged for now. > the section size was reduced. Maybe the pain of arm64::pfn_valid() is not > worth the memory savings anymore? arm64 pfn_valid() special case was primarily because of MEMBLOCK_NOMAP tagged memory areas, which are reserved by the firmware. > >> Commit 4f5b0c178996 ("arm, arm64: move free_unused_memmap() to generic mm") >> had used CONFIG_HAVE_ARCH_PFN_VALID to gate free_unused_memmap(), which in >> turn had expanded its scope to new platforms like arc and m68k. Rather lets >> restrict back the scope for free_unused_memmap() to arm and arm64 platforms >> using this new config option i.e CONFIG_HAVE_EARLY_SECTION_MEMMAP. > > The whole point of 4f5b0c178996 was to let arc and m68k to free unused > memory map with FLATMEM so they won't need DISCONTIGMEM or SPARSEMEM. So > whatever implementation there will be for arm/arm64, please keep arc and > m68k functionally intact. Okay. Will protect free_unused_memmap() on HAVE_EARLY_SECTION_MEMMAP_HOLES config as well. diff --git a/mm/memblock.c b/mm/memblock.c index d9fa2e62ab7a..11b624e94127 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1927,8 +1927,11 @@ static void __init free_unused_memmap(void) unsigned long start, end, prev_end = 0; int i; - if (!IS_ENABLED(CONFIG_HAVE_EARLY_SECTION_MEMMAP_HOLES) || - IS_ENABLED(CONFIG_SPARSEMEM_VMEMMAP)) + if (IS_ENABLED(CONFIG_SPARSEMEM_VMEMMAP)) + return; + + if (!IS_ENABLED(CONFIG_HAVE_EARLY_SECTION_MEMMAP_HOLES) && + !IS_ENABLED(CONFIG_HAVE_ARCH_PFN_VALID)) return;