mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gregory Price (Meta)" <gourry@gourry.net>
To: Richard Cheng <icheng@nvidia.com>
Cc: "Gregory Price (Meta)" <gourry@gourry.net>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	kernel-team@meta.com,  linux-doc@vger.kernel.org,
	driver-core@lists.linux.dev,  linux-serial@vger.kernel.org,
	linux-pm@vger.kernel.org,  damon@lists.linux.dev,
	linux-cxl@vger.kernel.org, akpm@linux-foundation.org,
	 david@kernel.org, liam@infradead.org, vbabka@kernel.org,
	rppt@kernel.org,  surenb@google.com, mhocko@suse.com,
	corbet@lwn.net,  skhan@linuxfoundation.org,
	rdunlap@infradead.org,  gregkh@linuxfoundation.org,
	rafael@kernel.org, dakr@kernel.org,  johan@kernel.org,
	jirislaby@kernel.org, kasong@tencent.com,  qi.zheng@linux.dev,
	shakeel.butt@linux.dev, baohua@kernel.org,
	 axelrasmussen@google.com, yuanchu@google.com,
	weixugc@google.com,  baoquan.he@linux.dev,
	baolin.wang@linux.alibaba.com, yury.norov@gmail.com,
	 linux@rasmusvillemoes.dk, pavel@kernel.org, lenb@kernel.org,
	 hannes@cmpxchg.org, brendan.jackman@linux.dev, ziy@nvidia.com,
	 sj@kernel.org, muchun.song@linux.dev, osalvador@suse.de,
	 nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com,
	 lance.yang@linux.dev, usama.arif@linux.dev, kas@kernel.org,
	 xu.xin@linux.dev, chengming.zhou@linux.dev,
	joshua.hahnjy@gmail.com,  rakie.kim@sk.com,
	ying.huang@linux.alibaba.com, matthew.brost@intel.com,
	 byungchul@sk.com, apopple@nvidia.com, rientjes@google.com
Subject: Re: [PATCH 00/22] mm: introduce N_MEMORY_COMMON
Date: Wed, 18 Nov 2026 10:13:12 -0500	[thread overview]
Message-ID: <179501479267.1206716.268867271510310543.b4-reply@b4> (raw)
In-Reply-To: <av1DvCQd_OvkGgLU@MWDK4CY14F>

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


      reply	other threads:[~2026-11-18 15:13 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  7:09 Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 01/22] mm: add node-state-filtered zone and node iterators Gregory Price (Meta)
2026-11-18  8:29   ` Richard Cheng
2026-11-18 15:17     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 02/22] mm: publish and clear node memory states via helpers Gregory Price (Meta)
2026-11-18  7:53   ` Richard Cheng
2026-11-18 15:20     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 03/22] mm: introduce the common-memory node state Gregory Price (Meta)
2026-11-18 15:24   ` Richard Cheng
2026-11-18 15:51     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 04/22] mm/page_alloc: build zonelists from common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 05/22] mm/mempolicy: keep interleave and tmpfs mount policies on " Gregory Price (Meta)
2026-11-18 15:30   ` Richard Cheng
2026-11-18 15:56     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 06/22] mm: base hash distribution on common memory nodes Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 07/22] mm/memory_hotplug: migrate offlined pages to common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 08/22] mm/memory-tiers: restrict demotion topology " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 09/22] mm/ksm: restrict merging " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 10/22] mm/khugepaged: restrict collapse " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 11/22] mm/mempolicy: don't NUMA-hint folios outside " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 12/22] mm/damon: restrict DAMON-native folio operations to " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 13/22] mm/hugetlb: restrict pool growth " Gregory Price (Meta)
2026-11-18  7:32   ` Richard Cheng
2026-11-18 15:25     ` Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 14/22] mm/page_alloc: count common memory nodes for kswapd recovery Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 15/22] mm/oom_kill: compare OOM constraints against common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 16/22] tty/sysrq: use common memory for the manual OOM zonelist Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 17/22] mm/vmscan: restrict reclaim to common memory Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 18/22] mm/compaction: restrict compaction " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 19/22] mm/migrate: restrict move_pages() destinations " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 20/22] PM: hibernate: size the image from " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 21/22] mm/khugepaged: base the recommended min_free_kbytes on " Gregory Price (Meta)
2026-11-14  7:09 ` [PATCH 22/22] nodemask: remove the now-unused first_memory_node/next_memory_node Gregory Price (Meta)
2026-11-18  7:01 ` [PATCH 00/22] mm: introduce N_MEMORY_COMMON Richard Cheng
2026-11-18 15:13   ` Gregory Price (Meta) [this message]

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=179501479267.1206716.268867271510310543.b4-reply@b4 \
    --to=gourry@gourry.net \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baoquan.he@linux.dev \
    --cc=brendan.jackman@linux.dev \
    --cc=byungchul@sk.com \
    --cc=chengming.zhou@linux.dev \
    --cc=corbet@lwn.net \
    --cc=dakr@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=icheng@nvidia.com \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=kasong@tencent.com \
    --cc=kernel-team@meta.com \
    --cc=lance.yang@linux.dev \
    --cc=lenb@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=matthew.brost@intel.com \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nico.pache@linux.dev \
    --cc=osalvador@suse.de \
    --cc=pavel@kernel.org \
    --cc=qi.zheng@linux.dev \
    --cc=rafael@kernel.org \
    --cc=rakie.kim@sk.com \
    --cc=rdunlap@infradead.org \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=sj@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=xu.xin@linux.dev \
    --cc=ying.huang@linux.alibaba.com \
    --cc=yuanchu@google.com \
    --cc=yury.norov@gmail.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

all inboxes | Powered by JetHome®