The patch titled Subject: arm: arm64: introduce CONFIG_HAVE_MEMBLOCK_PFN_VALID has been added to the -mm tree. Its filename is arm-arm64-introduce-config_have_memblock_pfn_valid.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/arm-arm64-introduce-config_have_memblock_pfn_valid.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/arm-arm64-introduce-config_have_memblock_pfn_valid.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Jia He <hejianet@xxxxxxxxx> Subject: arm: arm64: introduce CONFIG_HAVE_MEMBLOCK_PFN_VALID Patch series "remain and optimize memblock_next_valid_pfn on arm and arm64", v11. b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") optimized the loop in memmap_init_zone(). But it causes possible panic bug. So Daniel Vacek reverted it later. But as suggested by Daniel Vacek, it is fine to using memblock to skip gaps and finding next valid frame with CONFIG_HAVE_ARCH_PFN_VALID. More from what Daniel said: "On arm and arm64, memblock is used by default. But generic version of pfn_valid() is based on mem sections and memblock_next_valid_pfn() does not always return the next valid one but skips more resulting in some valid frames to be skipped (as if they were invalid). And that's why kernel was eventually crashing on some !arm machines." About the performance consideration: As said by James in b92df1de5, "I have tested this patch on a virtual model of a Samurai CPU with a sparse memory map. The kernel boot time drops from 109 to 62 seconds." Thus it would be better if we remain memblock_next_valid_pfn on arm/arm64. Besides we can remain memblock_next_valid_pfn, there is still some room for improvement. After this set, I can see the time overhead of memmap_init is reduced from 27956us to 13537us in my armv8a server(QDF2400 with 96G memory, pagesize 64k). I believe arm server will benefit more if memory is larger than TBs Patch 1 introduces new config to make codes more generic Patch 2 remains the memblock_next_valid_pfn on arm and arm64,this patch is originated from b92df1de5 Patch 3 optimizes the memblock_next_valid_pfn() This patch (of 3): Make CONFIG_HAVE_MEMBLOCK_PFN_VALID a new config option so it can move memblock_next_valid_pfn to generic code file. All the latter optimizations are based on this config. The memblock initialization time on arm/arm64 can benefit from this. Link: http://lkml.kernel.org/r/1534907237-2982-2-git-send-email-jia.he@xxxxxxxxxxxxxxxx Signed-off-by: Jia He <jia.he@xxxxxxxxxxxxxxxx> Reviewed-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: AKASHI Takahiro <takahiro.akashi@xxxxxxxxxx> Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Cc: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx> Cc: Daniel Vacek <neelx@xxxxxxxxxx> Cc: Eugeniu Rosca <erosca@xxxxxxxxxxxxxx> Cc: Gioh Kim <gi-oh.kim@xxxxxxxxxxxxxxxx> Cc: James Morse <james.morse@xxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Kemi Wang <kemi.wang@xxxxxxxxx> Cc: Laura Abbott <labbott@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Nikolay Borisov <nborisov@xxxxxxxx> Cc: Pavel Tatashin <pavel.tatashin@xxxxxxxxxxxxx> Cc: Petr Tesarik <ptesarik@xxxxxxxx> Cc: Philip Derrin <philip@cog.systems> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: Steve Capper <steve.capper@xxxxxxx> Cc: Vladimir Murzin <vladimir.murzin@xxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Wei Yang <richard.weiyang@xxxxxxxxx> Cc: Will Deacon <will.deacon@xxxxxxx> Cc: YASUAKI ISHIMATSU <yasu.isimatu@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/arm/Kconfig | 1 + arch/arm64/Kconfig | 1 + mm/Kconfig | 3 +++ 3 files changed, 5 insertions(+) --- a/arch/arm64/Kconfig~arm-arm64-introduce-config_have_memblock_pfn_valid +++ a/arch/arm64/Kconfig @@ -787,6 +787,7 @@ config ARCH_FLATMEM_ENABLE config HAVE_ARCH_PFN_VALID def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM + select HAVE_MEMBLOCK_PFN_VALID config HW_PERF_EVENTS def_bool y --- a/arch/arm/Kconfig~arm-arm64-introduce-config_have_memblock_pfn_valid +++ a/arch/arm/Kconfig @@ -1634,6 +1634,7 @@ config ARCH_SELECT_MEMORY_MODEL config HAVE_ARCH_PFN_VALID def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM + select HAVE_MEMBLOCK_PFN_VALID config HAVE_GENERIC_GUP def_bool y --- a/mm/Kconfig~arm-arm64-introduce-config_have_memblock_pfn_valid +++ a/mm/Kconfig @@ -136,6 +136,9 @@ config HAVE_MEMBLOCK_NODE_MAP config HAVE_MEMBLOCK_PHYS_MAP bool +config HAVE_MEMBLOCK_PFN_VALID + bool + config HAVE_GENERIC_GUP bool _ Patches currently in -mm which might be from hejianet@xxxxxxxxx are arm-arm64-introduce-config_have_memblock_pfn_valid.patch mm-page_alloc-remain-memblock_next_valid_pfn-on-arm-arm64.patch mm-page_alloc-reduce-unnecessary-binary-search-in-memblock_next_valid_pfn.patch