• Liam Ni's avatar
    NUMA: optimize detection of memory with no node id assigned by firmware · ff6c3d81
    Liam Ni authored
    Sanity check that makes sure the nodes cover all memory loops over
    numa_meminfo to count the pages that have node id assigned by the
    firmware, then loops again over memblock.memory to find the total amount
    of memory and in the end checks that the difference between the total
    memory and memory that covered by nodes is less than some threshold. 
    Worse, the loop over numa_meminfo calls __absent_pages_in_range() that
    also partially traverses memblock.memory.
    
    It's much simpler and more efficient to have a single traversal of
    memblock.memory that verifies that amount of memory not covered by nodes
    is less than a threshold.
    
    Introduce memblock_validate_numa_coverage() that does exactly that and use
    it instead of numa_meminfo_cover_memory().
    
    Link: https://lkml.kernel.org/r/20231026020329.327329-1-zhiguangni01@gmail.comSigned-off-by: default avatarLiam Ni <zhiguangni01@gmail.com>
    Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Bibo Mao <maobibo@loongson.cn>
    Cc: Binbin Zhou <zhoubinbin@loongson.cn>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Feiyang Chen <chenfeiyang@loongson.cn>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Huacai Chen <chenhuacai@kernel.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: WANG Xuerui <kernel@xen0n.name>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    ff6c3d81
memblock.c 64.8 KB