Re: [PATCH v2 10/12] mm/collapse: work out the orders a VMA allows once per VMA
From: Zi Yan
Date: Fri Sep 11 2026 - 12:29:54 EST
On Thu Sep 10, 2026 at 8:02 AM EDT, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
>
> The scan asked collapse_possible_orders() for every PTE table, for an
> answer that is a property of the VMA. Both callers walk a VMA a table at
> a time, so let them work it out once and pass the mask in. It is only
> good while the lock that produced it is held, so madvise_collapse() takes
> it again after every collapse.
>
> The mask is then sampled once per VMA rather than once per table. A thp
> enabled knob written during a walk takes effect one VMA later, and cannot
> widen a collapse: hugepage_vma_revalidate() tests the order again under
> the lock the collapse retakes.
>
> Assisted-by: LLM
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---
> mm/khugepaged.c | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
LGTM.
Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
--
Best Regards,
Yan, Zi