From: Cornelia Huck <cohuck@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 3/5] virtio-scsi: default num_queues to -smp N
Date: Thu, 16 Jan 2020 12:53:49 +0100 [thread overview]
Message-ID: <20200116125349.6a3aeaa9.cohuck@redhat.com> (raw)
In-Reply-To: <20200116105842.271179-4-stefanha@redhat.com>
On Thu, 16 Jan 2020 10:58:40 +0000
Stefan Hajnoczi <stefanha@redhat.com> wrote:
> Automatically size the number of request virtqueues to match the number
> of vCPUs. This ensures that completion interrupts are handled on the
> same vCPU that submitted the request. No IPI is necessary to complete
> an I/O request and performance is improved.
>
> Remember that virtqueue numbering assumptions are being removed from the
> virtio-pci proxy object, so the Control and Event virtqueues are counted
> by ->get_num_virtqueues() and we only add 1 for the Configuration Change
> interrupt:
>
> if (vpci_dev->nvectors == DEV_NVECTORS_UNSPECIFIED) {
> - vpci_dev->nvectors = vs->conf.num_queues + 3;
> + vpci_dev->nvectors = vdc->get_num_virtqueues(VIRTIO_DEVICE(vdev)) + 1;
> }
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> hw/core/machine.c | 3 +++
> hw/scsi/vhost-scsi.c | 2 ++
> hw/scsi/vhost-user-scsi.c | 2 ++
> hw/scsi/virtio-scsi.c | 18 ++++++++++++++++++
> hw/virtio/vhost-scsi-pci.c | 4 ++--
> hw/virtio/vhost-user-scsi-pci.c | 4 ++--
> hw/virtio/virtio-scsi-pci.c | 4 ++--
> include/hw/virtio/virtio-scsi.h | 1 +
> 8 files changed, 32 insertions(+), 6 deletions(-)
>
> @@ -878,6 +879,18 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = {
> .load_request = virtio_scsi_load_request,
> };
>
> +static uint32_t virtio_scsi_get_num_virtqueues(VirtIODevice *vdev)
> +{
> + VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev);
> + uint32_t request_queues = s->conf.num_queues;
> +
> + if (s->conf.num_queues == 1 && s->conf.auto_num_queues) {
> + request_queues = current_machine->smp.cpus;
> + }
> +
> + return VIRTIO_SCSI_VQ_NUM_FIXED + request_queues;
I'm not sure doing this at the device level is the right thing to do.
For now, only virtio-pci will call this function, and there basing the
number of virtqueues off the number of cpus makes sense; but that's a
property of the transport, not of the device.
Consider e.g. a virtio-scsi-ccw device: If we wanted to introduce a way
to automatically pick a good number of virtqueues there, this functions
likely would not return a particularly useful value, as queue interrupt
processing does not really relate to the number of cpus with adapter
interrupts. It's not a problem right now, as only virtio-pci calls
this, but someone looking at this callback is likely getting the
impression that this is a generically useful function.
> +}
> +
> void virtio_scsi_common_realize(DeviceState *dev,
> VirtIOHandleOutput ctrl,
> VirtIOHandleOutput evt,
next prev parent reply other threads:[~2020-01-16 11:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 10:58 [PATCH 0/5] virtio: enable blk and scsi multi-queue by default Stefan Hajnoczi
2020-01-16 10:58 ` [PATCH 1/5] virtio-scsi: introduce a constant for fixed virtqueues Stefan Hajnoczi
2020-01-16 10:58 ` [PATCH 2/5] virtio: add VirtioDeviceClass->get_num_virtqueues() Stefan Hajnoczi
2020-01-16 10:58 ` [PATCH 3/5] virtio-scsi: default num_queues to -smp N Stefan Hajnoczi
2020-01-16 11:53 ` Cornelia Huck [this message]
2020-01-16 14:16 ` Stefan Hajnoczi
2020-01-16 15:02 ` Cornelia Huck
2020-01-16 10:58 ` [PATCH 4/5] virtio-blk: " Stefan Hajnoczi
2020-01-16 10:58 ` [PATCH 5/5] vhost-user-blk: " Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200116125349.6a3aeaa9.cohuck@redhat.com \
--to=cohuck@redhat.com \
--cc=ehabkost@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).