From: Oliver O'Halloran <oohall@gmail.com> To: linuxppc-dev@lists.ozlabs.org Cc: bsingharora@gmail.com, arbab@linux.vnet.ibm.com, linux-nvdimm@lists.01.org Subject: [PATCH 5/9] powerpc/vmemmap: Add altmap support Date: Wed, 12 Apr 2017 03:42:29 +1000 [thread overview] Message-ID: <20170411174233.21902-6-oohall@gmail.com> (raw) In-Reply-To: <20170411174233.21902-1-oohall@gmail.com> Adds support to powerpc for the altmap feature of ZONE_DEVICE memory. An altmap is a driver provided region that is used to provide the backing storage for the struct pages of ZONE_DEVICE memory. In situations where large amount of ZONE_DEVICE memory is being added to the system the altmap reduces pressure on main system memory by allowing the mm/ metadata to be stored on the device itself rather in main memory. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- arch/powerpc/mm/init_64.c | 20 +++++++++++++++----- arch/powerpc/mm/mem.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c index f8124edb6ffa..225fbb8034e6 100644 --- a/arch/powerpc/mm/init_64.c +++ b/arch/powerpc/mm/init_64.c @@ -44,6 +44,7 @@ #include <linux/slab.h> #include <linux/of_fdt.h> #include <linux/libfdt.h> +#include <linux/memremap.h> #include <asm/pgalloc.h> #include <asm/page.h> @@ -171,13 +172,17 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node) pr_debug("vmemmap_populate %lx..%lx, node %d\n", start, end, node); for (; start < end; start += page_size) { + struct vmem_altmap *altmap; void *p; int rc; if (vmemmap_populated(start, page_size)) continue; - p = vmemmap_alloc_block(page_size, node); + /* altmap lookups only work at section boundaries */ + altmap = to_vmem_altmap(SECTION_ALIGN_DOWN(start)); + + p = __vmemmap_alloc_block_buf(page_size, node, altmap); if (!p) return -ENOMEM; @@ -241,9 +246,10 @@ void __ref vmemmap_free(unsigned long start, unsigned long end) pr_debug("vmemmap_free %lx...%lx\n", start, end); for (; start < end; start += page_size) { - struct page *page = pfn_to_page(addr >> PAGE_SHIFT); - unsigned int nr_pages; - unsigned long addr; + unsigned long nr_pages, addr; + struct vmem_altmap *altmap; + struct page *section_base; + struct page *page; /* * the section has already be marked as invalid, so @@ -258,9 +264,13 @@ void __ref vmemmap_free(unsigned long start, unsigned long end) continue; page = pfn_to_page(addr >> PAGE_SHIFT); + section_base = pfn_to_page(vmemmap_section_start(start)); nr_pages = 1 << page_order; - if (PageReserved(page)) { + altmap = to_vmem_altmap((unsigned long) section_base); + if (altmap) { + vmem_altmap_free(altmap, nr_pages); + } else if (PageReserved(page)) { /* allocated from bootmem */ if (page_size < PAGE_SIZE) { /* diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 3bbba178b464..6f7b64eaa9d8 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -36,6 +36,7 @@ #include <linux/hugetlb.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <linux/memremap.h> #include <asm/pgalloc.h> #include <asm/prom.h> @@ -176,7 +177,8 @@ int arch_remove_memory(u64 start, u64 size, enum memory_type type) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; - struct zone *zone; + struct vmem_altmap *altmap; + struct page *page; int ret; /* @@ -193,8 +195,16 @@ int arch_remove_memory(u64 start, u64 size, enum memory_type type) return -EINVAL; } - zone = page_zone(pfn_to_page(start_pfn)); - ret = __remove_pages(zone, start_pfn, nr_pages); + /* + * If we have an altmap then we need to skip over any reserved PFNs + * when querying the zone. + */ + page = pfn_to_page(start_pfn); + altmap = to_vmem_altmap((unsigned long) page); + if (altmap) + page += vmem_altmap_offset(altmap); + + ret = __remove_pages(page_zone(page), start_pfn, nr_pages); if (ret) return ret; -- 2.9.3 _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Oliver O'Halloran <oohall@gmail.com> To: linuxppc-dev@lists.ozlabs.org Cc: arbab@linux.vnet.ibm.com, bsingharora@gmail.com, linux-nvdimm@lists.01.org, Oliver O'Halloran <oohall@gmail.com> Subject: [PATCH 5/9] powerpc/vmemmap: Add altmap support Date: Wed, 12 Apr 2017 03:42:29 +1000 [thread overview] Message-ID: <20170411174233.21902-6-oohall@gmail.com> (raw) In-Reply-To: <20170411174233.21902-1-oohall@gmail.com> Adds support to powerpc for the altmap feature of ZONE_DEVICE memory. An altmap is a driver provided region that is used to provide the backing storage for the struct pages of ZONE_DEVICE memory. In situations where large amount of ZONE_DEVICE memory is being added to the system the altmap reduces pressure on main system memory by allowing the mm/ metadata to be stored on the device itself rather in main memory. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- arch/powerpc/mm/init_64.c | 20 +++++++++++++++----- arch/powerpc/mm/mem.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c index f8124edb6ffa..225fbb8034e6 100644 --- a/arch/powerpc/mm/init_64.c +++ b/arch/powerpc/mm/init_64.c @@ -44,6 +44,7 @@ #include <linux/slab.h> #include <linux/of_fdt.h> #include <linux/libfdt.h> +#include <linux/memremap.h> #include <asm/pgalloc.h> #include <asm/page.h> @@ -171,13 +172,17 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node) pr_debug("vmemmap_populate %lx..%lx, node %d\n", start, end, node); for (; start < end; start += page_size) { + struct vmem_altmap *altmap; void *p; int rc; if (vmemmap_populated(start, page_size)) continue; - p = vmemmap_alloc_block(page_size, node); + /* altmap lookups only work at section boundaries */ + altmap = to_vmem_altmap(SECTION_ALIGN_DOWN(start)); + + p = __vmemmap_alloc_block_buf(page_size, node, altmap); if (!p) return -ENOMEM; @@ -241,9 +246,10 @@ void __ref vmemmap_free(unsigned long start, unsigned long end) pr_debug("vmemmap_free %lx...%lx\n", start, end); for (; start < end; start += page_size) { - struct page *page = pfn_to_page(addr >> PAGE_SHIFT); - unsigned int nr_pages; - unsigned long addr; + unsigned long nr_pages, addr; + struct vmem_altmap *altmap; + struct page *section_base; + struct page *page; /* * the section has already be marked as invalid, so @@ -258,9 +264,13 @@ void __ref vmemmap_free(unsigned long start, unsigned long end) continue; page = pfn_to_page(addr >> PAGE_SHIFT); + section_base = pfn_to_page(vmemmap_section_start(start)); nr_pages = 1 << page_order; - if (PageReserved(page)) { + altmap = to_vmem_altmap((unsigned long) section_base); + if (altmap) { + vmem_altmap_free(altmap, nr_pages); + } else if (PageReserved(page)) { /* allocated from bootmem */ if (page_size < PAGE_SIZE) { /* diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 3bbba178b464..6f7b64eaa9d8 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -36,6 +36,7 @@ #include <linux/hugetlb.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <linux/memremap.h> #include <asm/pgalloc.h> #include <asm/prom.h> @@ -176,7 +177,8 @@ int arch_remove_memory(u64 start, u64 size, enum memory_type type) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; - struct zone *zone; + struct vmem_altmap *altmap; + struct page *page; int ret; /* @@ -193,8 +195,16 @@ int arch_remove_memory(u64 start, u64 size, enum memory_type type) return -EINVAL; } - zone = page_zone(pfn_to_page(start_pfn)); - ret = __remove_pages(zone, start_pfn, nr_pages); + /* + * If we have an altmap then we need to skip over any reserved PFNs + * when querying the zone. + */ + page = pfn_to_page(start_pfn); + altmap = to_vmem_altmap((unsigned long) page); + if (altmap) + page += vmem_altmap_offset(altmap); + + ret = __remove_pages(page_zone(page), start_pfn, nr_pages); if (ret) return ret; -- 2.9.3
next prev parent reply other threads:[~2017-04-11 17:43 UTC|newest] Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-04-11 17:42 ZONE_DEVICE and pmem API support for powerpc Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-11 17:42 ` [PATCH 1/9] mm/huge_memory: Use zap_deposited_table() more Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-12 5:44 ` Aneesh Kumar K.V 2017-04-12 5:44 ` Aneesh Kumar K.V 2017-04-18 21:35 ` David Rientjes 2017-04-18 21:35 ` David Rientjes 2017-04-11 17:42 ` [PATCH 2/9] mm/huge_memory: Deposit a pgtable for DAX PMD faults when required Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-12 5:51 ` Aneesh Kumar K.V 2017-04-12 5:51 ` Aneesh Kumar K.V 2017-04-12 5:51 ` Aneesh Kumar K.V 2017-04-11 17:42 ` [PATCH 3/9] powerpc/mm: Add _PAGE_DEVMAP for ppc64 Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-12 0:19 ` Stephen Rothwell 2017-04-12 0:19 ` Stephen Rothwell 2017-04-12 3:07 ` Aneesh Kumar K.V 2017-04-12 3:07 ` Aneesh Kumar K.V 2017-04-13 5:20 ` Aneesh Kumar K.V 2017-04-13 5:20 ` Aneesh Kumar K.V 2017-04-11 17:42 ` [PATCH 4/9] powerpc/mm: Reshuffle vmemmap_free() Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-12 0:33 ` Stephen Rothwell 2017-04-12 0:33 ` Stephen Rothwell 2017-04-11 17:42 ` Oliver O'Halloran [this message] 2017-04-11 17:42 ` [PATCH 5/9] powerpc/vmemmap: Add altmap support Oliver O'Halloran 2017-04-12 0:24 ` Balbir Singh 2017-04-12 0:24 ` Balbir Singh 2017-04-11 17:42 ` [PATCH 6/9] powerpc, mm: Enable ZONE_DEVICE on powerpc Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-12 0:25 ` Balbir Singh 2017-04-12 0:25 ` Balbir Singh 2017-04-12 0:43 ` Stephen Rothwell 2017-04-12 0:43 ` Stephen Rothwell 2017-04-12 2:03 ` Michael Ellerman 2017-04-12 2:03 ` Michael Ellerman 2017-04-11 17:42 ` [PATCH 7/9] powerpc/mm: Wire up ioremap_cache Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-23 11:53 ` [7/9] " Michael Ellerman 2017-04-23 11:53 ` Michael Ellerman 2017-04-11 17:42 ` [PATCH 8/9] powerpc/mm: Wire up hpte_removebolted for powernv Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran [not found] ` <20170411174233.21902-9-oohall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2017-04-11 22:50 ` Anton Blanchard 2017-04-11 22:50 ` Anton Blanchard 2017-04-12 0:18 ` Stephen Rothwell 2017-04-12 0:18 ` Stephen Rothwell 2017-04-12 3:30 ` Rashmica Gupta 2017-04-12 3:30 ` Rashmica Gupta 2017-04-12 1:53 ` Balbir Singh 2017-04-12 1:53 ` Balbir Singh 2017-04-13 4:21 ` Oliver O'Halloran 2017-04-13 4:21 ` Oliver O'Halloran 2017-04-13 10:10 ` Michael Ellerman 2017-04-13 10:10 ` Michael Ellerman 2017-04-11 17:42 ` [PATCH 9/9] powerpc: Add pmem API support Oliver O'Halloran 2017-04-11 17:42 ` Oliver O'Halloran 2017-04-11 18:22 ` ZONE_DEVICE and pmem API support for powerpc Dan Williams 2017-04-11 18:22 ` Dan Williams 2017-04-12 9:14 ` Oliver O'Halloran 2017-04-12 9:14 ` Oliver O'Halloran 2017-04-12 1:10 ` Stephen Rothwell 2017-04-12 1:10 ` Stephen Rothwell
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170411174233.21902-6-oohall@gmail.com \ --to=oohall@gmail.com \ --cc=arbab@linux.vnet.ibm.com \ --cc=bsingharora@gmail.com \ --cc=linux-nvdimm@lists.01.org \ --cc=linuxppc-dev@lists.ozlabs.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.