From: Gregory Price <gourry@gourry.net>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com,
akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
surenb@google.com, mhocko@suse.com, mingo@redhat.com,
peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com, ziy@nvidia.com,
matthew.brost@intel.com, joshua.hahnjy@gmail.com,
rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net,
ying.huang@linux.alibaba.com, apopple@nvidia.com,
raghavendra.kt@amd.com, shy828301@gmail.com,
baolin.wang@linux.alibaba.com, osalvador@suse.de
Subject: [PATCH 2/2] sched/numa: scan read-only file mappings in tiering mode
Date: Fri, 4 Sep 2026 14:20:06 -0400 [thread overview]
Message-ID: <20260904182006.1562449-3-gourry@gourry.net> (raw)
In-Reply-To: <20260904182006.1562449-1-gourry@gourry.net>
task_numa_work() refuses to scan any read-only file-backed mapping:
if (vma->vm_file &&
(vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ)) {
trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_SHARED_RO);
continue;
}
commit 4591ce4f2d22 ("sched/numa: Do not trap hinting faults for shared
libraries") added this because such pages are expected to be cache
replicated and bounce between accessor nodes, so:
If we are never going to migrate the page, it is overhead for no gain
Memory tiering broke that premise. A slow tier folio is promoted on
hint fault based on hotness, so these can migrate now - they just never
get the chance, because the VMA is never scanned.
Observed on a 768G DRAM + 256G CXL host running a ~430G database service:
91% of its main binary (169M of 185M) accumulated on CXL.
After this patch the binary's tier residency tracked runtime load.
Scan these VMAs with the slow_only restriction. Only non-toptier folios
are made hint-faultable, so the scan never marks a toptier folio in a
read-only file mapping in any mode. A page already on the fast tier costs
nothing, and a page on the slow tier costs one hint fault, which is what
buys the promotion.
That fault is not free of placement effect: a successful promotion reports
its toptier destination node to task_numa_fault(), so it lands in
numa_faults[] like any other promotion. Only the set of VMAs that can
produce one changes.
Fixes: c574bbe91703 ("NUMA balancing: optimize page placement for memory tiering system")
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Assisted-by: Claude:claude-opus-5
---
kernel/sched/fair.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 990af0e45d69..5c5c80b17649 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4075,6 +4075,11 @@ static void reset_ptenuma_scan(struct task_struct *p)
p->mm->numa_scan_offset = 0;
}
+static bool vma_is_ro_file(struct vm_area_struct *vma)
+{
+ return vma->vm_file && (vma->vm_flags & (VM_READ | VM_WRITE)) == VM_READ;
+}
+
static bool vma_is_accessed(struct mm_struct *mm, struct vm_area_struct *vma)
{
unsigned long pids;
@@ -4211,6 +4216,8 @@ static void task_numa_work(struct callback_head *work)
}
for (; vma; vma = vma_next(&vmi)) {
+ bool ro_file;
+
if (!vma_migratable(vma) || !vma_policy_mof(vma) ||
is_vm_hugetlb_page(vma) || (vma->vm_flags & VM_MIXEDMAP)) {
trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_UNSUITABLE);
@@ -4222,9 +4229,16 @@ static void task_numa_work(struct callback_head *work)
* migrated as it is expected they are cache replicated. Avoid
* hinting faults in read-only file-backed mappings or the vDSO
* as migrating the pages will be of marginal benefit.
+ *
+ * Tiering still wants them. A read-only mapping strands just
+ * as much on the slow tier as any other, so scan it for slow
+ * tier folios alone. Nothing on the top tier is marked here,
+ * in any mode.
*/
+ ro_file = vma_is_ro_file(vma);
if (!vma->vm_mm ||
- (vma->vm_file && (vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ))) {
+ (ro_file && !(sysctl_numa_balancing_mode &
+ NUMA_BALANCING_MEMORY_TIERING))) {
trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_SHARED_RO);
continue;
}
@@ -4302,7 +4316,7 @@ static void task_numa_work(struct callback_head *work)
* VMA can cause others to become "permanently unaccessed" if a scan
* cycle is consumed entirely by the large VMA.
*/
- vma->numab_state->slow_only = false;
+ vma->numab_state->slow_only = ro_file;
if (!vma_pids_forced && !vma_is_accessed(mm, vma)) {
if (!(sysctl_numa_balancing_mode &
NUMA_BALANCING_MEMORY_TIERING)) {
--
2.55.0
next prev parent reply other threads:[~2026-09-04 18:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 18:20 [PATCH 0/2] sched/numa: stop VMA scan filters from gating promotion Gregory Price
2026-09-04 18:20 ` [PATCH 1/2] sched/numa: do not let the per-VMA PID filter gate promotion Gregory Price
2026-09-04 19:10 ` Gregory Price
2026-09-04 18:20 ` Gregory Price [this message]
2026-09-04 19:31 ` [PATCH 2/2] sched/numa: scan read-only file mappings in tiering mode Gregory Price
2026-09-07 15:35 ` Gregory Price
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=20260904182006.1562449-3-gourry@gourry.net \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=bsegall@google.com \
--cc=byungchul@sk.com \
--cc=david@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=joshua.hahnjy@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@meta.com \
--cc=kprateek.nayak@amd.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=matthew.brost@intel.com \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=osalvador@suse.de \
--cc=peterz@infradead.org \
--cc=raghavendra.kt@amd.com \
--cc=rakie.kim@sk.com \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=shy828301@gmail.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=ying.huang@linux.alibaba.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®