From: Zi Yan Date: Tue, 31 May 2022 02:44:50 +0000 (-0400) Subject: mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=547be963c99f1e9ebc1cfabf630f64601a98dd00;p=linux.git mm: page_isolation: use compound_nr() correctly in isolate_single_pageblock() When compound_nr(page) was used, page was not guaranteed to be the head of the compound page and it could cause an infinite loop. Fix it by calling it on the head page. Link: https://lkml.kernel.org/r/20220531024450.2498431-1-zi.yan@sent.com Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity") Signed-off-by: Zi Yan Reported-by: Anshuman Khandual Link: https://lore.kernel.org/linux-mm/20220530115027.123341-1-anshuman.khandual@arm.com/ Reviewed-by: Anshuman Khandual Reviewed-by: Miaohe Lin Reviewed-by: Oscar Salvador Acked-by: Muchun Song Cc: David Hildenbrand Cc: Qian Cai Cc: Vlastimil Babka Cc: Mel Gorman Cc: Eric Ren Cc: Mike Rapoport Cc: Christophe Leroy Signed-off-by: Andrew Morton --- diff --git a/mm/page_isolation.c b/mm/page_isolation.c index 6021f8444b5a2..d200d41ad0d32 100644 --- a/mm/page_isolation.c +++ b/mm/page_isolation.c @@ -385,9 +385,9 @@ static int isolate_single_pageblock(unsigned long boundary_pfn, int flags, * above do the rest. If migration is not possible, just fail. */ if (PageCompound(page)) { - unsigned long nr_pages = compound_nr(page); struct page *head = compound_head(page); unsigned long head_pfn = page_to_pfn(head); + unsigned long nr_pages = compound_nr(head); if (head_pfn + nr_pages <= boundary_pfn) { pfn = head_pfn + nr_pages;