Commit 52219aea authored by David Hildenbrand's avatar David Hildenbrand Committed by Linus Torvalds

mm/memory_hotplug: handle memblocks only with CONFIG_ARCH_KEEP_MEMBLOCK

The comment in add_memory_resource() is stale: hotadd_new_pgdat() will no
longer call get_pfn_range_for_nid(), as a hotadded pgdat will simply span
no pages at all, until memory is moved to the zone/node via
move_pfn_range_to_zone() - e.g., when onlining memory blocks.

The only archs that care about memblocks for hotplugged memory (either for
iterating over all system RAM or testing for memory validity) are arm64,
s390x, and powerpc - due to CONFIG_ARCH_KEEP_MEMBLOCK.  Without
CONFIG_ARCH_KEEP_MEMBLOCK, we can simply stop messing with memblocks.
Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarMike Rapoport <rppt@linux.ibm.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Link: http://lkml.kernel.org/r/20200422155353.25381-3-david@redhat.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c68ab18c
...@@ -133,6 +133,9 @@ config HAVE_FAST_GUP ...@@ -133,6 +133,9 @@ config HAVE_FAST_GUP
depends on MMU depends on MMU
bool bool
# Don't discard allocated memory used to track "memory" and "reserved" memblocks
# after early boot, so it can still be used to test for validity of memory.
# Also, memblocks are updated with memory hot(un)plug.
config ARCH_KEEP_MEMBLOCK config ARCH_KEEP_MEMBLOCK
bool bool
......
...@@ -1021,12 +1021,7 @@ int __ref add_memory_resource(int nid, struct resource *res) ...@@ -1021,12 +1021,7 @@ int __ref add_memory_resource(int nid, struct resource *res)
mem_hotplug_begin(); mem_hotplug_begin();
/* if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
* Add new range to memblock so that when hotadd_new_pgdat() is called
* to allocate new pgdat, get_pfn_range_for_nid() will be able to find
* this new range and calculate total pages correctly. The range will
* be removed at hot-remove time.
*/
memblock_add_node(start, size, nid); memblock_add_node(start, size, nid);
ret = __try_online_node(nid, false); ret = __try_online_node(nid, false);
...@@ -1076,6 +1071,7 @@ int __ref add_memory_resource(int nid, struct resource *res) ...@@ -1076,6 +1071,7 @@ int __ref add_memory_resource(int nid, struct resource *res)
/* rollback pgdat allocation and others */ /* rollback pgdat allocation and others */
if (new_node) if (new_node)
rollback_node_hotadd(nid); rollback_node_hotadd(nid);
if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK))
memblock_remove(start, size); memblock_remove(start, size);
mem_hotplug_done(); mem_hotplug_done();
return ret; return ret;
...@@ -1673,8 +1669,12 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size) ...@@ -1673,8 +1669,12 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size)
mem_hotplug_begin(); mem_hotplug_begin();
arch_remove_memory(nid, start, size, NULL); arch_remove_memory(nid, start, size, NULL);
if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) {
memblock_free(start, size); memblock_free(start, size);
memblock_remove(start, size); memblock_remove(start, size);
}
__release_memory_resource(start, size); __release_memory_resource(start, size);
try_offline_node(nid); try_offline_node(nid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment