mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gregory Price (Meta)" <gourry@gourry.net>
To: linux-mm@kvack.org
Cc: 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,
	gourry@gourry.net, 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: [PATCH 08/22] mm/memory-tiers: restrict demotion topology to common memory
Date: Sat, 14 Nov 2026 02:09:45 -0500	[thread overview]
Message-ID: <20261114070959.3490008-9-gourry@gourry.net> (raw)
In-Reply-To: <20261114070959.3490008-1-gourry@gourry.net>

Memory outside N_MEMORY_COMMON is outside the ordinary allocation pool
and cannot be a generic demotion source or destination.

Build demotion paths and the default DRAM performance reference from
N_MEMORY_COMMON rather than every node that has memory, and do not
assign other nodes to a memory tier through the generic hotplug path.

Removing a node's memory already resets its demotion targets, so a node
that unplugs and returns outside N_MEMORY_COMMON keeps none.

All memory nodes currently carry N_MEMORY_COMMON, behavior is unchanged.

Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
---
 mm/memory-tiers.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c
index 7fc56a8c66518..97d5ecefd89f3 100644
--- a/mm/memory-tiers.c
+++ b/mm/memory-tiers.c
@@ -370,7 +370,8 @@ int next_demotion_node(int node, const nodemask_t *allowed_mask)
 	 * closest demotion target.
 	 */
 	nodes_complement(mask, *allowed_mask);
-	return find_next_best_node_in(node, &mask, &node_states[N_MEMORY]);
+	return find_next_best_node_in(node, &mask,
+				      &node_states[N_MEMORY_COMMON]);
 }
 
 static void disable_all_demotion_targets(void)
@@ -405,7 +406,7 @@ static void dump_demotion_targets(void)
 {
 	int node;
 
-	for_each_node_state(node, N_MEMORY) {
+	for_each_node_state(node, N_MEMORY_COMMON) {
 		struct memory_tier *memtier = __node_get_memory_tier(node);
 		nodemask_t preferred = node_demotion[node].preferred;
 
@@ -441,7 +442,7 @@ static void establish_demotion_targets(void)
 
 	disable_all_demotion_targets();
 
-	for_each_node_state(node, N_MEMORY) {
+	for_each_node_state(node, N_MEMORY_COMMON) {
 		best_distance = -1;
 		nd = &node_demotion[node];
 
@@ -459,7 +460,7 @@ static void establish_demotion_targets(void)
 		 * nodelist to skip list so that we find the best node from the
 		 * memtier nodelist.
 		 */
-		nodes_andnot(tier_nodes, node_states[N_MEMORY], tier_nodes);
+		nodes_andnot(tier_nodes, node_states[N_MEMORY_COMMON], tier_nodes);
 
 		/*
 		 * Find all the nodes in the memory tier node list of same best distance.
@@ -468,7 +469,7 @@ static void establish_demotion_targets(void)
 		 */
 		do {
 			target = find_next_best_node_in(node, &tier_nodes,
-							&node_states[N_MEMORY]);
+							&node_states[N_MEMORY_COMMON]);
 			if (target == NUMA_NO_NODE)
 				break;
 
@@ -507,7 +508,7 @@ static void establish_demotion_targets(void)
 	 * allocation to a set of nodes that is closer the above selected
 	 * preferred node.
 	 */
-	lower_tier = node_states[N_MEMORY];
+	lower_tier = node_states[N_MEMORY_COMMON];
 	list_for_each_entry(memtier, &memory_tiers, list) {
 		/*
 		 * Keep removing current tier from lower_tier nodes,
@@ -554,7 +555,7 @@ static struct memory_tier *set_node_memory_tier(int node)
 
 	lockdep_assert_held_once(&memory_tier_lock);
 
-	if (!node_state(node, N_MEMORY))
+	if (!node_state(node, N_MEMORY_COMMON))
 		return ERR_PTR(-EINVAL);
 
 	mt_calc_adistance(node, &adist);
@@ -706,8 +707,8 @@ static int __init memory_tier_late_init(void)
 	get_online_mems();
 	guard(mutex)(&memory_tier_lock);
 
-	/* Assign each uninitialized N_MEMORY node to a memory tier. */
-	for_each_node_state(nid, N_MEMORY) {
+	/* Assign each uninitialized common memory node to a memory tier. */
+	for_each_node_state(nid, N_MEMORY_COMMON) {
 		/*
 		 * Some device drivers may have initialized
 		 * memory tiers, potentially bringing memory nodes
@@ -929,8 +930,8 @@ static int __init memory_tier_init(void)
 	if (IS_ERR(default_dram_type))
 		panic("%s() failed to allocate default DRAM tier\n", __func__);
 
-	/* Record nodes with memory and CPU to set default DRAM performance. */
-	nodes_and(default_dram_nodes, node_states[N_MEMORY],
+	/* Record common-memory nodes with CPUs for default DRAM performance. */
+	nodes_and(default_dram_nodes, node_states[N_MEMORY_COMMON],
 		  node_states[N_CPU]);
 
 	hotplug_node_notifier(memtier_hotplug_callback, MEMTIER_HOTPLUG_PRI);
-- 
2.53.1-Meta


  parent reply	other threads:[~2026-11-14  7:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-14  7:09 [PATCH 00/22] mm: introduce N_MEMORY_COMMON 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-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-14  7:09 ` [PATCH 03/22] mm: introduce the common-memory node state 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-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 ` Gregory Price (Meta) [this message]
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-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

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=20261114070959.3490008-9-gourry@gourry.net \
    --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=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®