Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp803120ybg; Tue, 28 Jul 2020 20:39:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFb5IyvvUM/1Zbt5tyrF/M2qQBh02uUnmLHLMKCiG0B8LUObqUs7cy0GHuvgq7o4tfBrZW X-Received: by 2002:a17:906:7e57:: with SMTP id z23mr13409025ejr.294.1595993952440; Tue, 28 Jul 2020 20:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595993952; cv=none; d=google.com; s=arc-20160816; b=hiIjotcz/ejS2/fOPvpo/XYzhh1hchhMUapA5oVEQ0Qj88yRDeQsgOY1lOXas54fgx g2VX24rekowRRlWpCb81LgJ7qiGQAboi5WH1KbD/1sRlsmsdvy9txPFlRWIqaBh+mQJx S4voTZ0x4xRoYy/atIBVpC8C6rNc16j4eBIpYRBlYwLncedz0VllpsgkVSx5/Y7mKATR k38muaaziE3OJJHenhVdbpW+ZM5jV1Qwq7IMKJ8e54mJzcVMJkTPdJlVAMoZK7S6YfGs ZAWBZ3efSIwLfTbEkvzcFXwRA5CAq3FTGsSyFDHZzZlVAjaWyWsDCBGuQSzzu5kEgX4R TMXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Php9ewy9sMkhlXxPuCa3JEom7CDjlsH6eBx9IU+wko0=; b=T649078DFP6bVD6IF/Tm1tLbjbHrV2kpg6W0fwVnyp2nWjfD4kzkXtiEmWG8T+pIk/ UQKpMJYio2gwjmI2q25Ks8G8nzavixBozKcYDg4ysuvQ9d+q7KCmCXPYxgijrq/6lH1P zEXIw8VFxu+oBi3HLMv6YSZjKMdXaui02aYrdIG8pKy/NXYO3iUCml65OE4DWMp3L45u vScUHo/NlTpyMkgnJJ9ErcDajMt1Jl94Rcd6vpvXbsySOaWzOSNiicPaQq2QQS82cGnS Qtztu/CnShG0FdIetKkomq7YNj5VFwzBNCNuyd3g+WEQoApDklKbesLnc4bq77geJCMT Ct+Q== 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 n25si475177edf.229.2020.07.28.20.38.49; Tue, 28 Jul 2020 20:39:12 -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 S1726897AbgG2Dfo (ORCPT + 99 others); Tue, 28 Jul 2020 23:35:44 -0400 Received: from foss.arm.com ([217.140.110.172]:44634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbgG2Dfo (ORCPT ); Tue, 28 Jul 2020 23:35:44 -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 1581D31B; Tue, 28 Jul 2020 20:35:44 -0700 (PDT) Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com [10.169.212.213]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9ACF53F66E; Tue, 28 Jul 2020 20:35:36 -0700 (PDT) From: Jia He To: Dan Williams , Vishal Verma , Mike Rapoport , David Hildenbrand Cc: Catalin Marinas , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Dave Jiang , Andrew Morton , Steve Capper , Mark Rutland , Logan Gunthorpe , Anshuman Khandual , Hsin-Yi Wang , Jason Gunthorpe , Dave Hansen , Kees Cook , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-mm@kvack.org, Wei Yang , Pankaj Gupta , Ira Weiny , Kaly Xin , Jia He Subject: [RFC PATCH 4/6] mm/page_alloc: adjust the start,end in dax pmem kmem case Date: Wed, 29 Jul 2020 11:34:22 +0800 Message-Id: <20200729033424.2629-5-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200729033424.2629-1-justin.he@arm.com> References: <20200729033424.2629-1-justin.he@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are 3 cases when doing online pages: - normal RAM, should be aligned with memory block size - persistent memory with ZONE_DEVICE - persistent memory used as normal RAM (kmem) with ZONE_NORMAL, this patch tries to adjust the start_pfn/end_pfn after finding the corresponding resource range. Without this patch, the check of __init_single_page when doing online memory will be failed because those pages haven't been mapped in mmu(not present from mmu's point of view). Signed-off-by: Jia He --- mm/page_alloc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e028b87ce294..13216ab3623f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5971,6 +5971,20 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, if (start_pfn == altmap->base_pfn) start_pfn += altmap->reserve; end_pfn = altmap->base_pfn + vmem_altmap_offset(altmap); + } else { + struct resource res; + int ret; + + /* adjust the start,end in dax pmem kmem case */ + ret = find_next_iomem_res(start_pfn << PAGE_SHIFT, + (end_pfn << PAGE_SHIFT) - 1, + IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY, + IORES_DESC_PERSISTENT_MEMORY, + false, &res); + if (!ret) { + start_pfn = PFN_UP(res.start); + end_pfn = PFN_DOWN(res.end + 1); + } } #endif -- 2.17.1