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

From: Baolin Wang

Date: Mon Sep 07 2026 - 03:37:51 EST




On 9/4/26 11:10 PM, 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>
---

LGTM.
Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>