Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1413544 > unrolled thread
| Started by | Waiman Long <Waiman.Long@hpe.com> |
|---|---|
| First post | 2016-06-04 00:30 +0200 |
| Last post | 2016-06-09 11:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 1/3] dax: Take shared lock in dax_do_io() Waiman Long <Waiman.Long@hpe.com> - 2016-06-04 00:30 +0200
Re: [PATCH 1/3] dax: Take shared lock in dax_do_io() Christoph Hellwig <hch@infradead.org> - 2016-06-09 11:10 +0200
| From | Waiman Long <Waiman.Long@hpe.com> |
|---|---|
| Date | 2016-06-04 00:30 +0200 |
| Subject | [PATCH 1/3] dax: Take shared lock in dax_do_io() |
| Message-ID | <rG5Ll-AU-63@gated-at.bofh.it> |
With the change from i_mutex to i_rwsem in 4.7 kernel, the locking
scheme in dax_do_io() can now be changed to take a shared lock for
read so that multiple readers can access the same file concurrently.
With a 38-threads fio I/O test with 2 shared files (on DAX-mount, ext4
formatted NVDIMM) running on a 4-socket Haswell-EX server with 4.7-rc1
kernel, the aggregated bandwidths before and after the patch were:
Test W/O patch With patch % change
---- --------- ---------- --------
Read-only 4711MB/s 16031MB/s +240%
Read-write 1932MB/s 1040MB/s -46%
There was a big increase in parallel read performance. However,
parallel read-write test showed a regression because a mix of readers
and writers will largely disable optimistic spinning.
Signed-off-by: Waiman Long <Waiman.Long@hpe.com>
---
fs/dax.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/dax.c b/fs/dax.c
index 761495b..ff57d88 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -247,8 +247,8 @@ static ssize_t dax_io(struct inode *inode, struct iov_iter *iter,
* @flags: See below
*
* This function uses the same locking scheme as do_blockdev_direct_IO:
- * If @flags has DIO_LOCKING set, we assume that the i_mutex is held by the
- * caller for writes. For reads, we take and release the i_mutex ourselves.
+ * If @flags has DIO_LOCKING set, we assume that the i_rwsem is held by the
+ * caller for writes. For reads, we take and release the i_rwsem ourselves.
* If DIO_LOCKING is not set, the filesystem takes care of its own locking.
* As with do_blockdev_direct_IO(), we increment i_dio_count while the I/O
* is in progress.
@@ -265,8 +265,9 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
memset(&bh, 0, sizeof(bh));
bh.b_bdev = inode->i_sb->s_bdev;
+ /* Take the shared lock for read */
if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
- inode_lock(inode);
+ inode_lock_shared(inode);
/* Protects against truncate */
if (!(flags & DIO_SKIP_DIO_COUNT))
@@ -275,7 +276,7 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode,
retval = dax_io(inode, iter, pos, end, get_block, &bh);
if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ)
- inode_unlock(inode);
+ inode_unlock_shared(inode);
if (end_io) {
int err;
--
1.7.1
[toc] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2016-06-09 11:10 +0200 |
| Message-ID | <rI48p-4md-15@gated-at.bofh.it> |
| In reply to | #1413544 |
Please just take the extra step and move the locking out of dax_do_io and into the caller.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web