Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp125462pxf; Wed, 7 Apr 2021 22:16:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwM70zUI0KQiaobtpR+ZxcjKDizvtE9b9SDnrIWYNGgaIwZlvKDAnHYXLHWYILfw6vVtEBW X-Received: by 2002:a17:90b:1e0b:: with SMTP id pg11mr6693775pjb.146.1617859009332; Wed, 07 Apr 2021 22:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617859009; cv=none; d=google.com; s=arc-20160816; b=YWMnMZNvHuGd+gjgzk+GkrML4MoPFttZ9k4gfFX4KjYyZ7ZlH3nmZ6tevFggpKYX4Z PvMbaNdhWNJpCHgj7yALIfMVmf7n+UU5gOuUGdQk1IC41Fznd/axfolYRO5lm/TZaHzu qpuuiuGdGYm0jW+Fx/0eGGfkrUKradiTsmzaPMxSHn0YUcCjfCDsfoqWl03FSoiN0o18 uSXBoTuLXLaYnTN5ZvmMv3PUMW4ZGaAaAzafQPuE6M7rtDwwNQldvNnIUj/qdR9q88yq 8OcggAZkp72/MoCgLYgtPcMwg41p+DE/V+NTQBBPMolbHaIu+Vf8sy5H139N50ri+uvo sX6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:subject:from; bh=D8EOs1TiO76Fc5G2fZOByh/Ev/yT9lyTGykO9J7MjSA=; b=yIbYGSu6Q4n83jA1gKDpLGqaBTuWgkgNRqqBAUsf9ZEW8XB4l48iTi90ri5Hcy2s0L 0vutQarQWj5Vxeuj4XZew8L+q3rWIMRllSpoOQxp+NVvGoeu6+ckKSS59WTqc3VzxLJV FA8BY+PYEvCnxK2FgcqjbMxxW9mKzfiC2Ki8ERPxz9ALF6timtfRq9HkygXITO4AHnn7 NZO0WFbujUxVQRVNVIXOjFQErrYKGp3YW0LXN6YwlrHiMaHUjcGwe1esqryRaHlT+mXo mEG59r1SvFFemscnZBkqgDWdXeoJ0MAMdVGq2PC0SdupkccCuAo1HYxc75AyW3zvrxl/ 5aSA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l25si26411355pgb.101.2021.04.07.22.16.37; Wed, 07 Apr 2021 22:16:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbhDHFPm (ORCPT + 99 others); Thu, 8 Apr 2021 01:15:42 -0400 Received: from foss.arm.com ([217.140.110.172]:39418 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhDHFPm (ORCPT ); Thu, 8 Apr 2021 01:15:42 -0400 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 8E8331424; Wed, 7 Apr 2021 22:15:31 -0700 (PDT) Received: from [10.163.67.84] (unknown [10.163.67.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6AA923F73D; Wed, 7 Apr 2021 22:15:28 -0700 (PDT) From: Anshuman Khandual Subject: Re: [RFC/RFT PATCH 1/3] memblock: update initialization of reserved pages To: Mike Rapoport , linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Marc Zyngier , Mark Rutland , Mike Rapoport , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20210407172607.8812-1-rppt@kernel.org> <20210407172607.8812-2-rppt@kernel.org> Message-ID: <064dad68-ca9f-14d3-7859-5321001fbca4@arm.com> Date: Thu, 8 Apr 2021 10:46:18 +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: <20210407172607.8812-2-rppt@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/7/21 10:56 PM, Mike Rapoport wrote: > From: Mike Rapoport > > The struct pages representing a reserved memory region are initialized > using reserve_bootmem_range() function. This function is called for each > reserved region just before the memory is freed from memblock to the buddy > page allocator. > > The struct pages for MEMBLOCK_NOMAP regions are kept with the default > values set by the memory map initialization which makes it necessary to > have a special treatment for such pages in pfn_valid() and > pfn_valid_within(). > > Split out initialization of the reserved pages to a function with a > meaningful name and treat the MEMBLOCK_NOMAP regions the same way as the > reserved regions and mark struct pages for the NOMAP regions as > PageReserved. This would definitely need updating the comment for MEMBLOCK_NOMAP definition in include/linux/memblock.h just to make the semantics is clear, though arm64 is currently the only user for MEMBLOCK_NOMAP. > > Signed-off-by: Mike Rapoport > --- > mm/memblock.c | 23 +++++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index afaefa8fc6ab..6b7ea9d86310 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -2002,6 +2002,26 @@ static unsigned long __init __free_memory_core(phys_addr_t start, > return end_pfn - start_pfn; > } > > +static void __init memmap_init_reserved_pages(void) > +{ > + struct memblock_region *region; > + phys_addr_t start, end; > + u64 i; > + > + /* initialize struct pages for the reserved regions */ > + for_each_reserved_mem_range(i, &start, &end) > + reserve_bootmem_region(start, end); > + > + /* and also treat struct pages for the NOMAP regions as PageReserved */ > + for_each_mem_region(region) { > + if (memblock_is_nomap(region)) { > + start = region->base; > + end = start + region->size; > + reserve_bootmem_region(start, end); > + } > + } > +} > + > static unsigned long __init free_low_memory_core_early(void) > { > unsigned long count = 0; > @@ -2010,8 +2030,7 @@ static unsigned long __init free_low_memory_core_early(void) > > memblock_clear_hotplug(0, -1); > > - for_each_reserved_mem_range(i, &start, &end) > - reserve_bootmem_region(start, end); > + memmap_init_reserved_pages(); > > /* > * We need to use NUMA_NO_NODE instead of NODE_DATA(0)->node_id >