linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: <brauner@kernel.org>, <david@fromorbit.com>, <djwong@kernel.org>,
	<jack@suse.cz>, <tytso@mit.edu>
Cc: <linux-xfs@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-ext4@vger.kernel.org>,
	<yi.zhang@huawei.com>
Subject: [PATCH RFC 2/2] ext4: Optimize endio process for DIO overwrites
Date: Thu, 29 Feb 2024 19:38:49 +0800	[thread overview]
Message-ID: <20240229113849.2222577-3-chengzhihao1@huawei.com> (raw)
In-Reply-To: <20240229113849.2222577-1-chengzhihao1@huawei.com>

In DIO overwriting case, there is no need to convert unwritten exntents
and ext4_handle_inode_extension() can be ignored, which means that endio
process can be executed under irq context. Since commit 240930fb7e6b5
("ext4: dio take shared inode lock when overwriting preallocated blocks")
has provided a method to judge whether overwriting is happening, just do
nothing in endio process if DIO overwriting happens.
This patch enables ext4 processing endio under irq context in DIO
overwriting case, which brings a performance improvement in the
following fio test on a x86 physical machine with nvme when irq
and fio run on the same cpu:

Test: fio -direct=1 -iodepth=128 -rw=randwrite -ioengine=libaio -bs=4k
-size=2G -numjobs=1 -overwrite=1 -time_based -runtime=60 -group_reporting
-filename=/test/test -name=Rand_write_Testing --cpus_allowed=1

before: 953 MiB/s  after: 1350 MiB/s, ~41% perf improvement.

Suggested-by: Zhang Yi <yi.zhang@huawei.com>
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 fs/ext4/file.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 54d6ff22585c..411a05c6b96e 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -503,6 +503,7 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	loff_t offset = iocb->ki_pos;
 	size_t count = iov_iter_count(from);
 	const struct iomap_ops *iomap_ops = &ext4_iomap_ops;
+	const struct iomap_dio_ops *iomap_dops = &ext4_dio_write_ops;
 	bool extend = false, unwritten = false;
 	bool ilock_shared = true;
 	int dio_flags = 0;
@@ -572,9 +573,12 @@ static ssize_t ext4_dio_write_iter(struct kiocb *iocb, struct iov_iter *from)
 		ext4_journal_stop(handle);
 	}
 
-	if (ilock_shared && !unwritten)
+	if (ilock_shared && !unwritten) {
 		iomap_ops = &ext4_iomap_overwrite_ops;
-	ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops,
+		iomap_dops = NULL;
+		dio_flags = IOMAP_DIO_MAY_INLINE_COMP;
+	}
+	ret = iomap_dio_rw(iocb, from, iomap_ops, iomap_dops,
 			   dio_flags, NULL, 0);
 	if (ret == -ENOTBLK)
 		ret = 0;
-- 
2.39.2


      parent reply	other threads:[~2024-02-29 11:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 11:38 [PATCH RFC 0/2] ext4: Do endio process under irq context for DIO overwrites Zhihao Cheng
2024-02-29 11:38 ` [PATCH RFC 1/2] iomap: Add a IOMAP_DIO_MAY_INLINE_COMP flag Zhihao Cheng
2024-03-01  0:40   ` Dave Chinner
2024-03-01 10:02     ` Zhihao Cheng
2024-03-11  7:55       ` Zhihao Cheng
2024-02-29 11:38 ` Zhihao Cheng [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=20240229113849.2222577-3-chengzhihao1@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=brauner@kernel.org \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.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;
as well as URLs for NNTP newsgroup(s).