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

From: Gregory Price

Date: Fri Sep 18 2026 - 10:16:31 EST


On Fri, Sep 18, 2026 at 02:58:36PM +0200, David Hildenbrand (Arm) wrote:
> > +/*
> > + * 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.
>

No argument here. Would like to balance improvement vs backportable
bugfix though. I broke out the name to try to make it at least a bit
more readable.

> > 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.
>

ack

> > 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.
>

ack.