diff options
author | Alexander Motin <[email protected]> | 2021-07-06 17:38:00 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-07-06 14:38:00 -0700 |
commit | 97752ba22a4a036f9bc54556d114c77f68796b8f (patch) | |
tree | 5fc7a4a894b811a436573ea8a68732bc7bef7e95 /module | |
parent | 6e4e3c3ab67d4ad050a5e704287ea3577fe45b17 (diff) |
Move gethrtime() calls out of vdev queue lock
This dramatically reduces the lock contention on systems with slower
(non-TSC) timecounters. With TSC the difference is minimal, but since
this lock is pretty congested, any improvement counts. Plus I don't
see any reason to do it under the lock other than the latency of the
lock itself, which this change actually reduces.
Reviewed-by: Matthew Ahrens <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Alexander Motin <[email protected]>
Sponsored-By: iXsystems, Inc.
Closes #12281
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/vdev_queue.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c index 198861edb..06d22f6df 100644 --- a/module/zfs/vdev_queue.c +++ b/module/zfs/vdev_queue.c @@ -912,9 +912,9 @@ vdev_queue_io(zio_t *zio) } zio->io_flags |= ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE; + zio->io_timestamp = gethrtime(); mutex_enter(&vq->vq_lock); - zio->io_timestamp = gethrtime(); vdev_queue_io_add(vq, zio); nio = vdev_queue_io_to_issue(vq); mutex_exit(&vq->vq_lock); @@ -936,14 +936,13 @@ vdev_queue_io_done(zio_t *zio) vdev_queue_t *vq = &zio->io_vd->vdev_queue; zio_t *nio; - mutex_enter(&vq->vq_lock); + hrtime_t now = gethrtime(); + vq->vq_io_complete_ts = now; + vq->vq_io_delta_ts = zio->io_delta = now - zio->io_timestamp; + mutex_enter(&vq->vq_lock); vdev_queue_pending_remove(vq, zio); - zio->io_delta = gethrtime() - zio->io_timestamp; - vq->vq_io_complete_ts = gethrtime(); - vq->vq_io_delta_ts = vq->vq_io_complete_ts - zio->io_timestamp; - while ((nio = vdev_queue_io_to_issue(vq)) != NULL) { mutex_exit(&vq->vq_lock); if (nio->io_done == vdev_queue_agg_io_done) { |