Re: [PATCH v5 1/9] mm/khugepaged: drop redundant mm_struct pin in madvise_collapse()
From: Lance Yang
Date: Thu Oct 15 2026 - 00:34:21 EST
On Wed, Oct 14, 2026 at 06:11:34PM +0100, Kiryl Shutsemau (Meta) wrote:
>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
>Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
>Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
>Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
>---
Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>