[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1617947717-2424-1-git-send-email-anshuman.khandual@arm.com>
Date: Fri, 9 Apr 2021 11:25:17 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: linux-mm@...ck.org
Cc: Anshuman Khandual <anshuman.khandual@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH] 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 79cc2ed5a716 ("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: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@....com>
---
mm/page_alloc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 604dcd69397b..81b7460e1228 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7068,10 +7068,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.
+ */
+ WARN_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.
--
2.20.1
Powered by blists - more mailing lists