From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BB67C15C for ; Wed, 10 Jun 2026 00:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781051584; cv=none; b=IcKjK6ZLd315A6T6NTdCff3WcGhesgAfQnakZqK/yDXUadXF3dF2mSDix66SjmM+09etp1fVbPHzpbhuXWZFBXwepv9OC5xu7pEUcpUSjg9a0fKL5AyhxmHobHdM2RT5CKmWKmqHY/msC9XWG06xApZOSZYPTUeZ/OXQxSofYz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781051584; c=relaxed/simple; bh=z/6PoY5L3T995ZCB/VxkUi08Yq91j3PyA3uyAjk/CN8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pbumS6zD//QSOcZ0RJFyiUYNkHuO6QOoAUQtgKXui/aGpISWq/atig7jf8BY4GkILrzbGooLTSM1HkHFTMESudtchRAGAI7p4pQ+xIQIsOGCVGs0KJHQsvxSIEDo2234qyE6qupJ9rnl63S32cMd4kG6ksgmmJbTYWGWLkjbZrM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cQjfL6qz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cQjfL6qz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1BC71F00893; Wed, 10 Jun 2026 00:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781051583; bh=HacGq9vy/nwk7WKQRYcnSI6MhokQ7vpN7zhGoyls9ZM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=cQjfL6qzhkI/U3wSArxJuGF8j3F3XKbmefuECxQcwU9kujQ+ziJvWc8Buy299eihA zM+V6p8x2EcKgpURHejgubyLxZbJFHYNPbvhxu6LdwBpTgv6HyN6jFipFZ3fDOsr4Z nPwCXj+0nWANwDa8LVQ43pA64Xa5ON0OZbrhA1ml4i7ZcOjRwBcXdRvB0KpkU+IkgX FSw+JIO5mTh4YpiNpbgrKFaM3GZeMk48prfRk++5C9u6C6a7J8xP6LnNbavkldWa6f QvElaFybHYhEhpAgABH7MHkdjfQkVWo38xr+ZGQF0VigNFZBDSiQuV2edGZbAN/QzR RWduJ+nwctqsg== Date: Wed, 10 Jun 2026 00:33:01 +0000 From: Jaegeuk Kim To: Wenjie Qi 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 Message-ID: References: <20260527054507.1900373-1-qiwenjie@xiaomi.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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 >