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

From: Pedro Falcato

Date: Wed Jul 01 2026 - 08:05:07 EST


On Wed, Jul 01, 2026 at 12:54:52PM +0100, Matthew Wilcox wrote:
> 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().

ACK to both of your suggestions, I'll send a proper version (once I figure
out the proper way to send a stable fix that does not hit mainline).

--
Pedro