Re: [PATCH v4 08/13] mm/collapse: call collapse_file() from collapse_single_pmd()
From: Zi Yan
Date: Mon Sep 28 2026 - 21:43:59 EST
On Mon Sep 28, 2026 at 6:06 AM EDT, Kiryl Shutsemau wrote:
> From: "Kiryl Shutsemau (Meta)" <kas@xxxxxxxxxx>
>
> 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
So the new version is a little faster by saving a file scan?
> 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
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@xxxxxxxxxx>
> ---
> mm/khugepaged.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
LGTM.
Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
--
Best Regards,
Yan, Zi