Re: [PATCH v3] mm/page_alloc: speeding up the iteration of max_order

From: Oscar Salvador
Date: Mon Dec 07 2020 - 08:38:27 EST


On Fri, Dec 04, 2020 at 11:51:09PM +0800, Muchun Song wrote:
> When we free a page whose order is very close to MAX_ORDER and greater
> than pageblock_order, it wastes some CPU cycles to increase max_order
> to MAX_ORDER one by one and check the pageblock migratetype of that page
> repeatedly especially when MAX_ORDER is much larger than pageblock_order.
>
> We also should not be checking migratetype of buddy when "order ==
> MAX_ORDER - 1" as the buddy pfn may be invalid, so adjust the condition.
> With the new check, we don't need the max_order check anymore, so we
> replace it.
>
> Also adjust max_order initialization so that it's lower by one than
> previously, which makes the code hopefully more clear.
>
> Fixes: d9dddbf55667 ("mm/page_alloc: prevent merging between isolated and other pageblocks")
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Acked-by: Vlastimil Babka <vbabka@xxxxxxx>

Reviewed-by: Oscar Salvador <osalvador@xxxxxxx>

--
Oscar Salvador
SUSE L3