qemu-e2k/include/hw/virtio
Stefan Hajnoczi 38738f7dbb virtio-scsi: don't waste CPU polling the event virtqueue
The virtio-scsi event virtqueue is not emptied by its handler function.
This is typical for rx virtqueues where the device uses buffers when
some event occurs (e.g. a packet is received, an error condition
happens, etc).

Polling non-empty virtqueues wastes CPU cycles. We are not waiting for
new buffers to become available, we are waiting for an event to occur,
so it's a misuse of CPU resources to poll for buffers.

Introduce the new virtio_queue_aio_attach_host_notifier_no_poll() API,
which is identical to virtio_queue_aio_attach_host_notifier() except
that it does not poll the virtqueue.

Before this patch the following command-line consumed 100% CPU in the
IOThread polling and calling virtio_scsi_handle_event():

  $ qemu-system-x86_64 -M accel=kvm -m 1G -cpu host \
      --object iothread,id=iothread0 \
      --device virtio-scsi-pci,iothread=iothread0 \
      --blockdev file,filename=test.img,aio=native,cache.direct=on,node-name=drive0 \
      --device scsi-hd,drive=drive0

After this patch CPU is no longer wasted.

Reported-by: Nir Soffer <nsoffer@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Nir Soffer <nsoffer@redhat.com>
Message-id: 20220427143541.119567-3-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2022-05-09 10:45:04 +01:00
..
vhost-backend.h
vhost-scsi-common.h
vhost-scsi.h
vhost-user-blk.h
vhost-user-fs.h
vhost-user-i2c.h hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST 2022-03-04 08:30:52 -05:00
vhost-user-rng.h
vhost-user-scsi.h
vhost-user-vsock.h
vhost-user.h vhost-user: fix VirtQ notifier cleanup 2022-03-04 08:30:52 -05:00
vhost-vdpa.h vdpa: Expose VHOST_F_LOG_ALL on SVQ 2022-03-15 13:57:44 +08:00
vhost-vsock-common.h
vhost-vsock.h
vhost.h
virtio-access.h Replace TARGET_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
virtio-balloon.h
virtio-blk.h
virtio-bus.h
virtio-crypto.h
virtio-gpu-bswap.h Replace config-time define HOST_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
virtio-gpu-pci.h
virtio-gpu-pixman.h
virtio-gpu.h
virtio-input.h
virtio-iommu.h virtio-iommu: Default to bypass during boot 2022-03-06 05:08:23 -05:00
virtio-mem.h
virtio-mmio.h
virtio-net.h
virtio-pmem.h
virtio-rng.h
virtio-scsi.h build: move vhost-scsi configuration to Kconfig 2022-05-07 07:46:58 +02:00
virtio-serial.h
virtio.h virtio-scsi: don't waste CPU polling the event virtqueue 2022-05-09 10:45:04 +01:00