Re: [PATCH v3 10/12] mm/collapse: work out the orders a VMA allows once per VMA
From: Kiryl Shutsemau
Date: Thu Sep 24 2026 - 11:11:38 EST
On Wed, Sep 23, 2026 at 03:19:36PM +0200, David Hildenbrand (Arm) wrote:
[...]
>
> > + /* One mask for the whole VMA */
> > + orders = collapse_possible_orders(vma, vma->vm_flags,
> > + cc->policy.tva_type);
>
> cc->policy.tva_type is always sattic here, no?
Yes, TVA_KHUGEPAGED.
> > @@ -3252,9 +3254,11 @@ int madvise_collapse(struct vm_area_struct *vma, unsigned long start,
> > }
> > vma = found;
> > hend = min(hend, vma->vm_end & HPAGE_PMD_MASK);
> > + orders = collapse_possible_orders(vma, vma->vm_flags,
> > + cc->policy.tva_type);
>
>
> That's always TVA_FORCED_COLLAPSE, no?
Yep.
> It's a shame we cannot get rid of cc->policy.tva_type because we need it for
> hugepage_vma_revalidate to calculate orders. Which sucks a bit.
It stays for the engine, not the callers.
The fixup I will fold in v4 is below.
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 2a10a30055c6..8fad934befe2 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2905,7 +2905,7 @@ static void collapse_scan_mm_slot(unsigned int progress_max,
}
/* One mask for the whole VMA */
orders = collapse_possible_orders(vma, vma->vm_flags,
- cc->policy.tva_type);
+ TVA_KHUGEPAGED);
if (!orders) {
cc->progress++;
continue;
diff --git a/mm/madvise.c b/mm/madvise.c
index 33bcd390ce43..3087640ddaad 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1010,7 +1010,7 @@ static int madvise_collapse(struct madvise_behavior *madv_behavior)
vma = found;
hend = min(hend, vma->vm_end & HPAGE_PMD_MASK);
orders = collapse_possible_orders(vma, vma->vm_flags,
- cc->policy.tva_type);
+ TVA_FORCED_COLLAPSE);
}
result = collapse_scan_pmd(vma, addr, cc, orders);
--
Kiryl Shutsemau / Kirill A. Shutemov