]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
mm: pass the vmem_altmap to arch_remove_memory and __remove_pages
authorChristoph Hellwig <hch@lst.de>
Fri, 29 Dec 2017 07:53:55 +0000 (08:53 +0100)
committerDan Williams <dan.j.williams@intel.com>
Mon, 8 Jan 2018 19:46:23 +0000 (11:46 -0800)
We can just pass this on instead of having to do a radix tree lookup
without proper locking 2 levels into the callchain.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
arch/ia64/mm/init.c
arch/powerpc/mm/mem.c
arch/s390/mm/init.c
arch/sh/mm/init.c
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c
include/linux/memory_hotplug.h
kernel/memremap.c
mm/hmm.c
mm/memory_hotplug.c

index 2e2e4f5322049ed4556048a8503e8c64377d9e19..6a8ce9e1536e8a2238e54c41cab79d3376fecc3d 100644 (file)
@@ -663,7 +663,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(u64 start, u64 size)
+int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
@@ -671,7 +671,7 @@ int arch_remove_memory(u64 start, u64 size)
        int ret;
 
        zone = page_zone(pfn_to_page(start_pfn));
-       ret = __remove_pages(zone, start_pfn, nr_pages);
+       ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
        if (ret)
                pr_warn("%s: Problem encountered in __remove_pages() as"
                        " ret=%d\n", __func__,  ret);
index e670cfc2766e081e80c2691fcece781c35b9431f..22aa528b78a2444546ca4b28f116abe960ff483d 100644 (file)
@@ -149,11 +149,10 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(u64 start, u64 size)
+int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
-       struct vmem_altmap *altmap;
        struct page *page;
        int ret;
 
@@ -162,11 +161,10 @@ int arch_remove_memory(u64 start, u64 size)
         * 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);
+       ret = __remove_pages(page_zone(page), start_pfn, nr_pages, altmap);
        if (ret)
                return ret;
 
index e12c5af50cd7a426876ce414ffec6291f3efefd8..3fa3e532361227ad134f32b46c6c0db58d9d1240 100644 (file)
@@ -240,7 +240,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(u64 start, u64 size)
+int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        /*
         * There is no hardware or firmware interface which could trigger a
index 552afbf55bad3d750a6cd2c0cfede1115b948f90..ce0bbaa7e40403b37d0d6dbdf107693dd24a2613 100644 (file)
@@ -510,7 +510,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
 #endif
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(u64 start, u64 size)
+int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = PFN_DOWN(start);
        unsigned long nr_pages = size >> PAGE_SHIFT;
@@ -518,7 +518,7 @@ int arch_remove_memory(u64 start, u64 size)
        int ret;
 
        zone = page_zone(pfn_to_page(start_pfn));
-       ret = __remove_pages(zone, start_pfn, nr_pages);
+       ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
        if (unlikely(ret))
                pr_warn("%s: Failed, __remove_pages() == %d\n", __func__,
                        ret);
index 8a3091511a71bbc3269ecc67f3f79a7b8db726cc..79cb066f40c0d4a4607a7b7aa4e5524a203b5e10 100644 (file)
@@ -839,14 +839,14 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(u64 start, u64 size)
+int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
        struct zone *zone;
 
        zone = page_zone(pfn_to_page(start_pfn));
-       return __remove_pages(zone, start_pfn, nr_pages);
+       return __remove_pages(zone, start_pfn, nr_pages, altmap);
 }
 #endif
 #endif
index 594902ef56ef84ee035462f219873e535ed2fa76..3c046618cc7e01e35c63a6353ef30642032ec9ec 100644 (file)
@@ -1132,21 +1132,19 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end)
        remove_pagetable(start, end, true);
 }
 
-int __ref arch_remove_memory(u64 start, u64 size)
+int __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
        struct page *page = pfn_to_page(start_pfn);
-       struct vmem_altmap *altmap;
        struct zone *zone;
        int ret;
 
        /* With altmap the first mapped page is offset from @start */
-       altmap = to_vmem_altmap((unsigned long) page);
        if (altmap)
                page += vmem_altmap_offset(altmap);
        zone = page_zone(page);
-       ret = __remove_pages(zone, start_pfn, nr_pages);
+       ret = __remove_pages(zone, start_pfn, nr_pages, altmap);
        WARN_ON_ONCE(ret);
        kernel_physical_mapping_remove(start, start + size);
 
index cbdd6d52e877d2b3592814780e82256f52a385b6..e71927d0d46bd98db16e2ca2c07389443a2def47 100644 (file)
@@ -126,9 +126,10 @@ static inline bool movable_node_is_enabled(void)
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
 extern bool is_pageblock_removable_nolock(struct page *page);
-extern int arch_remove_memory(u64 start, u64 size);
+extern int arch_remove_memory(u64 start, u64 size,
+               struct vmem_altmap *altmap);
 extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
-       unsigned long nr_pages);
+       unsigned long nr_pages, struct vmem_altmap *altmap);
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 
 /* reasonably generic interface to expand the physical pages */
index 8488cdeead160f4292436f9365d8b6cb070ff089..380fca1c4a0204acad77bc18aab69297dd4bf3fb 100644 (file)
@@ -304,7 +304,7 @@ static void devm_memremap_pages_release(struct device *dev, void *data)
        align_size = ALIGN(resource_size(res), SECTION_SIZE);
 
        mem_hotplug_begin();
-       arch_remove_memory(align_start, align_size);
+       arch_remove_memory(align_start, align_size, pgmap->altmap);
        mem_hotplug_done();
 
        untrack_pfn(NULL, PHYS_PFN(align_start), align_size);
index 231aaacd19971b6a37c7015a1c85fa0ca58c0d69..5d17ba89062fc4dd2cb4a1e0b91d00c87b6ac8d1 100644 (file)
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -838,10 +838,10 @@ static void hmm_devmem_release(struct device *dev, void *data)
 
        mem_hotplug_begin();
        if (resource->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY)
-               __remove_pages(zone, start_pfn, npages);
+               __remove_pages(zone, start_pfn, npages, NULL);
        else
                arch_remove_memory(start_pfn << PAGE_SHIFT,
-                                  npages << PAGE_SHIFT);
+                                  npages << PAGE_SHIFT, NULL);
        mem_hotplug_done();
 
        hmm_devmem_radix_release(resource);
index b36f1822c432d28cbfb9908e77a89504931138e0..eae6bf47caf7a5cf2aa1db464bd206fbf1d86901 100644 (file)
@@ -569,7 +569,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms,
  * calling offline_pages().
  */
 int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
-                unsigned long nr_pages)
+                unsigned long nr_pages, struct vmem_altmap *altmap)
 {
        unsigned long i;
        unsigned long map_offset = 0;
@@ -577,10 +577,6 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
 
        /* In the ZONE_DEVICE case device driver owns the memory region */
        if (is_dev_zone(zone)) {
-               struct page *page = pfn_to_page(phys_start_pfn);
-               struct vmem_altmap *altmap;
-
-               altmap = to_vmem_altmap((unsigned long) page);
                if (altmap)
                        map_offset = vmem_altmap_offset(altmap);
        } else {
@@ -1890,7 +1886,7 @@ void __ref remove_memory(int nid, u64 start, u64 size)
        memblock_free(start, size);
        memblock_remove(start, size);
 
-       arch_remove_memory(start, size);
+       arch_remove_memory(start, size, NULL);
 
        try_offline_node(nid);