From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Wenjie Qi <qwjhust@gmail.com>
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com
Subject: Re: [PATCH] f2fs: skip direct I/O iostat work when disabled
Date: Wed, 10 Jun 2026 00:33:01 +0000 [thread overview]
Message-ID: <aiiwvYnHRDE1FcMk@google.com> (raw)
In-Reply-To: <20260527054507.1900373-1-qiwenjie@xiaomi.com>
On 05/27, Wenjie Qi wrote:
> F2FS iostat is optional and is disabled by default, but the direct
> I/O submit path still allocates and binds a bio_iostat_ctx, updates
> the submit timestamp, and replaces bi_end_io for every DIO bio even
> when sbi->iostat_enable is false.
>
> The end_io path also calls f2fs_update_iostat(), which returns
> immediately when iostat is disabled. This adds avoidable per-bio
> overhead to the default direct I/O hot path.
>
> Skip DIO iostat context setup and the direct read/write byte updates
> when iostat is disabled. If iostat is enabled through sysfs before
> submission, the existing context allocation and latency accounting path
> is still used.
>
> QEMU benchmark on a 1GiB F2FS virtio-blk image, with iostat_enable=0,
> 4KiB O_DIRECT I/O over a 64MiB file, 50000 iterations per run:
>
> baseline patched
> direct_read median 65264.50 ns 55470.95 ns
> direct_read recheck 65553.75 ns 55470.95 ns
> direct_write median 68054.62 ns 56309.44 ns
> direct_write recheck 66873.51 ns 56309.44 ns
>
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> fs/f2fs/file.c | 9 +++++++--
> fs/f2fs/iostat.h | 6 ++++++
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 6edf0105dbc8..3ad8bd660b33 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4799,6 +4799,9 @@ static void f2fs_dio_iostat_start(struct f2fs_sb_info *sbi, struct bio *bio)
> {
> void *bi_private = bio->bi_private;
>
> + if (!f2fs_iostat_enabled(sbi))
> + return;
> +
> iostat_alloc_and_bind_ctx(sbi, bio, bi_private);
> iostat_update_submit_ctx(bio, DATA);
> bio->bi_end_io = f2fs_dio_end_bio;
> @@ -4816,7 +4819,8 @@ static int f2fs_dio_read_end_io(struct kiocb *iocb, ssize_t size, int error,
> dec_page_count(sbi, F2FS_DIO_READ);
> if (error)
> return error;
> - f2fs_update_iostat(sbi, NULL, APP_DIRECT_READ_IO, size);
> + if (f2fs_iostat_enabled(sbi))
> + f2fs_update_iostat(sbi, NULL, APP_DIRECT_READ_IO, size);
f2fs_update_iostat() checks sbi->iostat_enable?
> return 0;
> }
>
> @@ -5097,7 +5101,8 @@ static int f2fs_dio_write_end_io(struct kiocb *iocb, ssize_t size, int error,
> if (error)
> return error;
> f2fs_update_time(sbi, REQ_TIME);
> - f2fs_update_iostat(sbi, NULL, APP_DIRECT_IO, size);
> + if (f2fs_iostat_enabled(sbi))
> + f2fs_update_iostat(sbi, NULL, APP_DIRECT_IO, size);
> return 0;
> }
>
> diff --git a/fs/f2fs/iostat.h b/fs/f2fs/iostat.h
> index 2025225b5bed..d3ef787575be 100644
> --- a/fs/f2fs/iostat.h
> +++ b/fs/f2fs/iostat.h
> @@ -44,6 +44,11 @@ struct bio_iostat_ctx {
> struct bio_post_read_ctx *post_read_ctx;
> };
>
> +static inline bool f2fs_iostat_enabled(struct f2fs_sb_info *sbi)
> +{
> + return sbi->iostat_enable;
> +}
> +
> static inline void iostat_update_submit_ctx(struct bio *bio,
> enum page_type type)
> {
> @@ -72,6 +77,7 @@ static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *in
> enum iostat_type type, unsigned long long io_bytes) {}
> static inline void f2fs_update_read_folio_count(struct f2fs_sb_info *sbi,
> struct folio *folio) {}
> +static inline bool f2fs_iostat_enabled(struct f2fs_sb_info *sbi) { return false; }
> static inline void iostat_update_and_unbind_ctx(struct bio *bio) {}
> static inline void iostat_alloc_and_bind_ctx(struct f2fs_sb_info *sbi,
> struct bio *bio, struct bio_post_read_ctx *ctx) {}
> --
> 2.43.0
>
prev parent reply other threads:[~2026-06-10 0:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 5:45 [PATCH] f2fs: skip direct I/O iostat work when disabled Wenjie Qi
2026-06-10 0:33 ` Jaegeuk Kim [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=aiiwvYnHRDE1FcMk@google.com \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=qiwenjie@xiaomi.com \
--cc=qwjhust@gmail.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