From: Usama Arif <usama.arif@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
willy@infradead.org, jack@suse.cz, david@kernel.org,
axboe@kernel.dk, Christoph Hellwig <hch@lst.de>,
hannes@cmpxchg.org, jlayton@kernel.org, brauner@kernel.org,
tz2294@columbia.edu, ritesh.list@gmail.com,
chentaotao@didiglobal.com, ziy@nvidia.com, bigeasy@linutronix.de,
liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
mhocko@suse.com, apopple@nvidia.com, byungchul@sk.com,
gourry@gourry.net, joshua.hahnjy@gmail.com,
matthew.brost@intel.com, ying.huang@linux.alibaba.com,
clrkwllms@kernel.org, rostedt@goodmis.org, linux-mm@kvack.org,
linux-fsdevel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
kas@kernel.org, riel@surriel.com, shakeel.butt@linux.dev,
kernel-team@meta.com
Cc: Usama Arif <usama.arif@linux.dev>
Subject: [PATCH 0/4] mm: drop folios under writeback on POSIX_FADV_DONTNEED
Date: Wed, 2 Dec 2026 06:24:35 -0800 [thread overview]
Message-ID: <20261202142513.2951661-1-usama.arif@linux.dev> (raw)
POSIX_FADV_DONTNEED starts writeback on the dirty folios in the range
without waiting for it, then invalidates what it can and skips folios
under writeback. With small folios most bios complete while DONTNEED is
still invalidating. With large folios on XFS a single bio can carry
hundreds of megabytes, none of which leaves writeback until all of it
completes, so DONTNEED right after writing a new 256 MiB file leaves all
of it cached.
This is affecting production workloads after a kernel upgrade that
started using large folios on XFS: an application that writes files
through a shared mapping, unmaps them and calls DONTNEED without syncing
now fills its memory limit with page cache that DONTNEED used to drop.
Patch 4 marks the unmapped dirty folios in the range dropbehind before
starting writeback, and the unmapped folios still under writeback after
it, so that writeback completion drops them as it does for RWF_DONTCACHE
writes. Only regular files on filesystems that support RWF_DONTCACHE are
marked, and not the folio extending past EOF, which an appender calling
DONTNEED after each write would have to read back.
Patches 1-3 fix dropbehind bugs that patch 4 makes easier to hit:
1. Migration does not copy PG_dropbehind, so WB_DONTCACHE_DIRTY leaks.
2. Lookups clear PG_dropbehind without the folio lock, racing with
dirtying and cleaning, so WB_DONTCACHE_DIRTY drifts.
3. folio_end_dropbehind() can invalidate with interrupts disabled in a
forced-threaded handler, as ext4 RWF_DONTCACHE overwrites did with
threadirqs from v6.17 until commit 7d7c9c83c822.
Patches 1-3 are stable candidates.
With the series, new files and overwrites on XFS and ext4 were dropped within
a second of DONTNEED apart from the folio at EOF; without the series
most of them stayed cached.
Alternatives considered:
- fdatasync() before DONTNEED works, but blocks the caller and needs
every application changed.
- Restoring the PG_reclaim that DONTNEED set on these folios until
commit 5c211ba29deb ("mm: add and use find_lock_entries") only moves
them to the tail of the inactive list, still cached and charged.
- Calling bio_complete_in_task() for every bio with a dropbehind folio
would also catch folios marked after submission, but needs a pass
over every write bio's folios before completing it.
Limitations:
- Folios already under writeback that complete in interrupt context
stay cached.
base-commit: 872ceec1e3caf227655a58f7407a9c8493dcf56f
Usama Arif (4):
mm/migrate: preserve PG_dropbehind across folio migration
mm/filemap: clear PG_dropbehind on lookup under the folio lock
mm/filemap: don't drop dropbehind folios with interrupts disabled
mm/fadvise: drop folios under writeback on POSIX_FADV_DONTNEED
mm/fadvise.c | 60 +++++++++++++++++++++++++++++++++++++++++----
mm/filemap.c | 30 +++++++++++++++++------
mm/internal.h | 1 +
mm/migrate.c | 3 +++
mm/page-writeback.c | 23 +++++++++++++++++
5 files changed, 104 insertions(+), 13 deletions(-)
--
2.53.1-Meta
next reply other threads:[~2026-12-02 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 14:24 Usama Arif [this message]
2026-12-02 14:24 ` [PATCH 1/4] mm/migrate: preserve PG_dropbehind across folio migration Usama Arif
2026-12-02 14:41 ` Jan Kara
2026-12-02 14:56 ` Jeff Layton
2026-12-02 15:03 ` Zi Yan
2026-12-02 15:08 ` David Hildenbrand (Arm)
2026-12-02 15:18 ` Usama Arif
2026-12-02 14:24 ` [PATCH 2/4] mm/filemap: clear PG_dropbehind on lookup under the folio lock Usama Arif
2026-12-02 14:42 ` Jan Kara
2026-12-02 15:04 ` Jeff Layton
2026-12-02 14:24 ` [PATCH 3/4] mm/filemap: don't drop dropbehind folios with interrupts disabled Usama Arif
2026-12-02 14:51 ` Jan Kara
2026-12-02 15:04 ` Jeff Layton
2026-12-02 14:24 ` [PATCH 4/4] mm/fadvise: drop folios under writeback on POSIX_FADV_DONTNEED Usama Arif
2026-12-02 15:18 ` Jeff Layton
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=20261202142513.2951661-1-usama.arif@linux.dev \
--to=usama.arif@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=axboe@kernel.dk \
--cc=bigeasy@linutronix.de \
--cc=brauner@kernel.org \
--cc=byungchul@sk.com \
--cc=chentaotao@didiglobal.com \
--cc=clrkwllms@kernel.org \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=joshua.hahnjy@gmail.com \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=matthew.brost@intel.com \
--cc=mhocko@suse.com \
--cc=riel@surriel.com \
--cc=ritesh.list@gmail.com \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=tz2294@columbia.edu \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=ying.huang@linux.alibaba.com \
--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