[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 03/10] virtio-scsi: suppress virtqueue kick durin
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH v3 03/10] virtio-scsi: suppress virtqueue kick during processing |
Date: |
Tue, 22 Nov 2016 16:31:39 +0000 |
The guest does not need to kick the virtqueue while we are processing
it. This reduces the number of vmexits during periods of heavy I/O.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/scsi/virtio-scsi.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 10fd687..24a6272 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -578,26 +578,32 @@ static void virtio_scsi_handle_cmd_req_submit(VirtIOSCSI
*s, VirtIOSCSIReq *req)
void virtio_scsi_handle_cmd_vq(VirtIOSCSI *s, VirtQueue *vq)
{
VirtIOSCSIReq *req, *next;
- int ret;
+ int ret = 0;
QTAILQ_HEAD(, VirtIOSCSIReq) reqs = QTAILQ_HEAD_INITIALIZER(reqs);
- while ((req = virtio_scsi_pop_req(s, vq))) {
- ret = virtio_scsi_handle_cmd_req_prepare(s, req);
- if (!ret) {
- QTAILQ_INSERT_TAIL(&reqs, req, next);
- } else if (ret == -EINVAL) {
- /* The device is broken and shouldn't process any request */
- while (!QTAILQ_EMPTY(&reqs)) {
- req = QTAILQ_FIRST(&reqs);
- QTAILQ_REMOVE(&reqs, req, next);
- blk_io_unplug(req->sreq->dev->conf.blk);
- scsi_req_unref(req->sreq);
- virtqueue_detach_element(req->vq, &req->elem, 0);
- virtio_scsi_free_req(req);
+ do {
+ virtio_queue_set_notification(vq, 0);
+
+ while ((req = virtio_scsi_pop_req(s, vq))) {
+ ret = virtio_scsi_handle_cmd_req_prepare(s, req);
+ if (!ret) {
+ QTAILQ_INSERT_TAIL(&reqs, req, next);
+ } else if (ret == -EINVAL) {
+ /* The device is broken and shouldn't process any request */
+ while (!QTAILQ_EMPTY(&reqs)) {
+ req = QTAILQ_FIRST(&reqs);
+ QTAILQ_REMOVE(&reqs, req, next);
+ blk_io_unplug(req->sreq->dev->conf.blk);
+ scsi_req_unref(req->sreq);
+ virtqueue_detach_element(req->vq, &req->elem, 0);
+ virtio_scsi_free_req(req);
+ }
}
}
- }
+
+ virtio_queue_set_notification(vq, 1);
+ } while (ret != -EINVAL && !virtio_queue_empty(vq));
QTAILQ_FOREACH_SAFE(req, &reqs, next, next) {
virtio_scsi_handle_cmd_req_submit(s, req);
--
2.7.4
- [Qemu-devel] [PATCH v3 00/10] aio: experimental virtio-blk polling mode, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 02/10] virtio-blk: suppress virtqueue kick during processing, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 01/10] virtio: add missing vdev->broken check, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 03/10] virtio-scsi: suppress virtqueue kick during processing,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH v3 06/10] virtio: poll virtqueues for new buffers, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 04/10] aio: add AioPollFn and io_poll() interface, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 08/10] virtio: turn vq->notification into a nested counter, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 07/10] linux-aio: poll ring for completions, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 05/10] aio: add polling mode to AioContext, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 09/10] aio: add .io_poll_begin/end() callbacks, Stefan Hajnoczi, 2016/11/22
- [Qemu-devel] [PATCH v3 10/10] virtio: disable virtqueue notifications during polling, Stefan Hajnoczi, 2016/11/22