mm: pass nid to reserve_bootmem_region()
authorYajun Deng <yajun.deng@linux.dev>
Mon, 19 Jun 2023 02:34:06 +0000 (10:34 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 23 Jun 2023 23:59:27 +0000 (16:59 -0700)
commit61167ad5fecdeaa037f3df1ba354dddd5f66a1ed
treeb0e08754150ba76f267e9181f2a6173f2d99776c
parent9883c7f84053cec2826ca3c56254601b5ce9cdbe
mm: pass nid to reserve_bootmem_region()

early_pfn_to_nid() is called frequently in init_reserved_page(), it
returns the node id of the PFN.  These PFN are probably from the same
memory region, they have the same node id.  It's not necessary to call
early_pfn_to_nid() for each PFN.

Pass nid to reserve_bootmem_region() and drop the call to
early_pfn_to_nid() in init_reserved_page().  Also, set nid on all reserved
pages before doing this, as some reserved memory regions may not be set
nid.

The most beneficial function is memmap_init_reserved_pages() if
CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled.

The following data was tested on an x86 machine with 190GB of RAM.

before:
memmap_init_reserved_pages()  67ms

after:
memmap_init_reserved_pages()  20ms

Link: https://lkml.kernel.org/r/20230619023406.424298-1-yajun.deng@linux.dev
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h
mm/memblock.c
mm/mm_init.c