linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] mm/page_alloc: unify the warning on NOFAIL and high order allocation
Date: Sun, 30 Jun 2024 14:16:51 +0930	[thread overview]
Message-ID: <0432aa5966e7bc9d88a05dcacb210b80320e0700.1719722782.git.wqu@suse.com> (raw)

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 --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,
-- 
2.45.2



                 reply	other threads:[~2024-06-30  4:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0432aa5966e7bc9d88a05dcacb210b80320e0700.1719722782.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox