The patch titled Subject: mm/memblock: use a more appropriate order calculation when free memblock pages has been added to the -mm tree. Its filename is mm-memblock-use-a-more-appropriate-order-calculation-when-free-memblock-pages.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memblock-use-a-more-appropriate-order-calculation-when-free-memblock-pages.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memblock-use-a-more-appropriate-order-calculation-when-free-memblock-pages.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: Hailong Liu <liu.hailong6@xxxxxxxxxx> Subject: mm/memblock: use a more appropriate order calculation when free memblock pages When system in the booting stage, pages span from [start, end] of a memblock are freed to buddy in a order as large as possible (less than MAX_ORDER) at first, then decrease gradually to a proper order(less than end) in a loop. However, *min(MAX_ORDER - 1UL, __ffs(start))* can not get the largest order in some cases. Instead, *__ffs(end - start)* may be more appropriate and meaningful. Link: https://lkml.kernel.org/r/20201203152311.5272-1-carver4lio@xxxxxxx Signed-off-by: Hailong Liu <liu.hailong6@xxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/memblock.c~mm-memblock-use-a-more-appropriate-order-calculation-when-free-memblock-pages +++ a/mm/memblock.c @@ -2010,7 +2010,7 @@ static void __init __free_pages_memory(u int order; while (start < end) { - order = min(MAX_ORDER - 1UL, __ffs(start)); + order = min(MAX_ORDER - 1UL, __ffs(end - start)); while (start + (1UL << order) > end) order--; _ Patches currently in -mm which might be from liu.hailong6@xxxxxxxxxx are mm-memblock-use-a-more-appropriate-order-calculation-when-free-memblock-pages.patch