From: Lance Yang <lance.yang@linux.dev>
To: ziy@nvidia.com
Cc: akpm@linux-foundation.org, david@kernel.org, willy@infradead.org,
songliubraving@fb.com, clm@fb.com, dsterba@suse.com,
viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
ljs@kernel.org, baolin.wang@linux.alibaba.com,
Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com,
dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev,
vbabka@kernel.org, rppt@kernel.org, surenb@google.com,
mhocko@suse.com, shuah@kernel.org, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v5 06/14] mm: fs: remove filemap_nr_thps*() functions and their users
Date: Thu, 7 May 2026 20:59:21 +0800 [thread overview]
Message-ID: <20260507125921.6325-1-lance.yang@linux.dev> (raw)
In-Reply-To: <20260429153538.727855-2-ziy@nvidia.com>
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>
parent reply other threads:[~2026-05-07 12:59 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20260429153538.727855-2-ziy@nvidia.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260507125921.6325-1-lance.yang@linux.dev \
--to=lance.yang@linux.dev \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=brauner@kernel.org \
--cc=clm@fb.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=dsterba@suse.com \
--cc=jack@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=npache@redhat.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=shuah@kernel.org \
--cc=songliubraving@fb.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox