]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm, memory_hotplug: add nid parameter to arch_remove_memory
authorOscar Salvador <osalvador@suse.com>
Fri, 28 Dec 2018 08:36:22 +0000 (00:36 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Dec 2018 20:11:49 +0000 (12:11 -0800)
Patch series "Do not touch pages in hot-remove path", v2.

This patchset aims for two things:

 1) A better definition about offline and hot-remove stage
 2) Solving bugs where we can access non-initialized pages
    during hot-remove operations [2] [3].

This is achieved by moving all page/zone handling to the offline
stage, so we do not need to access pages when hot-removing memory.

[1] https://patchwork.kernel.org/cover/10691415/
[2] https://patchwork.kernel.org/patch/10547445/
[3] https://www.spinics.net/lists/linux-mm/msg161316.html

This patch (of 5):

This is a preparation for the following-up patches.  The idea of passing
the nid is that it will allow us to get rid of the zone parameter
afterwards.

Link: http://lkml.kernel.org/r/20181127162005.15833-2-osalvador@suse.de
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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/memory_hotplug.c

index d5e12ff1d73cf69f1350577d61f311b5081e8075..904fe55e10fc5bf7d0906eb420236c3f195f297d 100644 (file)
@@ -661,7 +661,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, struct vmem_altmap *altmap)
+int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
index 20394e52fe272836e7e21e3e495cb50206c02c97..33cc6f676fa6224b76fe0f37399a30b2d852b449 100644 (file)
@@ -139,7 +139,8 @@ int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int __meminit arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
+int __meminit arch_remove_memory(int nid, u64 start, u64 size,
+                                       struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
index 50388190b39302470e609d43bed992ad0c3e7fa4..3e82f66d5c613e82e051235786f49c5d2e79b31f 100644 (file)
@@ -242,7 +242,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, struct vmem_altmap *altmap)
+int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap)
 {
        /*
         * There is no hardware or firmware interface which could trigger a
index c8c13c777162c42ce5c189b1ff0c8c71806796e0..a8e5c0e00fcaef3d85a0ce595db38fbe36c46532 100644 (file)
@@ -443,7 +443,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
 #endif
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
+int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = PFN_DOWN(start);
        unsigned long nr_pages = size >> PAGE_SHIFT;
index 49ecf5ecf6d329f82e11e2bf12a71fe739de3545..85c94f9a87f8c6247ddb0f645f69fee610cd1fe5 100644 (file)
@@ -860,7 +860,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, struct vmem_altmap *altmap)
+int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
index 484c1b92f078feb1605681c5c5a5df73e42e41cb..bccff68e32670ddd70762020b68551053c7c3a58 100644 (file)
@@ -1141,7 +1141,8 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end)
        remove_pagetable(start, end, true, NULL);
 }
 
-int __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap)
+int __ref arch_remove_memory(int nid, u64 start, u64 size,
+                               struct vmem_altmap *altmap)
 {
        unsigned long start_pfn = start >> PAGE_SHIFT;
        unsigned long nr_pages = size >> PAGE_SHIFT;
index 7383a7a76d69fc0f09c1dea840cb763edb344536..9e4d9b9b93ea768592997e117718774155d31c9e 100644 (file)
@@ -107,8 +107,8 @@ static inline bool movable_node_is_enabled(void)
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-extern int arch_remove_memory(u64 start, u64 size,
-               struct vmem_altmap *altmap);
+extern int arch_remove_memory(int nid, u64 start, u64 size,
+                               struct vmem_altmap *altmap);
 extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
        unsigned long nr_pages, struct vmem_altmap *altmap);
 #endif /* CONFIG_MEMORY_HOTREMOVE */
index 3eef989ef0352b6d07ae44c7ea426ef272b9b0e8..0d5603d76c37859d496b2bf016cf04355ebd23ad 100644 (file)
@@ -87,6 +87,7 @@ static void devm_memremap_pages_release(void *data)
        struct resource *res = &pgmap->res;
        resource_size_t align_start, align_size;
        unsigned long pfn;
+       int nid;
 
        pgmap->kill(pgmap->ref);
        for_each_device_pfn(pfn, pgmap)
@@ -97,13 +98,15 @@ static void devm_memremap_pages_release(void *data)
        align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
                - align_start;
 
+       nid = page_to_nid(pfn_to_page(align_start >> PAGE_SHIFT));
+
        mem_hotplug_begin();
        if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
                pfn = align_start >> PAGE_SHIFT;
                __remove_pages(page_zone(pfn_to_page(pfn)), pfn,
                                align_size >> PAGE_SHIFT, NULL);
        } else {
-               arch_remove_memory(align_start, align_size,
+               arch_remove_memory(nid, align_start, align_size,
                                pgmap->altmap_valid ? &pgmap->altmap : NULL);
                kasan_remove_zero_shadow(__va(align_start), align_size);
        }
index 6258e0e923ccc10e2a2d993e4f4a50fa684cf91b..0718cf7427b20a1f788ea900654e73ab8fd8d3a0 100644 (file)
@@ -1841,7 +1841,7 @@ void __ref __remove_memory(int nid, u64 start, u64 size)
        memblock_free(start, size);
        memblock_remove(start, size);
 
-       arch_remove_memory(start, size, NULL);
+       arch_remove_memory(nid, start, size, NULL);
 
        try_offline_node(nid);