On Wed, Apr 29, 2026 at 11:35:29AM -0400, Zi Yan wrote: >They are used by READ_ONLY_THP_FOR_FS to handle writes to FSes without >large folio support, so that read-only THPs created in these FSes are not >seen by the FSes when the underlying fd becomes writable. Now read-only PMD >THPs only appear in a FS with large folio support and the supported orders >include PMD_ORDER. > >READ_ONLY_THP_FOR_FS was using mapping->nr_thps, inode->i_writecount, and >smp_mb() to prevent writes to a read-only THP and collapsing writable >folios into a THP. In collapse_file(), mapping->nr_thps is increased, then >smp_mb(), and if inode->i_writecount > 0, collapse is stopped, while >do_dentry_open() first increases inode->i_writecount, then a full memory >fence, and if mapping->nr_thps > 0, all read-only THPs are truncated. > >Now this mechanism can be removed along with READ_ONLY_THP_FOR_FS code, >since a dirty folio check has been added after try_to_unmap() in >collapse_file() to prevent dirty folios from being collapsed as clean. > >Signed-off-by: Zi Yan <[email protected]> >Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> >Acked-by: David Hildenbrand (Arm) <[email protected]> >Reviewed-by: Baolin Wang <[email protected]> >---
Nice cleanup! The old counter/barrier trick is no longer needed; collapse_file() now checks the thing we actually care about ;) LGTM. Reviewed-by: Lance Yang <[email protected]>

