* Re: [PATCH v5 06/14] mm: fs: remove filemap_nr_thps*() functions and their users
[not found] <20260429153538.727855-2-ziy@nvidia.com>
@ 2026-05-07 12:59 ` Lance Yang
0 siblings, 0 replies; only message in thread
From: Lance Yang @ 2026-05-07 12:59 UTC (permalink / raw)
To: ziy
Cc: akpm, david, willy, songliubraving, clm, dsterba, viro, brauner,
jack, ljs, baolin.wang, Liam.Howlett, npache, ryan.roberts,
dev.jain, baohua, lance.yang, vbabka, rppt, surenb, mhocko, shuah,
linux-btrfs, linux-kernel, linux-fsdevel, linux-mm,
linux-kselftest
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 <ziy@nvidia.com>
>Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
>Acked-by: David Hildenbrand (Arm) <david@kernel.org>
>Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
>---
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 <lance.yang@linux.dev>
^ permalink raw reply [flat|nested] only message in thread