Re: [PATCH v5 7/7] mm: use VMA flag helpers in NUMA balancing

From: Lorenzo Stoakes (ARM)

Date: Tue Nov 10 2026 - 10:23:14 EST


On Tue, Nov 10, 2026 at 10:04:46AM -0500, Gregory Price (Meta) wrote:
> Use vma_test() instead of accessing vm_flags directly in the NUMA
> balancing code touched by the preceding fixes. Keep the existing flag
> predicates unchanged.
>
> No functional change intended.
>
> Suggested-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>

What a legend! :P

> Link: https://lore.kernel.org/r/aq1FDhy00epXXtgd@gremlin
> Assisted-by: LLM

This tag is no longer required, in fact I think checkpatch should moan about it
now.

> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>

Of course, LGTM ;)

This clashes with my latest VMA flags series, but the resolutions should be
trivial.

Reviewed-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>

> ---
> kernel/sched/fair.c | 2 +-
> mm/internal.h | 2 +-
> mm/migrate.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 279bf12b74b64..cf3e3657e9533 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4378,7 +4378,7 @@ static void task_numa_work(struct callback_head *work)
> */
> placement_scan = balancing;
> if (placement_scan && vma->vm_file) {
> - if ((vma->vm_flags & (VM_READ | VM_WRITE)) == VM_READ)
> + if (vma_test(vma, VMA_READ_BIT) && !vma_test(vma, VMA_WRITE_BIT))
> placement_scan = false;
> }
>
> diff --git a/mm/internal.h b/mm/internal.h
> index 6e7c247781a16..7fc34d084697e 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -1248,7 +1248,7 @@ size_t splice_folio_into_pipe(struct pipe_inode_info *pipe,
>
> static inline bool vma_is_single_threaded_private(struct vm_area_struct *vma)
> {
> - if (vma->vm_flags & VM_SHARED)
> + if (vma_test(vma, VMA_SHARED_BIT))
> return false;
>
> return atomic_read(&vma->vm_mm->mm_users) == 1;
> diff --git a/mm/migrate.c b/mm/migrate.c
> index 50a0a2e11a353..796d98d1c116c 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -2715,7 +2715,7 @@ int migrate_misplaced_folio_prepare(struct folio *folio,
> * See folio_maybe_mapped_shared() on possible imprecision
> * when we cannot easily detect if a folio is shared.
> */
> - if ((vma->vm_flags & VM_EXEC) && folio_maybe_mapped_shared(folio) &&
> + if (vma_test(vma, VMA_EXEC_BIT) && folio_maybe_mapped_shared(folio) &&
> (!folio_numab_promotable(folio) || !node_is_toptier(node)))
> return -EACCES;
>
> --
> 2.53.0-Meta
>

--
Cheers, Lorenzo