linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: Remove i_rwsem lock in buffered read
@ 2024-12-26  6:16 Chi Zhiling
  2024-12-26 21:50 ` Dave Chinner
  0 siblings, 1 reply; 49+ messages in thread
From: Chi Zhiling @ 2024-12-26  6:16 UTC (permalink / raw)
  To: djwong, cem; +Cc: linux-xfs, linux-kernel, Chi Zhiling

From: Chi Zhiling <chizhiling@kylinos.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@kylinos.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


^ permalink raw reply related	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2025-06-20 14:03 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-26  6:16 [PATCH] xfs: Remove i_rwsem lock in buffered read Chi Zhiling
2024-12-26 21:50 ` Dave Chinner
2024-12-28  7:37   ` Chi Zhiling
2024-12-28 22:17     ` Dave Chinner
2024-12-30  2:42       ` Chi Zhiling
2025-01-07 12:13         ` Amir Goldstein
2025-01-07 17:12           ` Christoph Hellwig
2025-01-08  7:43           ` Chi Zhiling
2025-01-08 11:33             ` Amir Goldstein
2025-01-08 11:45               ` Amir Goldstein
2025-01-08 12:15               ` John Garry
2025-01-09 10:07                 ` Amir Goldstein
2025-01-09 12:40                   ` John Garry
2025-01-09  8:37               ` Chi Zhiling
2025-01-09 10:25                 ` Amir Goldstein
2025-01-09 12:10                   ` Chi Zhiling
2025-01-09 12:25                     ` John Garry
2025-01-08 17:35             ` Darrick J. Wong
2025-01-09 23:28               ` Dave Chinner
2025-01-10  1:31                 ` Chi Zhiling
2025-01-10 17:07                 ` Amir Goldstein
2025-01-12 10:05                   ` Chi Zhiling
2025-01-13  2:44                     ` Darrick J. Wong
2025-01-13  5:59                       ` Chi Zhiling
2025-01-13 13:40                       ` Brian Foster
2025-01-13 16:19                         ` Darrick J. Wong
2025-01-15  5:55                         ` Christoph Hellwig
2025-01-15 21:41                           ` Dave Chinner
2025-01-16  4:36                             ` Christoph Hellwig
2025-01-17 22:20                               ` Dave Chinner
2025-01-16 14:23                             ` Brian Foster
2025-01-17 13:27                             ` Amir Goldstein
2025-01-17 22:19                               ` Dave Chinner
2025-01-18 13:03                                 ` Amir Goldstein
2025-01-20  5:11                                   ` Dave Chinner
2025-01-22  6:08                                 ` Christoph Hellwig
2025-01-22 23:35                                   ` Dave Chinner
2025-01-17 16:12                             ` Chi Zhiling
2025-01-24  7:57                             ` Chi Zhiling
2025-01-27 20:49                               ` Dave Chinner
2025-01-28  5:15                                 ` Christoph Hellwig
2025-01-28 21:23                                   ` David Laight
2025-01-29  0:59                                   ` Dave Chinner
2025-01-29  5:20                                     ` Christoph Hellwig
2025-02-10  1:44                                 ` Chi Zhiling
2025-01-14  0:09                   ` Dave Chinner
2025-01-25  8:43           ` Jinliang Zheng
2025-01-25 14:14             ` Amir Goldstein
2025-06-20 14:03   ` Jinliang Zheng

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).