From: Brian Foster <bfoster@redhat.com>
To: Tal Zussman <tz2294@columbia.edu>
Cc: fstests@vger.kernel.org, Zorro Lang <zlang@kernel.org>,
Christoph Hellwig <hch@lst.de>,
linux-ext4@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
"Darrick J. Wong" <djwong@kernel.org>, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH v2 3/3] generic/810: check that RWF_DONTCACHE I/O drops its folios
Date: Mon, 9 Nov 2026 09:10:23 -0500 [thread overview]
Message-ID: <avHUTwnSMVCkKVoW@bfoster> (raw)
In-Reply-To: <20261107-dontcache-test-v2-3-7655bf08d6d1@columbia.edu>
On Sat, Nov 07, 2026 at 09:19:41PM -0500, Tal Zussman wrote:
> A dontcache write drops its folios from the page cache once writeback
> completes, and a dontcache read drops them once the read completes.
>
> Test this by writing and reading a 1M file with and without
> RWF_DONTCACHE and checking with mincore how much of it is cached
> afterwards: all of it for plain I/O, none of it for dontcache I/O.
>
> The overwrite is a separate case because the drop is skipped when
> writeback completes in interrupt context, which is what happens on ext4
> without commit "ext4: complete dropbehind writeback in task context"
> [1].
>
> Link: https://lore.kernel.org/linux-ext4/20261012-ext4-dontcache-complete-in-task-v1-1-6ac801557041@columbia.edu/ [1]
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
I like it. Thanks for the tweaks!
Reviewed-by: Brian Foster <bfoster@redhat.com>
> tests/generic/810 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/generic/810.out | 11 ++++++++
> 2 files changed, 88 insertions(+)
>
> diff --git a/tests/generic/810 b/tests/generic/810
> new file mode 100755
> index 00000000..1866848f
> --- /dev/null
> +++ b/tests/generic/810
> @@ -0,0 +1,77 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Tal Zussman. All Rights Reserved.
> +#
> +# FS QA Test No. 810
> +#
> +# Check that RWF_DONTCACHE I/O drops its folios from the page cache: a
> +# dontcache write once its writeback completes, and a dontcache read once the
> +# read completes. Plain buffered I/O on the same file has to leave them cached.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw
> +
> +_require_scratch
> +_require_xfs_io_command "pwrite" "-U"
> +_require_xfs_io_command "pread" "-U"
> +_require_xfs_io_command "mincore"
> +_exclude_scratch_mount_option "dax"
> +
> +_scratch_mkfs > $seqres.full 2>&1
> +_scratch_mount
> +
> +size=$((1024 * 1024))
> +file=$SCRATCH_MNT/file
> +pagesize=$(_get_page_size)
> +
> +# Count the bytes of the file that are in the page cache.
> +cached_bytes()
> +{
> + local pages
> +
> + pages=$($XFS_IO_PROG -c "mmap -r 0 $size" -c "mincore" $file | \
> + awk '{ n += $4 } END { print n + 0 }')
> + echo $((pages * pagesize))
> +}
> +
> +# Report how many bytes are cached, after waiting up to $1 seconds for the
> +# cache to empty. Dontcache writeback can drop folios just after fsync returns.
> +report_cached()
> +{
> + local delay=${1:-0}
> + local i
> +
> + for ((i = 0; i < delay * 10; i++)); do
> + [ "$(cached_bytes)" -eq 0 ] && break
> + sleep 0.1
> + done
> + echo "$(cached_bytes) of $size bytes cached"
> +}
> +
> +echo "plain write"
> +$XFS_IO_PROG -f -c "pwrite -q 0 $size" -c fsync $file
> +report_cached 1
> +
> +echo "dontcache write to a new file"
> +rm -f $file
> +$XFS_IO_PROG -f -c "pwrite -q -U -V 1 -b $size 0 $size" -c fsync $file
> +report_cached 5
> +
> +# Start each of the remaining cases from an empty page cache.
> +echo "dontcache overwrite"
> +_scratch_cycle_mount
> +$XFS_IO_PROG -c "pwrite -q -U -V 1 -b $size 0 $size" -c fsync $file
> +report_cached 5
> +
> +echo "dontcache read"
> +_scratch_cycle_mount
> +$XFS_IO_PROG -c "pread -q -U -V 1 -b $size 0 $size" $file
> +report_cached 5
> +
> +echo "plain read"
> +_scratch_cycle_mount
> +$XFS_IO_PROG -c "pread -q 0 $size" $file
> +report_cached 1
> +
> +_scratch_unmount
> +_exit 0
> diff --git a/tests/generic/810.out b/tests/generic/810.out
> new file mode 100644
> index 00000000..cb6c3f2a
> --- /dev/null
> +++ b/tests/generic/810.out
> @@ -0,0 +1,11 @@
> +QA output created by 810
> +plain write
> +1048576 of 1048576 bytes cached
> +dontcache write to a new file
> +0 of 1048576 bytes cached
> +dontcache overwrite
> +0 of 1048576 bytes cached
> +dontcache read
> +0 of 1048576 bytes cached
> +plain read
> +1048576 of 1048576 bytes cached
>
> --
> 2.39.5
>
>
next prev parent reply other threads:[~2026-11-09 14:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 2:19 [PATCH v2 0/3] fstests: test that RWF_DONTCACHE I/O drops its folios Tal Zussman
2026-11-08 2:19 ` [PATCH v2 1/3] common/rc: probe pread options with a real read Tal Zussman
2026-11-08 2:19 ` [PATCH v2 2/3] common/rc: pass -V 1 when probing pwrite and pread -U Tal Zussman
2026-11-11 16:47 ` Christoph Hellwig
2026-11-08 2:19 ` [PATCH v2 3/3] generic/810: check that RWF_DONTCACHE I/O drops its folios Tal Zussman
2026-11-09 14:10 ` Brian Foster [this message]
2026-11-09 18:37 ` Tal Zussman
2026-11-11 16:47 ` Christoph Hellwig
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=avHUTwnSMVCkKVoW@bfoster \
--to=bfoster@redhat.com \
--cc=axboe@kernel.dk \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tz2294@columbia.edu \
--cc=zlang@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.