Skip to content
Permalink
Browse files
mm/page_alloc: Ensure that HUGETLB_PAGE_ORDER is less than MAX_ORDER
pageblock_order must always be less than MAX_ORDER, otherwise it might lead
to an warning during boot. A similar problem got fixed on arm64 platform
with the commit 79cc2ed ("arm64/mm: Drop THP conditionality from
FORCE_MAX_ZONEORDER"). Assert the above condition before HUGETLB_PAGE_ORDER
gets assigned as pageblock_order. This will help detect the problem earlier
on platforms where HUGETLB_PAGE_SIZE_VARIABLE is enabled.

Cc: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
  • Loading branch information
Anshuman Khandual authored and intel-lab-lkp committed Apr 12, 2021
1 parent 2932a9e commit 2dcbbc0896348946a9551948765b9b242cf37da6
Showing 1 changed file with 9 additions and 2 deletions.
@@ -6651,10 +6651,17 @@ void __init set_pageblock_order(void)
if (pageblock_order)
return;

if (HPAGE_SHIFT > PAGE_SHIFT)
if (HPAGE_SHIFT > PAGE_SHIFT) {
/*
* pageblock_order must always be less than
* MAX_ORDER. So does HUGETLB_PAGE_ORDER if
* that is being assigned here.
*/
BUILD_BUG_ON(HUGETLB_PAGE_ORDER >= MAX_ORDER);
order = HUGETLB_PAGE_ORDER;
else
} else {
order = MAX_ORDER - 1;
}

/*
* Assume the largest contiguous order of interest is a huge page.

0 comments on commit 2dcbbc0

Please sign in to comment.