Re: [PATCH v2 3/4] sched/numa: scan read-only file mappings in tiering mode

From: David Hildenbrand (Arm)

Date: Fri Sep 18 2026 - 09:03:52 EST


On 9/11/26 02:18, Gregory Price wrote:
> From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
>
> Commit 4591ce4f2d22 ("sched/numa: Do not trap hinting faults for
> shared libraries") excludes read-only file mappings from NUMA hinting to
> prevent placement bouncing. This also hides hot file folios on slow memory
> from the tiering code.
>
> Scan these mappings when memory tiering is enabled, but make their scans
> promotion-only. Ordinary NUMA placement retains the existing restriction.
>
> On a host with 768 GB of DRAM and 256 GB of CXL memory running a roughly
> 430 GB database service, 169 MB of its 185 MB main binary accumulated on
> CXL before this change. Afterwards its tier residency tracked runtime load.
>
> Fixes: c574bbe91703 ("NUMA balancing: optimize page placement for memory tiering system")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> ---
> kernel/sched/fair.c | 23 +++++++++++++++++------
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 81359b414947..e636e8de53f1 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4061,6 +4061,16 @@ void task_numa_fault(int last_cpupid, int mem_node, int pages, int flags)
> p->numa_faults_locality[local] += pages;
> }
>
> +/*
> + * Read-only file-backed mappings are expected to be cache replicated between
> + * accessor nodes, so they are not worth sampling for placement. They can
> + * still strand on the slow tier like anything else.
> + */
> +static bool vma_is_ro_file(struct vm_area_struct *vma)
> +{
> + return vma->vm_file && (vma->vm_flags & (VM_READ | VM_WRITE)) == VM_READ;


MAP_PRIVATE can easily map a read-only file with write permissions. So the
function name is a bit misleading.

This smells like a helper that should go next to other vma helpers and have
clear semantics.

> +}
> +
> static void reset_ptenuma_scan(struct task_struct *p)
> {
> /*
> @@ -4220,13 +4230,13 @@ static void task_numa_work(struct callback_head *work)
> }
>
> /*
> - * Shared library pages mapped by multiple processes are not
> - * 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.
> + * Read-only file-backed folios are poor NUMA placement
> + * candidates, but slow-tier folios still need to be scanned for
> + * promotion.
> */
> if (!vma->vm_mm ||
> - (vma->vm_file && (vma->vm_flags & (VM_READ|VM_WRITE)) == (VM_READ))) {
> + (vma_is_ro_file(vma) &&
> + !(numab_mode & NUMA_BALANCING_MEMORY_TIERING))) {

I'd vote for >80c here and but it into a singe line.

Or just use a magical helper

const bool tiering = numab_mode & NUMA_BALANCING_MEMORY_TIERING;

or sth like that.

> trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_SHARED_RO);
> continue;
> }
> @@ -4306,7 +4316,8 @@ static void task_numa_work(struct callback_head *work)
> continue;
> }
>
> - promo_only = !(numab_mode & NUMA_BALANCING_NORMAL);
> + promo_only = !(numab_mode & NUMA_BALANCING_NORMAL) ||
> + vma_is_ro_file(vma);

As I said, maybe that flag could be voided.

--
Cheers,

David