From: Haifeng Xu <haifeng.xu@shopee.com>
To: cl@linux.com, vbabka@suse.cz
Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com,
akpm@linux-foundation.org, roman.gushchin@linux.dev,
42.hyeyoo@gmail.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Haifeng Xu <haifeng.xu@shopee.com>
Subject: [PATCH v2] slub: Clear __GFP_COMP flag when allocating 0 order page
Date: Fri, 12 Apr 2024 09:54:31 +0000 [thread overview]
Message-ID: <20240412095431.612839-1-haifeng.xu@shopee.com> (raw)
We encounter warning messages when failing to create a new slab like
this:
page allocation failure: order:0, mode:0x1004000(GFP_NOWAIT|__GFP_COMP),
nodemask=(null)
It's a bit confusing for users because __GFP_COMP flag is used to create
compound page which implies the order should not be 0. This is because
minimum order will be tried if higher-order allocation fails and the
minimum order is 0. It's pointless to allocate 0 order page with __GFP_COMP
flag. Therefore, clear the __GFP_COMP flag when falling back to 0 order
allocation which makes the order and gfp flags matched.
Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
Suggested-by: Christoph Lameter (Ampere) <cl@linux.com>
---
Changes since v1:
- Place the check in allocate_slab() where the minimum order allocation
is performed.
---
mm/slub.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/mm/slub.c b/mm/slub.c
index a307d319e82c..e7bf1a1a31a8 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2027,6 +2027,15 @@ static struct slab *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
if (unlikely(!slab)) {
oo = s->min;
alloc_gfp = flags;
+ unsigned int order = oo_order(oo);
+
+ /*
+ * If fallback to the minimum order allocation and
+ * the order is 0, clear the __GFP_COMP flag.
+ */
+ if (order == 0)
+ alloc_gfp = alloc_gfp & ~__GFP_COMP;
+
/*
* Allocation may have failed due to fragmentation.
* Try a lower order alloc if possible
--
2.25.1
reply other threads:[~2024-04-12 9:54 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=20240412095431.612839-1-haifeng.xu@shopee.com \
--to=haifeng.xu@shopee.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).