From: "Kiryl Shutsemau (Meta)" <[email protected]> __khugepaged_exit() took mmap_lock for writing and dropped it again, to wait for a scan holding it for reading before exit_mmap() destroyed the page tables underneath it.
A scan now holds a reference on mm_users for as long as it runs, so it cannot be in flight here at all: __mmput() runs only once that count has reached zero, and asserts so on entry. The barrier is redundant. Assisted-by: Claude-Code:claude-opus-5 Signed-off-by: Kiryl Shutsemau (Meta) <[email protected]> --- mm/khugepaged.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 1d77d9a8046d..2b3364bdb100 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -434,16 +434,6 @@ void __khugepaged_exit(struct mm_struct *mm) mm_flags_clear(MMF_VM_HUGEPAGE, mm); mm_slot_free(mm_slot_cache, slot); mmdrop(mm); - } else if (slot) { - /* - * This is required to serialize against - * collapse_test_exit() (which is guaranteed to run - * under mmap_lock read mode). Stop here (after we return all - * pagetables will be destroyed) until khugepaged has finished - * working on the pagetables under the mmap_lock. - */ - mmap_write_lock(mm); - mmap_write_unlock(mm); } } -- 2.54.0
