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

From: David Hildenbrand (Arm)

Date: Wed Sep 23 2026 - 07:53:12 EST


On 9/16/26 11:31, 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: LLM
> Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
> Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David