hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9543 ---------------------------------------- When hot-adding 1G memory and then hot-removing a 128MB portion, the entire 1G PUD-level page table gets torn down because the linear mapping was created at PUD block granularity. This causes valid remaining memory to lose its mapping. Fix this by forcing PMD-level block mappings for remote NUMA nodes during arch_add_memory(), so that hot-remove only tears down PMD-sized segments rather than the full PUD range. Since hot-add/hot-remove granularity is larger than PMD size, there is no risk of incorrectly removing linear mappings belonging to adjacent memory regions. Fixes: 564bbaf3fbb5 ("mm/numa_remote: support to hotplug/hotremove remote memory") Signed-off-by: Jinjiang Tu <tujinjiang@huawei.com> --- arch/arm64/mm/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 6fd01159820b..2820748d7152 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -25,6 +25,7 @@ #include <linux/vmalloc.h> #include <linux/set_memory.h> #include <linux/kfence.h> +#include <linux/numa_remote.h> #include "internal.h" #include <asm/barrier.h> @@ -1408,7 +1409,7 @@ int arch_add_memory(int nid, u64 start, u64 size, if (can_set_direct_map() || is_virtcca_cvm_world()) flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; - else if (should_pmd_linear_mapping()) + else if (should_pmd_linear_mapping() || numa_is_remote_node(nid)) flags |= NO_PUD_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; __create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start), -- 2.43.0