__init_single_page would set page count and __free_pages_core would reset it. A lot of pages don't need to do this when in MEMINIT_EARLY context. It's unnecessary and time-consuming. The first two patches are in preparation for the next two, they didn't change anything. The third patch only set page count for the reserved region, not all of the region. The fourth patch removes the set paget count in deferred_init_pages. Yajun Deng (4): mm: pass set_count and set_reserved to __init_single_page mm: Introduce MEMINIT_LATE context mm: Set page count and mark page reserved in reserve_bootmem_region mm: don't set page count in deferred_init_pages include/linux/mmzone.h | 1 + mm/hugetlb.c | 2 +- mm/internal.h | 10 +++++--- mm/kmsan/init.c | 2 +- mm/memblock.c | 4 +-- mm/memory_hotplug.c | 2 +- mm/mm_init.c | 57 +++++++++++++++++++++++++----------------- mm/page_alloc.c | 22 +++++++++------- 8 files changed, 59 insertions(+), 41 deletions(-) -- 2.25.1