Re: [PATCH 7.2 v16 09/13] mm/khugepaged: introduce collapse_allowable_orders helper function

David Hildenbrand (Arm)
2026-04-27T20:25:19Z

On 4/19/26 20:57, Nico Pache wrote:
> Add collapse_allowable_orders() to generalize THP order eligibility. The
> function determines which THP orders are permitted based on collapse
> context (khugepaged vs madv_collapse).
>
> This consolidates collapse configuration logic and provides a clean
> interface for future mTHP collapse support where the orders may be
> different.
>
> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> Signed-off-by: Nico Pache <npache@redhat.com>
> ---

[...]

> cc = kmalloc_obj(*cc);
> diff --git a/mm/vma.c b/mm/vma.c
> index 377321b48734..c0398fb597b3 100644
> --- a/mm/vma.c
> +++ b/mm/vma.c
> @@ -989,7 +989,7 @@ static __must_check struct vm_area_struct *vma_merge_existing_range(
> goto abort;
>
> vma_set_flags_mask(vmg->target, sticky_flags);
> - khugepaged_enter_vma(vmg->target, vmg->vm_flags);
> + khugepaged_enter_vma(vmg->target);
> vmg->state = VMA_MERGE_SUCCESS;
> return vmg->target;
>
> @@ -1110,7 +1110,7 @@ struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg)
> * following VMA if we have VMAs on both sides.
> */
> if (vmg->target && !vma_expand(vmg)) {
> - khugepaged_enter_vma(vmg->target, vmg->vm_flags);
> + khugepaged_enter_vma(vmg->target);
> vmg->state = VMA_MERGE_SUCCESS;
> return vmg->target;
> }
> @@ -2589,7 +2589,7 @@ static int __mmap_new_vma(struct mmap_state *map, struct vm_area_struct **vmap,
> * call covers the non-merge case.
> */
> if (!vma_is_anonymous(vma))
> - khugepaged_enter_vma(vma, map->vm_flags);
> + khugepaged_enter_vma(vma);
> *vmap = vma;

Are you sure that in all cases, vma->vm_flags already corresponds to
vmg->vm_flags / map->vm_flags?

That's a change that makes this patch unnecessary hard to follow, in particular,
because it's not documented in the patch description.

If you think the change is fine, you should better move that into a separate
cleanup patch where you only drop the flags parameter from khugepaged_enter_vma().

--
Cheers,

David