Re: [PATCH 01/12] mm/khugepaged: drop redundant mm_struct pin in madvise_collapse()

From: Zi Yan

Date: Fri Sep 04 2026 - 12:50:18 EST


On Fri Sep 4, 2026 at 11:10 AM EDT, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
>
> madvise_collapse() holds an mmgrab() reference across its work. It is
> redundant. Every caller already holds mm_users:
>
> - madvise(2) works on current->mm, which lives as long as the task is in
> the syscall;
> - process_madvise(2) reaches a remote mm through mm_access(), which takes
> an mm_users reference and holds it until the syscall returns;
> - io_uring passes current->mm;
> - DAMON takes one with get_task_mm() and drops it after the call.
>
> Drop the mmgrab()/mmdrop() pair.
>
> Assisted-by: Claude-Code:claude-opus-5
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---
> mm/khugepaged.c | 2 --
> 1 file changed, 2 deletions(-)
>

Makes sense.

Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>


--
Best Regards,
Yan, Zi