Re: [PATCH v3 4/7] sched/numa: separate VMA placement from scan continuation

From: David Hildenbrand (Arm)

Date: Fri Sep 25 2026 - 06:57:35 EST



> /*
> - * Do not scan the VMA if task has not accessed it, unless no other
> - * VMA candidate exists.
> + * Do not scan the VMA if a task has not accessed it, unless no other
> + * VMA candidate exists. If a scan is already in-progress, finish it,
> + * but track continuation separately from starting a new one.
> */
> - if (!vma_pids_forced && !vma_is_accessed(mm, vma)) {
> - vma_pids_skipped = true;
> - trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_PID_INACTIVE);
> - continue;
> + placement_due = vma_needs_placement_scan(mm, vma);
> + scan_started = mm->numa_scan_offset > vma->vm_start;
> + pid_scan_allowed = vma_pids_forced || placement_due;
> +
> + if (!pid_scan_allowed) {
> + if (scan_started) {
> + trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_IGNORE_PID);
> + } else {
> + vma_pids_skipped = true;
> + trace_sched_skip_vma_numa(mm, vma, NUMAB_SKIP_PID_INACTIVE);
> + continue;
> + }
> }
>
> + /* Keep scan policy stable while processing a VMA in chunks.*/
> placement_scan &= numab_mode & NUMA_BALANCING_NORMAL;
> + if (scan_started)
> + placement_scan &= vma->numab_state->placement_scan;

Besides avoiding the "&=" in all cases to make the code readable, nothing caught
my attention.

It's all very complicated, so I won't pretend I fully digested the logic :)

--
Cheers,

David