diff mbox series

mm/page_alloc: unify the warning on NOFAIL and high order allocation

Message ID 0432aa5966e7bc9d88a05dcacb210b80320e0700.1719722782.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series mm/page_alloc: unify the warning on NOFAIL and high order allocation | expand

Commit Message

Qu Wenruo June 30, 2024, 4:46 a.m. UTC
Inside rmqueue() there is a dedicated WARN_ON_ONCE() to make sure
__GFP_NOFAIL is not combined with any order > 1 allocation.

However the following locations are doing the same check, but with
order > PAGE_ALLOC_COSTLY_ORDER as the threshold:

- VM_BUG_ON() inside pcp_allowed_order()
- WARN_ON_ONCE_GFP() inside __alloc_pages_may_oom()

So this looks like a behavior mismatch, and it's better to unify all the
__GFP_NOFAIL check using PAGE_ALLOC_COSTLY_ORDER for the order.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 mm/page_alloc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9ecf99190ea2..697e5cc7f3f1 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3005,9 +3005,11 @@  struct page *rmqueue(struct zone *preferred_zone,
 
 	/*
 	 * We most definitely don't want callers attempting to
-	 * allocate greater than order-1 page units with __GFP_NOFAIL.
+	 * allocate greater than PAGE_ALLOC_COSTLY_ORDER page units
+	 * with __GFP_NOFAIL.
 	 */
-	WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1));
+	WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) &&
+		     (order > PAGE_ALLOC_COSTLY_ORDER));
 
 	if (likely(pcp_allowed_order(order))) {
 		page = rmqueue_pcplist(preferred_zone, zone, order,