Linux NFS development
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Matthew Wilcox <willy@infradead.org>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>,
	linux-nfs@vger.kernel.org, NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	Jens Axboe <axboe@kernel.dk>, Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH v10 0/7] mm, iomap, NFSD: stop uncached writes reading back shared pages
Date: Tue, 10 Nov 2026 19:26:04 -0500	[thread overview]
Message-ID: <avO2HG8_m4v-NYYM@kernel.org> (raw)
In-Reply-To: <20261104091740.GB31130@lst.de>

[against my better judgement I'm replying, hoping technical discussion
wins out.. usually does]

On Wed, Nov 04, 2026 at 10:17:40AM +0100, Christoph Hellwig wrote:
> On Tue, Nov 03, 2026 at 04:17:47PM -0500, Mike Snitzer wrote:
> > Hi,
> > 
> > An uncached (RWF_DONTCACHE) buffered write drops each folio it writes
> > once the folio is written back.  A folio that the write covers only
> > partly is shared with the neighbouring write.  If it is dropped before
> > the neighbour writes its part, the neighbour reads it back from disk
> > first.  32 threads writing interleaved records to one XFS file, 4 KiB
> > pages, before and after 5/7:
> 
> Very colourful terminology here.  Who is "the neighbour".  How do we
> know a "neighbour" exists and what it wants to do?

"the neighbour" was meant to convey the other write that covers the
rest of a page that another write covers only partly.  For example,
with 4 KiB pages, a write of bytes 0 to 5999 covers bytes 4096 to 5999
of the second page.  A write that starts at byte 6000 covers the rest
of that page.

We do not know that such a write will come, and patch 5/7 does not
assume it.  5/7 looks only at the state of the page:

- If the page is not uptodate, it is not fully written.  5/7 does not
  mark it dropbehind.  It stays in the page cache, like a page from a
  normal buffered write, until a write completes it or reclaim drops
  it.
- If the page is uptodate, it already holds the other part, and this
  write completes it.  5/7 marks it dropbehind, and the writeback that
  cleans it drops it.

So if no other write comes, at most the first and last page of each
write stay cached.  If one comes, writeback drops the page after both
writes, and the second write does not read it from disk.

> In general if the user gave a very clear indication that the data
> should not be cached, it is a bit awkward to second [g]uess that.

RWF_DONTCACHE does not keep data out of the page cache.  It is buffered
IO, so all of the data goes through the page cache.  The flag only asks
the kernel to drop the pages after writeback: "buffered IO that drops
the cache after reading or writing data" (include/uapi/linux/fs.h).  It
is also best effort today: an RWF_DONTCACHE write drops only the pages
that it creates, not the pages that it finds in the cache.

5/7 does not change whether the data goes through the page cache.  It
changes only when the kernel drops a partially written page.  Today the
kernel drops the page before another write might get to it.  That write
must then read the page back from disk into the page cache, to merge its
own bytes.  So the page cache does not hold less: it holds the same page
twice, with a disk read between.  In the cover letter test, that is 0.97
device reads per write, and 831 MiB/s instead of 2281 MiB/s.  The user
asked for less page cache use, not for a read-modify-write of each
misaligned write.

> Especially if the expectations are not very clearly documented.

The 5/7 commit message states it: "An edge whose neighbour never writes,
such as the last page of a file, stays cached until reclaim."  So the
only change to what the user sees is: an RWF_DONTCACHE write can leave
the first and last page of the write in the page cache, if no other
write completes them.  Writeback drops all other pages of the write,
as before.

Mike

ps. I'll reduce the "colourful terminology" in v11 (e.g. drop
"neighbour" jargon) and also address the 2 issues sashiko raised
against v10's 6/7.

      reply	other threads:[~2026-11-11  0:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 21:17 [PATCH v10 0/7] mm, iomap, NFSD: stop uncached writes reading back shared pages Mike Snitzer
2026-11-03 21:17 ` [PATCH v10 1/7] mm: move clearing the uncached flag of a found folio into a helper Mike Snitzer
2026-11-04  9:17   ` Christoph Hellwig
2026-11-03 21:17 ` [PATCH v10 2/7] mm: take a folio off WB_DONTCACHE_DIRTY only if it was counted there Mike Snitzer
2026-11-03 21:17 ` [PATCH v10 3/7] mm: expose WB_DONTCACHE_DIRTY in bdi debugfs stats Mike Snitzer
2026-11-03 21:17 ` [PATCH v10 4/7] mm: add folio_mark_dropbehind() to mark a folio dropbehind and account it Mike Snitzer
2026-11-03 21:17 ` [PATCH v10 5/7] mm, iomap: keep a partly covered page until an uncached write completes it Mike Snitzer
2026-11-03 21:17 ` [PATCH v10 6/7] mm, iomap: let an uncached writer complete its shared pages itself Mike Snitzer
2026-11-03 21:17 ` [PATCH v10 7/7] NFSD: drop a shared boundary page only once both WRITEs have written it Mike Snitzer
2026-11-04  9:15   ` Christoph Hellwig
2026-11-04 17:01     ` Mike Snitzer
2026-11-05  7:59       ` Christoph Hellwig
2026-11-05 13:33         ` Chuck Lever
2026-11-05 22:49           ` Mike Snitzer
2026-11-10 17:23             ` MM/iomap review of this v10 patchset is needed please [was: Re: [PATCH v10 7/7] NFSD: drop a shared boundary page only once both WRITEs have written it] Mike Snitzer
2026-11-04  9:17 ` [PATCH v10 0/7] mm, iomap, NFSD: stop uncached writes reading back shared pages Christoph Hellwig
2026-11-11  0:26   ` Mike Snitzer [this message]

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=avO2HG8_m4v-NYYM@kernel.org \
    --to=snitzer@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=cel@kernel.org \
    --cc=corbet@lwn.net \
    --cc=hch@lst.de \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    --cc=willy@infradead.org \
    /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