From: Gregory Price <gourry@gourry.net>
To: linux-mm@kvack.org, jackmanb@google.com
Cc: kernel-team@meta.com, vishal.l.verma@intel.com,
ira.weiny@intel.com, dan.j.williams@intel.com,
longman@redhat.com, akpm@linux-foundation.org, david@kernel.org,
lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
vbabka@suse.cz, rppt@kernel.org, surenb@google.com,
mhocko@suse.com, osalvador@suse.de, ziy@nvidia.com,
matthew.brost@intel.com, joshua.hahnjy@gmail.com,
rakie.kim@sk.com, byungchul@sk.com, ying.huang@linux.alibaba.com,
apopple@nvidia.com, axelrasmussen@google.com, yuanchu@google.com,
weixugc@google.com, yury.norov@gmail.com,
linux@rasmusvillemoes.dk, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, tj@kernel.org,
hannes@cmpxchg.org, mkoutny@suse.com, sj@kernel.org,
baolin.wang@linux.alibaba.com, npache@redhat.com,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
lance.yang@linux.dev, muchun.song@linux.dev, xu.xin16@zte.com.cn,
chengming.zhou@linux.dev, jannh@google.com, linmiaohe@huawei.com,
nao.horiguchi@gmail.com, pfalcato@suse.de, rientjes@google.com,
shakeel.butt@linux.dev, riel@surriel.com, harry.yoo@oracle.com,
cl@gentwo.org, roman.gushchin@linux.dev, chrisl@kernel.org,
kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com,
bhe@redhat.com, zhengqi.arch@bytedance.com, terry.bowman@amd.com
Subject: [RFC] __GFP_UNMAPPED and __GFP_PRIVATE follow up
Date: Thu, 14 May 2026 13:42:09 -0400 [thread overview]
Message-ID: <agYJcRgOHho8upVv@gourry-fedora-PF4VCD3F> (raw)
I'm sending this as a general follow up to the __GFP_UNMAPPED and
__GFP_PRIVATE proposals that were discussed at LSFMMBPF '26
__GFP_PRIVATE
https://lore.kernel.org/linux-mm/20260222084842.1824063-3-gourry@gourry.net/
__GFP_UNMAPPED
https://lore.kernel.org/linux-mm/20260320-page_alloc-unmapped-v2-0-28bf1bd54f41@google.com/
There is a general push to avoid new GFP flags, and there were common
questions about alloc_context.
I have an idea for that, but first, let me address something about
__GFP_PRIVATE.
For __GFP_PRIVATE there was a question about whether the global nodemask
interfaces could be fixed. I've taken a bit of time to look at this and
I'm again left saying: Not without completely reinventing the wheel.
In particular, there's nothing that prevents an N_MEMORY_PRIVATE node
from also being N_CPU or N_GENERIC_INTIATOR.
In addition, there are a few hundred instances across the kernel of
nodemasks being cobbled together from node_states[] masks and stuff
like remap operations that may result in a private node finding its
way into a nodemask.
This kind of pattern isn't going away, and node_states have UAPI
implications associated with them :[.
The reality we really need to make the allocation request explicit
via some argument to the allocator if we want to re-use that code.
Yesterday I spitballed the addition of a new alloc interface:
https://lore.kernel.org/linux-mm/agS76pNPlPVLgpFA@gourry-fedora-PF4VCD3F/
I cannot speak for Brendan, however, in his cover letter he said:
https://lore.kernel.org/linux-mm/20260320-page_alloc-unmapped-v2-0-28bf1bd54f41@google.com/
For now I still assume a GFP flag is the cleanest way to get that
but in principle I'm not opposed to alloc_unmapped_pages() ...
His proposal looks a lot like ALLOC_CMA, in my opinion.
I'm wondering if we can solve both of these with an alloc_context
extension. In fact, I'm wondering if some GFP flags should actually
be alloc flags anyway.
We have more flexibility with alloc_flags (for now) because they're only
defined in mm/internal.h.
Maybe we could modify alloc_flags to be a struct, and export that
without being tied to down to a 32/64-bit flag field - and mark certain
sets of alloc flags verboten (internally controlled / controlled by GFP
flags, and will either be ignored or cause a BUG()).
Then we could get something like:
struct alloc_flags {
/*
* internal only: will be ignored, cleared, or cause BUG() if used,
* or should be applied via the appropriate __GFP flag.
*/
uint64_t wmark_min : 1;
uint64_t wmark_low : 1;
uint64_t wmark_high : 1;
... etc ...
/*
* external context flags
* allows explicit access to certain resources
*/
uint64_t cma : 1; /* allows access to CMA regions */
uint64_t unmapped : 1; /* return pages in unmapped state */
uint64_t managed_node : 1; /* allows access to managed node */
... etc ...
};
___alloc_frozen_pages_noprof(..., struct alloc_context *ac) {
ac->flags.wmark_low = 1;
...
prepare_alloc_pages(..., ac);
ac->flags.nofrag = alloc_flags_nofragment(...)
/* First allocation attempt */
page = get_page_from_freelist(alloc_gfp, order, &ac);
...
}
__alloc_frozen_pages_noprof(...) {
struct alloc_context ac = {};
___alloc_frozen_pages_noprof(..., ac);
}
__alloc_frozen_pages_context_noprof(..., struct alloc_flags *aflags) {
struct alloc_context ac = {};
/* Snapshot to prevent external changes */
ac.flags = aflags ? *aflags : 0;
sanitize_alloc_flags(&ac.flags); /* BUG() on insanity */
___alloc_frozen_pages_noprof(..., ac);
}
For existing users, they can continue to use __GFP flags and existing
allocation interfaces. For special context users, they can use the
context interface.
For __GFP_PRIVATE, this would look like modifying just a handful of
interfaces to include alloc_context or alloc_flags - e.g.:
folio_alloc_mpol(gfp, order, pol, ilx, nid)
->
folio_alloc_mpol(ac, order, pol_ilx, nid);
And a bit of logic to simply set:
ac.flags.managed_node = 1;
This kind of pattern already exists with things like scan_control,
oom_control, etc - which carry gfp masks around. Maybe those things
should just carry the full alloc_context around (w/ gfp and flags).
~Gregory
next reply other threads:[~2026-05-14 17:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-14 17:42 Gregory Price [this message]
2026-05-15 9:43 ` [RFC] __GFP_UNMAPPED and __GFP_PRIVATE follow up Brendan Jackman
2026-05-15 15:48 ` Gregory Price
2026-05-15 17:09 ` Brendan Jackman
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=agYJcRgOHho8upVv@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bhe@redhat.com \
--cc=byungchul@sk.com \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=cl@gentwo.org \
--cc=dan.j.williams@intel.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=ira.weiny@intel.com \
--cc=jackmanb@google.com \
--cc=jannh@google.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=lance.yang@linux.dev \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=longman@redhat.com \
--cc=lorenzo.stoakes@oracle.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=matthew.brost@intel.com \
--cc=mhiramat@kernel.org \
--cc=mhocko@suse.com \
--cc=mkoutny@suse.com \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=npache@redhat.com \
--cc=nphamcs@gmail.com \
--cc=osalvador@suse.de \
--cc=pfalcato@suse.de \
--cc=rakie.kim@sk.com \
--cc=riel@surriel.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shakeel.butt@linux.dev \
--cc=shikemeng@huaweicloud.com \
--cc=sj@kernel.org \
--cc=surenb@google.com \
--cc=terry.bowman@amd.com \
--cc=tj@kernel.org \
--cc=vbabka@suse.cz \
--cc=vishal.l.verma@intel.com \
--cc=weixugc@google.com \
--cc=xu.xin16@zte.com.cn \
--cc=ying.huang@linux.alibaba.com \
--cc=yuanchu@google.com \
--cc=yury.norov@gmail.com \
--cc=zhengqi.arch@bytedance.com \
--cc=ziy@nvidia.com \
/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