Re: Subject: [BUG/RFC] write-open file THP cache purge can discard dirty page cache

From: Matthew Wilcox

Date: Wed Jul 01 2026 - 07:56:10 EST


On Tue, Jun 30, 2026 at 08:55:12PM +0100, Pedro Falcato wrote:
> @@ -2043,6 +2044,17 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
> */
> try_to_unmap_flush();
>
> + /*
> + * If collapse looks to be successful, flush any dirty pages
> + * out the page cache. With the nr_thps incremented, there won't be
> + * any new writers (nor new dirties).
> + */
> + if (result == SCAN_SUCCEED && !is_shmem) {
> + err = filemap_write_and_wait(mapping);
> + if (err)
> + result = SCAN_WRITEBACK_FAIL;
> + }

Oh, the other thing is that this should be conditioned on
!mapping_large_folio_support().