aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2021-07-06 21:38:00 +0000
committerGitHub <noreply@github.com>2021-07-06 21:38:00 +0000
commit97752ba22a4a036f9bc54556d114c77f68796b8f (patch)
tree5fc7a4a894b811a436573ea8a68732bc7bef7e95
parent6e4e3c3ab67d4ad050a5e704287ea3577fe45b17 (diff)
downloadsrc-97752ba22a4a036f9bc54556d114c77f68796b8f.tar.gz
src-97752ba22a4a036f9bc54556d114c77f68796b8f.zip
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 <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored-By: iXsystems, Inc. Closes #12281
-rw-r--r--module/zfs/vdev_queue.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/module/zfs/vdev_queue.c b/module/zfs/vdev_queue.c
index 198861edb816..06d22f6df4c5 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) {