diff options
author | Miaohe Lin <linmiaohe@huawei.com> | 2023-08-01 20:37:23 +0800 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2023-08-21 13:37:32 -0700 |
commit | ebddd111fcd13fefd7350f77201dfc5605672909 (patch) | |
tree | 69c3d3111aa489e9e7ffbc82ac7ebaca3f3c53cd /mm/page_alloc.c | |
parent | 549f5c771e1be6985c29d5f1e0bbba11a8897ec8 (diff) | |
download | lwn-ebddd111fcd13fefd7350f77201dfc5605672909.tar.gz lwn-ebddd111fcd13fefd7350f77201dfc5605672909.zip |
mm/page_alloc: avoid unneeded alike_pages calculation
When free_pages is 0, alike_pages is not used. So alike_pages calculation
can be avoided by checking free_pages early to save cpu cycles. Also fix
typo 'comparable'. It should be 'compatible' here.
Link: https://lkml.kernel.org/r/20230801123723.2225543-1-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1eb3864e1dbc..8b17dcbb925d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1833,6 +1833,10 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, free_pages = move_freepages_block(zone, page, start_type, &movable_pages); + /* moving whole block can fail due to zone boundary conditions */ + if (!free_pages) + goto single_page; + /* * Determine how many pages are compatible with our allocation. * For movable allocation, it's the number of movable pages which @@ -1854,14 +1858,9 @@ static void steal_suitable_fallback(struct zone *zone, struct page *page, else alike_pages = 0; } - - /* moving whole block can fail due to zone boundary conditions */ - if (!free_pages) - goto single_page; - /* * If a sufficient number of pages in the block are either free or of - * comparable migratability as our allocation, claim the whole block. + * compatible migratability as our allocation, claim the whole block. */ if (free_pages + alike_pages >= (1 << (pageblock_order-1)) || page_group_by_mobility_disabled) |