Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp907631pxf; Wed, 7 Apr 2021 14:45:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcUV66ZxF3MIg3ikQ818ecvze9SlQdhn/9cPTX72PtwOxI4FH62gr3qa+2pfhM0qtN5ci5 X-Received: by 2002:a05:6402:214:: with SMTP id t20mr7105708edv.229.1617831929512; Wed, 07 Apr 2021 14:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617831929; cv=none; d=google.com; s=arc-20160816; b=yAoaC41WJ0EPzhglv732U58wMJWJeuPc2pgJRxE+QGhL0IWmhPm9H1UsZmjyUwbp3C aHSxf2JKwMReb0d2UAtfvdQCYdRh93X/MLeDLLKo8ejKyqUHEBaP3Z0fMMT7hxTlHeaB gaCG7pJnMi+z1m/IBOoRkq0lkTF5m4MzZ9363eiTVjFp74+Yv+CgtMD32BcMLcZJvWns xTv0z+fZqC4ViGtDacYNVtpyx7Hk+5rQg1CxVb2v8zgQSL3/f831pv2NtPGYLZaHpLT9 9QukHAXC5FiwiqmD1d775WchS/pqFtA/RpOue8FWOJsS3tBf4Utl2EVqlowcPrQ1u2Hz ZUNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y+fhWFYPdv55zYtbUm8wCgsS3dq+DxsPR1dYlnx778Y=; b=w0e3bMx8KXD+Zq5MIwRiE5qrKv7ovjzstPERCREGAcgEe+VYgT05Tv0W1Z1M6LnmgD pDHR0YMUI8R50XPdkXtM03k4ydW2O79q5PryVDkIKlZJ3zm4AgoIk78Bg4xmtUzvYW1o +xa07NhOxafBK2CwgjP3i3kTjPgUumfzxPVM211oQo2+H71nfd8nL3vV9vhYQmwN7WY4 jfrkeAe5UdHr3cFWmXKDJC5wq/OcdF3Euco0pC8CxIfsIMIbDODhZGpaTtvNXkqJKVcl u71IC+FTbEpf/OGJcn88UwLgbVomDU5rlCrZYnHX4EYKVTfM70Rsx7xgBICBA6y3G+Mm ZpEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iy1Snv0d; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si7495845edc.429.2021.04.07.14.45.03; Wed, 07 Apr 2021 14:45: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iy1Snv0d; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344067AbhDGR1B (ORCPT + 99 others); Wed, 7 Apr 2021 13:27:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243605AbhDGR0x (ORCPT ); Wed, 7 Apr 2021 13:26:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DA706121E; Wed, 7 Apr 2021 17:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617816404; bh=xxAF7GHeBxkoT1bP5pdr71a5gAYBafBiXk5AmPplAhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iy1Snv0d8wa9Gx1CvzBU2QHXvg8HODrh4v4kHJw7ZBX7JL8xaqXRB590SqXs+CNjH pE+eXk32d7FQN0cilfmOLn/BiBgI4xxnT5vA1vamqzxfPPqaBSQ7ky+6eoHoLVHxfi fJuctfoSQCEPlOYxGLFtRDzcLVCfJfSk36KTpMzaBgRggsblH19R+FRS4TeUdv6YKL sqeiXzMD1RR9vaK6fpsm5SLMvGrG7tvvH3osMJZRxFPFIqOyEaophkqlUuWP7gJzer xvDCHS7iIleB3TtvhZRzHq4WXb98Bhy8xnYKYTRneTHaWYyzZaquXwDXqH61lzpao2 fVLczihgwKJNw== From: Mike Rapoport To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Marc Zyngier , Mark Rutland , Mike Rapoport , Mike Rapoport , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC/RFT PATCH 1/3] memblock: update initialization of reserved pages Date: Wed, 7 Apr 2021 20:26:05 +0300 Message-Id: <20210407172607.8812-2-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210407172607.8812-1-rppt@kernel.org> References: <20210407172607.8812-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 -- 2.28.0