* [Qemu-devel] [PATCH] virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD
@ 2011-01-25 13:58 Stefan Hajnoczi
2011-01-25 14:13 ` [Qemu-devel] " Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Hajnoczi @ 2011-01-25 13:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Michael S. Tsirkin
It is not possible to use virtio-ioeventfd when building without an I/O
thread. We rely on a signal to kick us out of vcpu execution. Timers
and AIO use SIGALRM and SIGUSR2 respectively. Unfortunately eventfd
does not support O_ASYNC (SIGIO) so eventfd cannot be used in a signal
driven manner.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
hw/virtio-pci.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index d07ff97..e921eda 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -640,6 +640,25 @@ static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign)
return virtio_pci_set_host_notifier_internal(proxy, n, assign);
}
+static bool virtio_pci_can_use_ioeventfd(void)
+{
+ if (!kvm_has_many_ioeventfds()) {
+ return false;
+ }
+
+ /* Use ioeventfd for virtqueue kick only if we have an I/O thread to
+ * perform out-of-line processing. Otherwise we might as well do
+ * synchronous virtqueue kicks and in fact we have to since eventfd does
+ * not support SIGIO. Without the I/O thread a signal would be required to
+ * kick the vcpu out of guest code.
+ */
+#ifdef CONFIG_IOTHREAD
+ return true;
+#else
+ return false;
+#endif
+}
+
static void virtio_pci_vmstate_change(void *opaque, bool running)
{
VirtIOPCIProxy *proxy = opaque;
@@ -705,7 +724,7 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
pci_register_bar(&proxy->pci_dev, 0, size, PCI_BASE_ADDRESS_SPACE_IO,
virtio_map);
- if (!kvm_has_many_ioeventfds()) {
+ if (!virtio_pci_can_use_ioeventfd()) {
proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
}
--
1.7.2.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Qemu-devel] Re: [PATCH] virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD
2011-01-25 13:58 [Qemu-devel] [PATCH] virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD Stefan Hajnoczi
@ 2011-01-25 14:13 ` Michael S. Tsirkin
2011-01-25 14:20 ` Stefan Hajnoczi
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2011-01-25 14:13 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Kevin Wolf, qemu-devel
On Tue, Jan 25, 2011 at 01:58:08PM +0000, Stefan Hajnoczi wrote:
> It is not possible to use virtio-ioeventfd when building without an I/O
> thread. We rely on a signal to kick us out of vcpu execution. Timers
> and AIO use SIGALRM and SIGUSR2 respectively. Unfortunately eventfd
> does not support O_ASYNC (SIGIO) so eventfd cannot be used in a signal
> driven manner.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
I'd rather have the CONFIG_ ... mess contained in kvm-all.c
which tests CONFIG_IOTHREAD anyway, than spread out
to devices. Can we make kvm_has_many_ioeventfds check this?
> ---
> hw/virtio-pci.c | 21 ++++++++++++++++++++-
> 1 files changed, 20 insertions(+), 1 deletions(-)
>
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index d07ff97..e921eda 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -640,6 +640,25 @@ static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign)
> return virtio_pci_set_host_notifier_internal(proxy, n, assign);
> }
>
> +static bool virtio_pci_can_use_ioeventfd(void)
> +{
> + if (!kvm_has_many_ioeventfds()) {
> + return false;
> + }
> +
> + /* Use ioeventfd for virtqueue kick only if we have an I/O thread to
> + * perform out-of-line processing. Otherwise we might as well do
> + * synchronous virtqueue kicks and in fact we have to since eventfd does
> + * not support SIGIO. Without the I/O thread a signal would be required to
> + * kick the vcpu out of guest code.
> + */
> +#ifdef CONFIG_IOTHREAD
> + return true;
> +#else
> + return false;
> +#endif
> +}
> +
> static void virtio_pci_vmstate_change(void *opaque, bool running)
> {
> VirtIOPCIProxy *proxy = opaque;
> @@ -705,7 +724,7 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
> pci_register_bar(&proxy->pci_dev, 0, size, PCI_BASE_ADDRESS_SPACE_IO,
> virtio_map);
>
> - if (!kvm_has_many_ioeventfds()) {
> + if (!virtio_pci_can_use_ioeventfd()) {
> proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
> }
>
> --
> 1.7.2.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD
2011-01-25 14:13 ` [Qemu-devel] " Michael S. Tsirkin
@ 2011-01-25 14:20 ` Stefan Hajnoczi
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2011-01-25 14:20 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Kevin Wolf, Stefan Hajnoczi, qemu-devel
On Tue, Jan 25, 2011 at 2:13 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Tue, Jan 25, 2011 at 01:58:08PM +0000, Stefan Hajnoczi wrote:
>> It is not possible to use virtio-ioeventfd when building without an I/O
>> thread. We rely on a signal to kick us out of vcpu execution. Timers
>> and AIO use SIGALRM and SIGUSR2 respectively. Unfortunately eventfd
>> does not support O_ASYNC (SIGIO) so eventfd cannot be used in a signal
>> driven manner.
>>
>> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
>
> I'd rather have the CONFIG_ ... mess contained in kvm-all.c
> which tests CONFIG_IOTHREAD anyway, than spread out
> to devices. Can we make kvm_has_many_ioeventfds check this?
Good idea.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-25 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 13:58 [Qemu-devel] [PATCH] virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD Stefan Hajnoczi
2011-01-25 14:13 ` [Qemu-devel] " Michael S. Tsirkin
2011-01-25 14:20 ` Stefan Hajnoczi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.