Re: [PATCH 00/22] mm: introduce N_MEMORY_COMMON
From: Gregory Price (Meta)
Date: Wed Nov 18 2026 - 10:13:28 EST
On 2026-11-18 15:01 +0800, Richard Cheng wrote:
> Hi Gregory,
>
> I've browsed through the serie, I'll go into detail in each patch
> in the following days, for now I have one general question.
>
Thank you for the read and the feedback!
> I wonder how the "common memory only" rule is enforced ?
>
> As far as I read it, there're 2 ways:
> 1. The zonelist, you build them from N_MEMORY_COMMON, so non-common
> node isn't in any zonelist.
> 2. A check at the call site, e.g. node_state(nid, N_MEMORY_COMMON) or
> folio_is_common_memory()
>
Those are essentially the two cases, which are already present in the
code in one shape or another in the existing shape:
node_state(nid, N_MEMORY);
or
folio_is_zone_device(folio)
With the exception of one or two places, the series largely modifies
these locations to use N_MEMORY_COMMON instead (or in addition, in the
case of zone device). There are a few places we add common checks where
zone device checks were not already present (because they were missing
or did not apply, usually PMD scenarios).
>
> Code reaches a node's memory in 3 ways: zonelist, node id, or by folio.
> I couldn't find a statement of which mechanism is responsible for which
> kind of path.
>
Being a bit more precise: How do we reach a node's folios/pages?
1) through some kernel structure, obvious examples:
- page tables
- VMAs / pagemaps / xarrays
- LRUs
2) pfn walks
- memory hot-unplug
- contiguous allocation
- DAMON
3) page allocator
- freelists (page allocator)
Sort of its own category since you ask it for folios from a node
> I see some consistent issues,
> 1. zonelist paths are covered by way number 1. Some of them also carry
> way number 2, some don't
> 2. node id and folio paths can only be covered by way number 2. Some entry
> points have the check, and some do not.
>
> I can't tell when a call site has no check is deliberate or missed.
> This matters once non-common node gets its own zonelist, as patch 4 metioned I think?
>
> Could you clarify the rule ? e.g. which zonelist users must filter on N_MEMORY_COMMON
> themselves? and why the zonelist alone is not enough for them ?
Some of this is obfuscated by the fact that the existing code already
does this filtering for you.
I suppose I have some premature changes to add additional filtering
where it isn't needed yet to reduce the complexity of later patches,
but I can see why this is confusing when introduced by itself.
Consider this:
- for_each_zone_zonelist_nodemask(zone, z, zonelist,
- gfp_zone(gfp_mask), nodemask) {
+ for_each_zone_node_state(zone, z, zonelist, gfp_zone(gfp_mask),
+ nodemask, N_MEMORY_COMMON) {
This is a bit of a preparatory change to later convert this to:
+ for_each_zone_node_state(zone, z, zonelist, gfp_zone(gfp_mask),
+ nodemask, N_MEMORY_RECLAIM) {
It looks like we're filtering by N_MEMORY_COMMON, but we're actually
iterating the fallback zonelist (constructed from N_MEMORY_COMMON)
struct zonelist *zonelist = node_zonelist(numa_node_id(), sc.gfp_mask);
Later we update this node_zonelist() call to determine whether the
private nodelist should be walked, at which point you do have to filter
for service support.
> Whether every path that takes a node id or a folio must check N_MEMORY_COMMON, and
> which ones are left for the feature bits in phase 3 ?
>
> Let's get the rule settled down and make it as the foundation as well as phase 2 and
> phase 3 ?
So:
1) If you're walking the normal zonelists, you're already filtered
2) If you're walking nodelists, you need to filter on N_MEMORY_COMMON
3) If you're operating on folios, you need to check common_memory()
4) If you're walking the private zonelist, filter on N_MEMORY_COMMON
So let me do this:
1) i'll restructure this phase to omit premature changes like above
(they'll move into N_MEMORY_PRIVATE and N_MEMORY_<FEATURE> commits).
2) I'll restructure N_MEMORY_COMMON commits here to handle cases 1-3
above in that order, and that'll hopefully clear up the confusion.
--
~Gregory