From patchwork Mon Jul 16 17:00:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10527221 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 D9A84601D2 for ; Mon, 16 Jul 2018 17:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7CE628D7E for ; Mon, 16 Jul 2018 17:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC71228D8F; Mon, 16 Jul 2018 17:10:34 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F97B28D7E for ; Mon, 16 Jul 2018 17:10:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 522366B0010; Mon, 16 Jul 2018 13:10:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4F7E86B0266; Mon, 16 Jul 2018 13:10:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 411746B0269; Mon, 16 Jul 2018 13:10:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 031256B0010 for ; Mon, 16 Jul 2018 13:10:33 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id c13-v6so3291920pfo.14 for ; Mon, 16 Jul 2018 10:10:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=D3pkQdKeDW+DZpSeWX9rUlzKYR4geRNlU9wcCDzRwl0=; b=i9r2sW2ihVv3GXPooDWmfu5J5mgVFkgs96YgQu8l3yToKWq8G+Hf9ULF7OcV8rA4Tc tuH6gJJ53i4P+ZdD/cO6R8gU35wmvhagv1FkLVkWSoBALJ+1cGFZHv3s+FQ6RiH7VQ2a DbSMSLdn320WA4bHVF8PSU8Z8fuhcX+2AB+vei1VXvZ3pGd8QKzG3QPLL4h6RdIZgcL1 qgs2hNi66/+dlQjNIuTVmSwXtAGYLD+6KxIRviQE50eSwPYp3309Kls9rOgWOFqpypUd t7V+Z1ZOPcXS5Wooi5qpAHRiK0lqn3MZoeavQGzHXshs5lyANpDfHLfyY2hBFR0Lzfvj MQGA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AOUpUlFsZLr0gT/RmDsSg+6fHH5UZ+4TJdwtzHmG9xDJuO3rMYHCoLwW N1t0qRZyMm6Ceovce/Z+Bdqh6ihSKcqXTUupApqNpyR1HH/q6o+PN8hqxSjAVvGH3aYgRqxGxMZ /kdmSMwcHU4fUKx9ZXrW+eX4yaK6anL0nBjJWuGts7MgAQqG/BELdjqu+xFzffivTdA== X-Received: by 2002:a63:7007:: with SMTP id l7-v6mr16233740pgc.206.1531761032700; Mon, 16 Jul 2018 10:10:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5adP/CqbgG1zXkKhpkuN60v0CyG4bDvbf1JA/R2v/XZ/m7ITwdVjdgYAphbX7gtlqe+m6 X-Received: by 2002:a63:7007:: with SMTP id l7-v6mr16233703pgc.206.1531761031985; Mon, 16 Jul 2018 10:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531761031; cv=none; d=google.com; s=arc-20160816; b=exesIrr/S9UH9TOKe9cgxuLA1Tqa3yfz90dmrI95IQNFHlNMLj6prxF5p45CPLrF+A vdgKM6xLTFMpmoBwmIANQ/n38JPMj1cjFSoujPLw4TSmwfQlJHO8JnhXLfH0ouJ2R9Q5 pY7Atj0A8uApvnOBYQDP/TxTUoQTIVzDXV16VD2td39m7eAEeXSzCoSCWK+S1GCe8S8H aOtYCt3sGSt7iL1a1PcR/53oCLXiNVbPjDxTm4nGrFF7FjxQerlPHvhh1zP1NDVS5xTc IJ9+ujF+/KDbJVvR4zQHaPJ0AGmReKG2AbGIBmsbAphQS0mnUXHhnN38OFbq3SvBln/f 6nTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=D3pkQdKeDW+DZpSeWX9rUlzKYR4geRNlU9wcCDzRwl0=; b=LYf+GhIKGBMOVIeQUEmBIGcc98tcrd9og11JVthOyjWnP37ukkQ5De8He3mBwdGqg0 GTFq0/V644jyEnxe7rBSwzRRVsiac4xwcqJjIDhLxSP25GN/iPy6dQaj5mQZNe53F3mD hRdxRNBj+KEyXGFOlqPVX4FqfMocs6Vljh9bc4U+mCDM90ph+8fGNb4h8dB9BRHkkB2J zjJXpyEJ4/P6JZXGEn8YLcdeQMZM6SWaDg0+Y4EwxxcCnYTlodNFKmqLAyGLnbWgBY8S MlXPwG1X92dtPEGXj9w35SSh7vjV6kO+38GbcSEitP/CCHUDFQRTsVPTeonn3IYwEa+h jnQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga01.intel.com (mga01.intel.com. [192.55.52.88]) by mx.google.com with ESMTPS id 5-v6si34415610pfx.61.2018.07.16.10.10.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 10:10:31 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) client-ip=192.55.52.88; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jul 2018 10:10:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,362,1526367600"; d="scan'208";a="67428421" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga002.fm.intel.com with ESMTP; 16 Jul 2018 10:10:23 -0700 Subject: [PATCH v2 01/14] mm: Plumb dev_pagemap instead of vmem_altmap to memmap_init_zone() From: Dan Williams To: akpm@linux-foundation.org Cc: Michal Hocko , Daniel Jordan , Pavel Tatashin , vishal.l.verma@intel.com, hch@lst.de, linux-mm@kvack.org, jack@suse.cz, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Mon, 16 Jul 2018 10:00:25 -0700 Message-ID: <153176042549.12695.1934863308712014061.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153176041838.12695.3365448145295112857.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP In preparation for teaching memmap_init_zone() how to initialize ZONE_DEVICE pages, pass in dev_pagemap. Cc: Michal Hocko Cc: Andrew Morton Cc: Daniel Jordan Cc: Pavel Tatashin Signed-off-by: Dan Williams --- include/linux/memory_hotplug.h | 3 ++- include/linux/mm.h | 2 +- kernel/memremap.c | 2 +- mm/memory_hotplug.c | 4 ++-- mm/page_alloc.c | 5 ++++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 4e9828cda7a2..e60085b2824d 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -14,6 +14,7 @@ struct mem_section; struct memory_block; struct resource; struct vmem_altmap; +struct dev_pagemap; #ifdef CONFIG_MEMORY_HOTPLUG /* @@ -326,7 +327,7 @@ extern int add_memory_resource(int nid, struct resource *resource, bool online); extern int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, bool want_memblock); extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, - unsigned long nr_pages, struct vmem_altmap *altmap); + unsigned long nr_pages, struct dev_pagemap *pgmap); extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); extern bool is_memblock_offlined(struct memory_block *mem); extern void remove_memory(int nid, u64 start, u64 size); diff --git a/include/linux/mm.h b/include/linux/mm.h index a0fbb9ffe380..319d01372efa 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2140,7 +2140,7 @@ static inline void zero_resv_unavail(void) {} extern void set_dma_reserve(unsigned long new_dma_reserve); extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long, - enum memmap_context, struct vmem_altmap *); + enum memmap_context, struct dev_pagemap *); extern void setup_per_zone_wmarks(void); extern int __meminit init_per_zone_wmark_min(void); extern void mem_init(void); diff --git a/kernel/memremap.c b/kernel/memremap.c index ecee37b44aa1..58327259420d 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -244,7 +244,7 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap, zone = &NODE_DATA(nid)->node_zones[ZONE_DEVICE]; if (!error) move_pfn_range_to_zone(zone, align_start >> PAGE_SHIFT, - align_size >> PAGE_SHIFT, altmap); + align_size >> PAGE_SHIFT, pgmap); } mem_hotplug_done(); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7deb49f69e27..aae4e6cc65e9 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -779,7 +779,7 @@ static void __meminit resize_pgdat_range(struct pglist_data *pgdat, unsigned lon } void __ref move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, - unsigned long nr_pages, struct vmem_altmap *altmap) + unsigned long nr_pages, struct dev_pagemap *pgmap) { struct pglist_data *pgdat = zone->zone_pgdat; int nid = pgdat->node_id; @@ -805,7 +805,7 @@ void __ref move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, * are reserved so nobody should be touching them so we should be safe */ memmap_init_zone(nr_pages, nid, zone_idx(zone), start_pfn, - MEMMAP_HOTPLUG, altmap); + MEMMAP_HOTPLUG, pgmap); set_zone_contiguous(zone); } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1521100f1e63..545a5860cce7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5459,10 +5459,11 @@ 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) + struct dev_pagemap *pgmap) { unsigned long end_pfn = start_pfn + size; pg_data_t *pgdat = NODE_DATA(nid); + struct vmem_altmap *altmap = NULL; unsigned long pfn; unsigned long nr_initialised = 0; struct page *page; @@ -5477,6 +5478,8 @@ 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 (pgmap && pgmap->altmap_valid) + altmap = &pgmap->altmap; if (altmap && start_pfn == altmap->base_pfn) start_pfn += altmap->reserve;