mm-collapse-call-collapse_file-from-collapse_single_pmd.patch removed from -mm tree
The quilt patch titled
Subject: mm/collapse: call collapse_file() from collapse_single_pmd()
has been removed from the -mm tree. Its filename was
mm-collapse-call-collapse_file-from-collapse_single_pmd.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: "Kiryl Shutsemau (Meta)" <[email protected]>
Subject: mm/collapse: call collapse_file() from collapse_single_pmd()
Date: Wed, 14 Oct 2026 18:11:41 +0100
collapse_scan_file() reads the page cache to decide whether a table is worth collapsing and, when it is, calls collapse_file() itself. The caller cannot get between the decision and the collapse.
Move the collapse_file() call up into collapse_single_pmd(), so the scan stops at the decision.
Two things change with it. The writeback retry re-runs collapse_file() alone instead of rescanning first; collapse_file() repeats the scan's checks under the page cache lock anyway. And mm_khugepaged_scan_file fires before the collapse, so for an accepted table its status reads SCAN_SUCCEED; what the collapse made of the table is for mm_khugepaged_collapse_file to report.
Preparation for splitting a collapse into a scan under mmap_lock and a run without it. The file scan has to stop where the anonymous one will.
---
mm/khugepaged.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
mm/khugepaged.c renamed from mm/khugepaged.c~mm-collapse-call-collapse_file-from-collapse_single_pmd +13 -8
@@ -2763,13 +2763,9 @@ static enum scan_result collapse_scan_fielse cc->progress +=HPAGE_PMD_NR ; -if (result ==SCAN_SUCCEED ) { -if (present <HPAGE_PMD_NR - max_ptes_none) { - result =SCAN_EXCEED_NONE_PTE ; -count_vm_event (THP_SCAN_EXCEED_NONE_PTE ); - }else { - result =collapse_file (mm, addr, file, start, cc); - } +if (result ==SCAN_SUCCEED && present <HPAGE_PMD_NR - max_ptes_none) { + result =SCAN_EXCEED_NONE_PTE ; +count_vm_event (THP_SCAN_EXCEED_NONE_PTE ); }trace_mm_khugepaged_scan_file (mm, failed_pfn, file, present, swap, result);
@@ -2800,8 +2796,16 @@ static enum scan_result collapse_single_mmap_read_unlock (mm); *lock_dropped = true; -retry: + +/* +* SCAN_PTE_MAPPED_HUGEPAGE is work too: the page cache already holds +* the PMD folio, and only the PTE table is left to retract. +*/ result =collapse_scan_file (mm, addr, file, pgoff, cc); +if (result !=SCAN_SUCCEED ) + goto put; +retry: + result =collapse_file (mm, addr, file, pgoff, cc);/* Dirty pages are worth a writeback and one more try, if asked for */ if (cc->policy.file_writeback_dirty && result == SCAN_PAGE_DIRTY_OR_WRITEBACK &&
@@ -2813,6 +2817,7 @@ retry: triggered_wb = true; goto retry; } +put:fput (file);if (result ==SCAN_PTE_MAPPED_HUGEPAGE ) {
_
Patches currently in -mm which might be from [email protected] are