[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241226061602.2222985-1-chizhiling@163.com>
Date: Thu, 26 Dec 2024 14:16:02 +0800
From: Chi Zhiling <chizhiling@....com>
To: djwong@...nel.org,
cem@...nel.org
Cc: linux-xfs@...r.kernel.org,
linux-kernel@...r.kernel.org,
Chi Zhiling <chizhiling@...inos.cn>
Subject: [PATCH] xfs: Remove i_rwsem lock in buffered read
From: Chi Zhiling <chizhiling@...inos.cn>
Using an rwsem to protect file data ensures that we can always obtain a
completed modification. But due to the lock, we need to wait for the
write process to release the rwsem before we can read it, even if we are
reading a different region of the file. This could take a lot of time
when many processes need to write and read this file.
On the other hand, The ext4 filesystem and others do not hold the lock
during buffered reading, which make the ext4 have better performance in
that case. Therefore, I think it will be fine if we remove the lock in
xfs, as most applications can handle this situation.
Without this lock, we achieve a great improvement when multi-threaded
reading and writing. Use the following command to test:
fio -ioengine=libaio -filename=testfile -bs=4k -rw=randrw -numjobs=16 -name="randrw"
Before this patch:
READ: bw=351MiB/s (368MB/s), 21.8MiB/s-22.0MiB/s (22.9MB/s-23.1MB/s), io=8185MiB (8582MB), run=23206-23347msec
WRITE: bw=351MiB/s (368MB/s), 21.9MiB/s-22.1MiB/s (23.0MB/s-23.2MB/s), io=8199MiB (8597MB), run=23206-23347msec
After this patch:
READ: bw=1961MiB/s (2056MB/s), 122MiB/s-125MiB/s (128MB/s-131MB/s), io=8185MiB (8582MB), run=4097-4174msec
WRITE: bw=1964MiB/s (2060MB/s), 123MiB/s-125MiB/s (129MB/s-131MB/s), io=8199MiB (8597MB), run=4097-4174msec
Signed-off-by: Chi Zhiling <chizhiling@...inos.cn>
---
fs/xfs/xfs_file.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 9a435b1ff264..7d039cc3ae9e 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -279,18 +279,9 @@ xfs_file_buffered_read(
struct kiocb *iocb,
struct iov_iter *to)
{
- struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp));
- ssize_t ret;
-
trace_xfs_file_buffered_read(iocb, to);
- ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED);
- if (ret)
- return ret;
- ret = generic_file_read_iter(iocb, to);
- xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-
- return ret;
+ return generic_file_read_iter(iocb, to);
}
STATIC ssize_t
--
2.43.0
Powered by blists - more mailing lists