* + mm-hugetlb-fix-gfp-mask-propagation-to-cma.patch added to mm-new branch
@ 2026-11-18 3:31 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-11-18 3:31 UTC (permalink / raw)
To: mm-commits, wangkefeng.wang, stable, osalvador, osalvador,
muchun.song, lance.yang, fvdl, david, azpijr, zhengqi.arch, akpm
The patch titled
Subject: mm: hugetlb: fix GFP mask propagation to CMA
has been added to the -mm mm-new branch. Its filename is
mm-hugetlb-fix-gfp-mask-propagation-to-cma.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-hugetlb-fix-gfp-mask-propagation-to-cma.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Qi Zheng <zhengqi.arch@bytedance.com>
Subject: mm: hugetlb: fix GFP mask propagation to CMA
Date: Tue, 17 Nov 2026 17:33:59 +0800
cma_alloc_frozen_compound() uses GFP_KERNEL, allowing direct reclaim
during the first MPOL_PREFERRED_MANY allocation attempt even though
the caller clears __GFP_DIRECT_RECLAIM.
Pass the caller's GFP mask through the helper so CMA respects its
reclaim constraints when trying the preferred nodes.
Link: https://lore.kernel.org/990efc61c4c3b2a4186cd578a56c6a74348fcdb1.1794907279.git.zhengqi.arch@bytedance.com
Fixes: 9bda131c6093 ("mm: cma: add cma_alloc_frozen{_compound}()")
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Frank van der Linden <fvdl@google.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: <stable@vger.kernel.org>
include/linux/cma.h | 2 +-
mm/cma.c | 10 ++++++++--
mm/hugetlb_cma.c | 4 ++--
3 files changed, 11 insertions(+), 5 deletions(-)
--- a/include/linux/cma.h~mm-hugetlb-fix-gfp-mask-propagation-to-cma
+++ a/include/linux/cma.h
@@ -56,7 +56,7 @@ extern bool cma_release(struct cma *cma,
struct page *cma_alloc_frozen(struct cma *cma, unsigned long count,
unsigned int align, bool no_warn);
-struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order);
+struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order, gfp_t gfp);
bool cma_release_frozen(struct cma *cma, const struct page *pages,
unsigned long count);
--- a/mm/cma.c~mm-hugetlb-fix-gfp-mask-propagation-to-cma
+++ a/mm/cma.c
@@ -837,9 +837,15 @@ struct page *cma_alloc_frozen(struct cma
return __cma_alloc_frozen(cma, count, align, gfp);
}
-struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order)
+struct page *cma_alloc_frozen_compound(struct cma *cma, unsigned int order, gfp_t gfp)
{
- gfp_t gfp = GFP_KERNEL | __GFP_COMP | __GFP_NOWARN;
+ /*
+ * The only caller of cma_alloc_frozen_compound() is hugetlb, and
+ * hugetlb constructs its gfp mask via htlb_alloc_mask(), which already
+ * sets __GFP_COMP. Check here for usecases bypassing htlb_alloc_mask().
+ */
+ if (WARN_ON_ONCE(!(gfp & __GFP_COMP)))
+ return NULL;
return __cma_alloc_frozen(cma, 1 << order, order, gfp);
}
--- a/mm/hugetlb_cma.c~mm-hugetlb-fix-gfp-mask-propagation-to-cma
+++ a/mm/hugetlb_cma.c
@@ -69,14 +69,14 @@ retry_cpuset:
}
if (hugetlb_cma[nid] && node_isset(nid, *nmask))
- page = cma_alloc_frozen_compound(hugetlb_cma[nid], order);
+ page = cma_alloc_frozen_compound(hugetlb_cma[nid], order, gfp_mask);
if (!page && !(gfp_mask & __GFP_THISNODE)) {
for_each_node_mask(node, *nmask) {
if (node == nid || !hugetlb_cma[node])
continue;
- page = cma_alloc_frozen_compound(hugetlb_cma[node], order);
+ page = cma_alloc_frozen_compound(hugetlb_cma[node], order, gfp_mask);
if (page)
break;
}
_
Patches currently in -mm which might be from zhengqi.arch@bytedance.com are
x86-hugetlb-disable-default-cma-reservations-on-32-bit-kernel.patch
mm-gup-allow-long-term-pins-of-cma-allocated-hugetlb-folios.patch
mm-hugetlb-fix-gfp-mask-propagation-to-cma.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-18 3:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 3:31 + mm-hugetlb-fix-gfp-mask-propagation-to-cma.patch added to mm-new branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox