Holding the vblk->lock across kick causes poor scalability in SMP
guests. If one CPU is doing virtqueue kick and another CPU touches the
vblk->lock it will have to spin until virtqueue kick completes.
This typically results in high system CPU utilization in SMP guests that
are running multithreaded I/O-bound workloads.
Signed-off-by: Stefan Hajnoczi <redacted>
---
drivers/block/virtio_blk.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 079c088..c2bf0a9 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -193,8 +193,14 @@ static void do_virtblk_request(struct request_queue *q)
issued++;
}
- if (issued)
- virtqueue_kick(vblk->vq);
+ if (!issued)
+ return;
+
+ if (virtqueue_kick_prepare(vblk->vq)) {
+ spin_unlock(&vblk->lock);
+ virtqueue_kick_notify(vblk->vq);
+ spin_lock(&vblk->lock);
+ }
}
/* return id (s/n) string for *disk to *id_str--
1.7.5.4