From: Akinobu Mita <akinobu.mita@gmail.com>
To: akinobu.mita@gmail.com
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, akpm@linux-foundation.org,
axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
hannes@cmpxchg.org, david@kernel.org, mhocko@kernel.org,
zhengqi.arch@bytedance.com, shakeel.butt@linux.dev,
lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
vbabka@suse.cz, rppt@kernel.org, surenb@google.com
Subject: [PATCH 1/2] mm: memory-tiers, numa_emu: enable to create memory tiers using fake numa nodes
Date: Mon, 8 Dec 2025 18:40:27 +0900 [thread overview]
Message-ID: <20251208094028.214949-2-akinobu.mita@gmail.com> (raw)
In-Reply-To: <20251208094028.214949-1-akinobu.mita@gmail.com>
This makes it possible to create memory tiers using fake numa nodes
generated by numa emulation.
The new "numa_emulation.adistance" kernel parameter allows you to set the
abstract distance for each NUMA node.
For example, if the system is booted with the parameters
"numa=fake=2 numa_emulation.adistance=576,704", it will configure memory
tiers with node0 having the default DRAM adistance value and node1 having
a lower adistance value.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
mm/numa_emulation.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c
index 703c8fa05048..a4266da21344 100644
--- a/mm/numa_emulation.c
+++ b/mm/numa_emulation.c
@@ -6,6 +6,9 @@
#include <linux/errno.h>
#include <linux/topology.h>
#include <linux/memblock.h>
+#include <linux/memory-tiers.h>
+#include <linux/module.h>
+#include <linux/node.h>
#include <linux/numa_memblks.h>
#include <asm/numa.h>
#include <acpi/acpi_numa.h>
@@ -344,6 +347,27 @@ static int __init setup_emu2phys_nid(int *dfl_phys_nid)
return max_emu_nid;
}
+static int adistance[MAX_NUMNODES];
+module_param_array(adistance, int, NULL, 0400);
+MODULE_PARM_DESC(adistance, "Abstract distance values for each NUMA node");
+
+static int emu_calculate_adistance(struct notifier_block *self,
+ unsigned long nid, void *data)
+{
+ if (adistance[nid]) {
+ int *adist = data;
+
+ *adist = adistance[nid];
+ return NOTIFY_STOP;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block emu_adist_nb = {
+ .notifier_call = emu_calculate_adistance,
+ .priority = INT_MIN,
+};
+
/**
* numa_emulation - Emulate NUMA nodes
* @numa_meminfo: NUMA configuration to massage
@@ -532,6 +556,8 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
}
}
+ register_mt_adistance_algorithm(&emu_adist_nb);
+
/* free the copied physical distance table */
memblock_free(phys_dist, phys_size);
return;
--
2.43.0
next prev parent reply other threads:[~2025-12-08 9:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 9:40 [PATCH 0/2] mm: fix oom-killer not being invoked when demotion is enabled Akinobu Mita
2025-12-08 9:40 ` Akinobu Mita [this message]
2025-12-16 20:24 ` [PATCH 1/2] mm: memory-tiers, numa_emu: enable to create memory tiers using fake numa nodes Andrew Morton
2025-12-17 13:55 ` Akinobu Mita
2025-12-08 9:40 ` [PATCH 2/2] mm/vmscan: don't demote if there is not enough free memory in the lower memory tier Akinobu Mita
2025-12-17 12:55 ` Vlastimil Babka
2025-12-17 14:30 ` Akinobu Mita
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=20251208094028.214949-2-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@kernel.org \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--cc=zhengqi.arch@bytedance.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