Re: [PATCH v4 13/13] mm/collapse: implement MADV_COLLAPSE in madvise.c

From: Zi Yan

Date: Mon Sep 28 2026 - 22:03:46 EST


On Mon Sep 28, 2026 at 6:06 AM EDT, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
>
> MADV_COLLAPSE is a madvise operation, but its implementation sat in
> khugepaged.c. The daemon's file therefore also held a syscall's worth of
> code that has nothing to do with the daemon: the walk over the user's
> range, the per-PMD loop, and the errno translation.
>
> Move it to madvise.c, among the operations it belongs with, along with the
> errno map and the policy it states for itself. It takes a struct
> madvise_behavior like every one of those operations, which is where the
> range, the VMA and the lock-dropped flag it used to be handed separately
> already live.
>
> It stays a caller of the interface khugepaged uses, so nothing about the
> collapse changes.
>
> The !CONFIG_TRANSPARENT_HUGEPAGE stub moves in with it.
>
> Assisted-by: LLM
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---
> include/linux/huge_mm.h | 9 ---
> mm/khugepaged.c | 159 +------------------------------------
> mm/madvise.c | 170 +++++++++++++++++++++++++++++++++++++++-
> 3 files changed, 170 insertions(+), 168 deletions(-)
>

LGTM.

Acked-by: Zi Yan <ziy@xxxxxxxxxx>


--
Best Regards,
Yan, Zi