mm-khugepaged-require-collapse_huge_page-to-enter-exit-with-the-lock-dropped.patch removed from -mm tree
The quilt patch titled
Subject: mm/khugepaged: require collapse_huge_page to enter/exit with the lock dropped
has been removed from the -mm tree. Its filename was
mm-khugepaged-require-collapse_huge_page-to-enter-exit-with-the-lock-dropped.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Nico Pache <[email protected]>
Subject: mm/khugepaged: require collapse_huge_page to enter/exit with the lock dropped
Date: Fri, 5 Jun 2026 10:14:12 -0600
Currently the collapse_huge_page function requires the mmap_read_lock to enter with it held, and exit with it dropped. This function moves the unlock into its parent caller, and changes this semantic to requiring it to enter/exit with it always unlocked.
In future patches, we need this expectation, as for in mTHP collapse, we may have already dropped the lock, and do not want to conditionally check for this by passing through the lock_dropped variable.
No functional change is expected as one of the first things the collapse_huge_page function does is drop this lock before allocating the hugepage.
---
mm/khugepaged.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~mm-khugepaged-require-collapse_huge_page-to-enter-exit-with-the-lock-dropped +8 -8
@@ -1222,6 +1222,12 @@ static enum scan_result alloc_charge_folreturn SCAN_SUCCEED ; } +/* +* collapse_huge_page expects the mmap_lock to be unlocked before entering and +* will always return with the lock unlocked, to avoid holding the mmap_lock +* while allocating a THP, as that could trigger direct reclaim/compaction. +* Note that the VMA must be rechecked after grabbing the mmap_lock again. +*/ static enum scan_result collapse_huge_page (struct mm_struct *mm,unsigned long address,int referenced,int unmapped,struct collapse_control *cc) {
@@ -1237,14 +1243,6 @@ static enum scan_result collapse_huge_paVM_BUG_ON (address & ~HPAGE_PMD_MASK ); -/* -* Before allocating the hugepage, release the mmap_lock read lock. -* The allocation can take potentially a long time if it involves -* sync compaction, and we do not need to hold the mmap_lock during -* that. We will recheck the vma after taking it again in write mode. -*/ -mmap_read_unlock (mm); - result =alloc_charge_folio (&folio, mm, cc,HPAGE_PMD_ORDER );if (result !=SCAN_SUCCEED ) goto out_nolock;
@@ -1554,6 +1552,8 @@ static enum scan_result collapse_scan_pm out_unmap:pte_unmap_unlock (pte, ptl);if (result ==SCAN_SUCCEED ) { +/* collapse_huge_page expects the lock to be dropped before calling */ +mmap_read_unlock (mm); result =collapse_huge_page (mm, start_addr, referenced, unmapped, cc);/* collapse_huge_page will return with the mmap_lock released */
_
Patches currently in -mm which might be from [email protected] are