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

From: David Hildenbrand (Arm)

Date: Thu Oct 01 2026 - 06:45:12 EST


On 9/30/26 13:22, Gregory Price wrote:
> From: "Gregory Price (Meta)" <gourry@xxxxxxxxxx>
>
> vma_is_accessed() returns true both when a VMA needs placement
> (east-west) sampling and when a VMA is already mid-scan across
> multiple scan windows.
>
> Callers cannot distinguish placement eligibility from scan progress.
>
> Rename the helper to vma_needs_placement_scan() and handle continuation
> state in task_numa_work(). Record whether an in-progress VMA scan is
> promotion-only so a scan resumed in a later scan window finishes with
> the policy it started with. The zeroed initial state places no
> restriction, so a resumed scan that finds freshly allocated NUMAB state
> falls back to the default policy.
>
> This separation allows PID-inactive VMAs to be scanned for promotion
> without treating scan continuation as evidence of placement eligibility.
> It is a prerequisite for the following fix and must accompany it when
> backported.
>
> Fixes: fc137c0ddab2 ("sched/numa: enhance vma scanning logic")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
> ---
> include/linux/mm_types.h | 6 ++++++
> kernel/sched/fair.c | 40 ++++++++++++++++++++++++----------------
> 2 files changed, 30 insertions(+), 16 deletions(-)
>
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 1bd3ca7bfff2..d0ac21d02c47 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -803,6 +803,12 @@ struct vma_numab_state {
> * A VMA is not eligible for scanning if prev_scan_seq == numa_scan_seq
> */
> int prev_scan_seq;
> +
> + /*
> + * The in-progress scan of this VMA is promotion-only.
> + * Resumed scans finish with the policy they started with.
> + */
> + bool promo_only;
> };
>
> #ifdef __HAVE_PFNMAP_TRACKING
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index ab9afd3ad49b..3b30786ded3b 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4082,7 +4082,8 @@ static void reset_ptenuma_scan(struct task_struct *p)
> p->mm->numa_scan_offset = 0;
> }
>
> -static bool vma_is_accessed(struct mm_struct *mm, struct vm_area_struct *vma)
> +static bool vma_needs_placement_scan(struct mm_struct *mm,
> + struct vm_area_struct *vma)

mm can be had from vma->vm_mm, so likely sufficient to only pass the vma?

Apart from that this looks much clearer to me

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David