From patchwork Thu Dec 7 15:08:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10099373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 444C06056F for ; Thu, 7 Dec 2017 15:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33D332969E for ; Thu, 7 Dec 2017 15:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EE2C29722; Thu, 7 Dec 2017 15:08:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D95632969E for ; Thu, 7 Dec 2017 15:08:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 28941221EA0AD; Thu, 7 Dec 2017 07:04:18 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: None (no SPF record) identity=mailfrom; client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=batv+66a8023ffb5c76db3fb6+5219+infradead.org+hch@bombadil.srs.infradead.org; receiver=linux-nvdimm@lists.01.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 721E32217CE54 for ; Thu, 7 Dec 2017 07:04:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/GUV0rc6gXROJhuT5C5f3kBgvom0yaM5adPJFI33qp0=; b=cYnfywYUY1G2DmZCcBtmCh++U qYh00hbFq2c+OZPyLYmaYIyjECxdXvn6G/oxz8biMcb3YeLTFGO7YbRxnm1+ijck/eO/ABnA7rqVC R3t2KH5YRHL/V392Pddg5FV8BSnf287fe4mrvdj43GDFLSl0WohtpsJvsOClkzky6ubNruyo7k0Dq MEzFip0Ga7F5cq+1HfXqUYTsQNB+To0dqui66rCT2n90gg61PQUw2Zarp48c/4/rfd7EVPS8ho7kw r7xQym77A10F8sBDb9fTPkHl5nQqOch1unGc2Zzfk9t/KdVOfo1GYS1EVuz6+Ogts5+VhSLaC4elP 1RrMUJRvg==; Received: from [38.126.112.130] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1eMxmz-0007Yf-Rv; Thu, 07 Dec 2017 15:08:41 +0000 From: Christoph Hellwig To: Dan Williams Subject: [PATCH 06/14] mm: better abstract out dev_pagemap start_pfn Date: Thu, 7 Dec 2017 07:08:32 -0800 Message-Id: <20171207150840.28409-7-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171207150840.28409-1-hch@lst.de> References: <20171207150840.28409-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe --- include/linux/memremap.h | 6 ++++++ kernel/memremap.c | 9 +++++++++ mm/page_alloc.c | 4 +--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/linux/memremap.h b/include/linux/memremap.h index d221f4c0ccac..fe60b4895f56 100644 --- a/include/linux/memremap.h +++ b/include/linux/memremap.h @@ -139,6 +139,7 @@ static inline bool is_zone_device_page(const struct page *page); int dev_pagemap_add_pages(unsigned long phys_start_pfn, unsigned nr_pages); bool dev_pagemap_free_pages(struct page *page, unsigned nr_pages); unsigned long dev_pagemap_offset(struct page *page); +unsigned long dev_pagemap_start_pfn(unsigned long start_pfn); #else static inline void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, @@ -174,6 +175,11 @@ static inline unsigned long dev_pagemap_offset(struct page *page) { return 0; } + +static inline unsigned long dev_pagemap_start_pfn(unsigned long start_pfn) +{ + return 0; +} #endif /* CONFIG_ZONE_DEVICE */ #if defined(CONFIG_DEVICE_PRIVATE) || defined(CONFIG_DEVICE_PUBLIC) diff --git a/kernel/memremap.c b/kernel/memremap.c index 91a5fc1146b5..01025c5f3037 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -493,6 +493,15 @@ int dev_pagemap_add_pages(unsigned long phys_start_pfn, unsigned nr_pages) return 0; } +unsigned long dev_pagemap_start_pfn(unsigned long start_pfn) +{ + struct vmem_altmap *pgmap = to_vmem_altmap(__pfn_to_phys(start_pfn)); + + if (pgmap && start_pfn == pgmap->base_pfn) + return pgmap->reserve; + return 0; +} + bool dev_pagemap_free_pages(struct page *page, unsigned nr_pages) { struct vmem_altmap *pgmap = to_vmem_altmap((uintptr_t)page); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 73f5d4556b3d..cf6a702222c3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5305,7 +5305,6 @@ void __ref build_all_zonelists(pg_data_t *pgdat) void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, unsigned long start_pfn, enum memmap_context context) { - struct vmem_altmap *altmap = to_vmem_altmap(__pfn_to_phys(start_pfn)); unsigned long end_pfn = start_pfn + size; pg_data_t *pgdat = NODE_DATA(nid); unsigned long pfn; @@ -5321,8 +5320,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, * Honor reservation requested by the driver for this ZONE_DEVICE * memory */ - if (altmap && start_pfn == altmap->base_pfn) - start_pfn += altmap->reserve; + start_pfn += dev_pagemap_start_pfn(start_pfn); for (pfn = start_pfn; pfn < end_pfn; pfn++) { /*