diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-06-13 10:56:33 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-07-20 03:58:57 -0400 |
commit | bce750b1633927be3eecf821f4d17975c3ba5b6a (patch) | |
tree | c2c02f7bb37c67e1f4e769b4eb064726e84fc0ac | |
parent | 139fe45abc2234b20fd5ecbcb7ea6d3688fed5e5 (diff) |
[SCSI] virtio-scsi: release sg_lock after add_buf
We do not need the sglist after calling virtqueue_add_buf. Hence we
can "pipeline" the locked operations and start preparing the sglist
for the next request while we kick the virtqueue.
Together with the previous two patches, this improves performance as
follows. For a simple "if=/dev/sda of=/dev/null bs=128M iflag=direct"
(the source being a 10G disk, residing entirely in the host buffer cache),
the additional locking does not cause any penalty with only one dd
process, but 2 simultaneous I/O operations improve their times by 3%:
number of simultaneous dd
1 2
----------------------------------------
current 5.9958s 10.2640s
patched 5.9531s 9.8663s
(Times are best of 10).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/virtio_scsi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 0ecf95e214d3..facfc90ef005 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
@@ -281,11 +281,11 @@ static int virtscsi_kick_cmd(struct virtio_scsi *vscsi, struct virtio_scsi_vq *v | |||
281 | 281 | ||
282 | spin_lock(&vq->vq_lock); | 282 | spin_lock(&vq->vq_lock); |
283 | ret = virtqueue_add_buf(vq->vq, vscsi->sg, out_num, in_num, cmd, gfp); | 283 | ret = virtqueue_add_buf(vq->vq, vscsi->sg, out_num, in_num, cmd, gfp); |
284 | spin_unlock(&vscsi->sg_lock); | ||
284 | if (ret >= 0) | 285 | if (ret >= 0) |
285 | ret = virtqueue_kick_prepare(vq->vq); | 286 | ret = virtqueue_kick_prepare(vq->vq); |
286 | 287 | ||
287 | spin_unlock(&vq->vq_lock); | 288 | spin_unlock_irqrestore(&vq->vq_lock, flags); |
288 | spin_unlock_irqrestore(&vscsi->sg_lock, flags); | ||
289 | 289 | ||
290 | if (ret > 0) | 290 | if (ret > 0) |
291 | virtqueue_notify(vq->vq); | 291 | virtqueue_notify(vq->vq); |