Re: [PATCH v5 8/9] mm/collapse: call collapse_file() from collapse_single_pmd()

From: Lance Yang

Date: Thu Oct 15 2026 - 01:42:16 EST



On Wed, Oct 14, 2026 at 06:11:41PM +0100, Kiryl Shutsemau (Meta) wrote:
>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.
>
>Assisted-by: LLM
>Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
>Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
>Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
>---

Reviewed-by: Lance Yang <lance.yang@xxxxxxxxx>