Re: Subject: [BUG/RFC] write-open file THP cache purge can discard dirty page cache
From: Matthew Wilcox
Date: Tue Jun 30 2026 - 14:37:39 EST
On Tue, Jun 30, 2026 at 01:01:53PM -0400, Gregg Leventhal wrote:
> On an affected 6.12 kernel with CONFIG_READ_ONLY_THP_FOR_FS=y, a file can
> contain read-only file THPs installed by khugepaged / MADV_COLLAPSE. When that
> same file is later opened for write, do_dentry_open() notices
> filemap_nr_thps() and drops the page cache:
[...]
>
> This is unsafe if the mapping also contains dirty folios.
But there shouldn't be any. It should not be possible to have
dirty folios and THPs in the same file unless the filesystem
supports large folios natively.
If the file is open for writing, the attempt to create THPs should fail.