提交 a7a4dd0b 编写于 作者: R Robin Murphy 提交者: Xie XiuQi

arm64: Add memory hotplug support

mainline inclusion
from mainline-5.0-rc1
commit 4ab215061554ae2a4b78744a5dd3b3c6639f16a7
category: feature
bugzilla: NA
CVE: NA

--------------------------------

Wire up the basic support for hot-adding memory. Since memory hotplug
is fairly tightly coupled to sparsemem, we tweak pfn_valid() to also
cross-check the presence of a section in the manner of the generic
implementation, before falling back to memblock to check for no-map
regions within a present section as before. By having arch_add_memory(()
create the linear mapping first, this then makes everything work in the
way that __add_section() expects.

We expect hotplug to be ACPI-driven, so the swapper_pg_dir updates
should be safe from races by virtue of the global device hotplug lock.
Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
Signed-off-by: NWill Deacon <will.deacon@arm.com>
Signed-off-by: NJing xiangfeng <jingxiangfeng@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 62fc9247
......@@ -257,6 +257,9 @@ config ZONE_DMA32
config HAVE_GENERIC_GUP
def_bool y
config ARCH_ENABLE_MEMORY_HOTPLUG
def_bool y
config SMP
def_bool y
......
......@@ -291,6 +291,14 @@ int pfn_valid(unsigned long pfn)
if ((addr >> PAGE_SHIFT) != pfn)
return 0;
#ifdef CONFIG_SPARSEMEM
if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
return 0;
if (!valid_section(__nr_to_section(pfn_to_section_nr(pfn))))
return 0;
#endif
return memblock_is_map_memory(addr);
}
EXPORT_SYMBOL(pfn_valid);
......
......@@ -1030,3 +1030,20 @@ int pud_free_pmd_page(pud_t *pudp, unsigned long addr)
pmd_free(NULL, table);
return 1;
}
#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
bool want_memblock)
{
int flags = 0;
if (debug_pagealloc_enabled())
flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
__create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start),
size, PAGE_KERNEL, pgd_pgtable_alloc, flags);
return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT,
altmap, want_memblock);
}
#endif
......@@ -464,3 +464,13 @@ void __init arm64_numa_init(void)
numa_init(dummy_numa_init);
}
/*
* We hope that we will be hotplugging memory on nodes we already know about,
* such that acpi_get_node() succeeds and we never fall back to this...
*/
int memory_add_physaddr_to_nid(u64 addr)
{
pr_warn("Unknown node for memory at 0x%llx, assuming node 0\n", addr);
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册