LoongArch: numa: Fix high_memory calculation
authorHuacai Chen <chenhuacai@loongson.cn>
Wed, 27 Sep 2023 08:19:13 +0000 (16:19 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Wed, 27 Sep 2023 08:19:13 +0000 (16:19 +0800)
For 64bit kernel without HIGHMEM, high_memory is the virtual address of
the highest physical address in the system. But __va(get_num_physpages()
<< PAGE_SHIFT) is not what we want for high_memory because there may be
holes in the physical address space. On the other hand, max_low_pfn is
calculated from memblock_end_of_DRAM(), which is exactly corresponding
to the highest physical address, so use it for high_memory calculation.

Cc: <stable@vger.kernel.org>
Fixes: d4b6f1562a3c3284adce ("LoongArch: Add Non-Uniform Memory Access (NUMA) support")
Signed-off-by: Chong Qiao <qiaochong@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/numa.c

index c7d33c489e048ccc0c5ec41b164b6b70c685e6d1..6e65ff12d5c7dc5062bc4d9bce24f4ef68f3b8da 100644 (file)
@@ -436,7 +436,7 @@ void __init paging_init(void)
 
 void __init mem_init(void)
 {
-       high_memory = (void *) __va(get_num_physpages() << PAGE_SHIFT);
+       high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
        memblock_free_all();
 }