Skip to contentSkip to conversation

Regression: virtio-pci: convert to ioeventfd callbacks

Qemu-devel Peter Lieven 4 participants 16 messages Jun 27, 2016 – Jun 29, 2016

lore
Share & tools
lore
#0 lore raw

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Peter

#1 lore raw
Quoted 9 lines · On Mon, 27 Jun 2016 11:44:47 +0200 Peter Lieven <[email protected]> wrote:

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Hm, I had not played around with blk-mq...

Any chance you could run this in gdb and get some backtraces?

#2 lore raw
In reply to Peter Lieven
Quoted 9 lines · On Mon, 27 Jun 2016 11:44:47 +0200 Peter Lieven <[email protected]> wrote:

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

OK, I played around a bit with Stefan's block branch rebased upon current master (and the conflict fixed up)... and I can't seem to hit any error with virtio-ccw (will see if I find time to play around with virtio-pci; but unless I've messed up, this should be the same code path). VIRTIO_BLK_F_MQ is correctly negotiated if num_queues > 1, and I can use the disk.

So, two questions:
- Which branch are you using? Any chance of a mis-merge there?
- Can you share the interesting portion of your command line?

#3 lore raw

Am 27.06.2016 um 17:09 schrieb Cornelia Huck:

Quoted 19 lines
Quoted 9 lines · On Mon, 27 Jun 2016 11:44:47 +0200 Peter Lieven <[email protected]> wrote:

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

OK, I played around a bit with Stefan's block branch rebased upon current master (and the conflict fixed up)... and I can't seem to hit any error with virtio-ccw (will see if I find time to play around with virtio-pci; but unless I've messed up, this should be the same code path). VIRTIO_BLK_F_MQ is correctly negotiated if num_queues > 1, and I can use the disk.

Quoted 4 lines

So, two questions:
- Which branch are you using? Any chance of a mis-merge there?
- Can you share the interesting portion of your command line?

Hi Cornelia,

sorry I should have been a little more precise. I am using current master for git.qemu.org.

I tried around and I can only reproduce the regression with iSCSI *and* dataplane enabled. Here is the reproducing commandline for me.

./x86_64-softmmu/qemu-system-x86_64 -enable-kvm -nodefaults -drive if=none,format=raw,file=iscsi://172.21.200.56/iqn.2001-05.com.equallogic:0-8a0906-98f384e0a-7d2004ee0a85767a-00lieven-test/0,cache=none,aio=native,id=disk0 -object iothread,id=iothread0 -device virtio-blk-pci,drive=disk0,iothread=iothread0 -vga vmware -monitor stdio

Have you the possiblity to install Ubuntu 14.04 on an iSCSI target?

Let me know if you need further information. Maybe the regression is an incompatiblity between the iSCSI driver and ioeventfd?

Thanks,
Peter

#4 lore raw
Quoted 27 lines · On Tue, 28 Jun 2016 08:22:05 +0200 Peter Lieven <[email protected]> wrote:

Am 27.06.2016 um 17:09 schrieb Cornelia Huck:

Quoted 19 lines
Quoted 9 lines · On Mon, 27 Jun 2016 11:44:47 +0200 Peter Lieven <[email protected]> wrote:

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

OK, I played around a bit with Stefan's block branch rebased upon current master (and the conflict fixed up)... and I can't seem to hit any error with virtio-ccw (will see if I find time to play around with virtio-pci; but unless I've messed up, this should be the same code path). VIRTIO_BLK_F_MQ is correctly negotiated if num_queues > 1, and I can use the disk.

Quoted 4 lines

So, two questions:
- Which branch are you using? Any chance of a mis-merge there?
- Can you share the interesting portion of your command line?

Hi Cornelia,

Quoted 7 lines

sorry I should have been a little more precise. I am using current master for git.qemu.org.

I tried around and I can only reproduce the regression with iSCSI *and* dataplane enabled. Here is the reproducing commandline for me.

./x86_64-softmmu/qemu-system-x86_64 -enable-kvm -nodefaults -drive if=none,format=raw,file=iscsi://172.21.200.56/iqn.2001-05.com.equallogic:0-8a0906-98f384e0a-7d2004ee0a85767a-00lieven-test/0,cache=none,aio=native,id=disk0 -object iothread,id=iothread0 -device virtio-blk-pci,drive=disk0,iothread=iothread0 -vga vmware -monitor stdio

Nothing really exciting there, maybe a timing issue triggered by the iscsi backing?

Quoted 2 lines

Have you the possiblity to install Ubuntu 14.04 on an iSCSI target?

No, I don't have any iscsi target available.

Quoted 2 lines

Let me know if you need further information. Maybe the regression is an incompatiblity between the iSCSI driver and ioeventfd?

Running in gdb and looking at the backchains may be helpful. Or checking in a guest dump whether there's any hang there instead. (Does this happen with guests other than Ubuntu 14.04, maybe with a similar kernel level?)

#5 lore raw
In reply to Cornelia Huck
Quoted 20 lines · Cornelia Huck
Quoted 9 lines · On Mon, 27 Jun 2016 11:44:47 +0200 Peter Lieven <[email protected]> wrote:

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

OK, I played around a bit with Stefan's block branch rebased upon current master (and the conflict fixed up)... and I can't seem to hit any error with virtio-ccw (will see if I find time to play around with virtio-pci; but unless I've messed up, this should be the same code path). VIRTIO_BLK_F_MQ is correctly negotiated if num_queues > 1, and I can use the disk.

Quoted 3 lines

So, two questions:
- Which branch are you using? Any chance of a mis-merge there?
- Can you share the interesting portion of your command line?

I notice cleanup is a bit weird:

        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
        k->ioeventfd_assign(proxy, notifier, n, assign);
        event_notifier_cleanup(notifier);

I think virtio_queue_set_host_notifier_fd_handler should happen after ioeventfd_assign for symmetry with init?

Signature · 1 line
MST
#6 lore raw
Quoted 8 lines · On Tue, 28 Jun 2016 10:03:21 +0300 "Michael S. Tsirkin" <[email protected]> wrote:

I notice cleanup is a bit weird:

        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
        k->ioeventfd_assign(proxy, notifier, n, assign);
        event_notifier_cleanup(notifier);

I think virtio_queue_set_host_notifier_fd_handler should happen after ioeventfd_assign for symmetry with init?

Looking at the pre-rework code, ccw used the order now in common code, while pci and mmio used the order you suggest.

"Switch the handler back, then unassign the transport's ioeventfd backing" made more sense to me (regardless of symmetry) - but we might lose a notification?

Peter: Can you check whether your problem goes away if you switch the two lines around?

#7 lore raw

Am 28.06.2016 um 09:42 schrieb Cornelia Huck:

Quoted 14 lines
Quoted 8 lines · On Tue, 28 Jun 2016 10:03:21 +0300 "Michael S. Tsirkin" <[email protected]> wrote:

I notice cleanup is a bit weird:

         virtio_queue_set_host_notifier_fd_handler(vq, false, false);
         k->ioeventfd_assign(proxy, notifier, n, assign);
         event_notifier_cleanup(notifier);

I think virtio_queue_set_host_notifier_fd_handler should happen after ioeventfd_assign for symmetry with init?

Looking at the pre-rework code, ccw used the order now in common code, while pci and mmio used the order you suggest.

Quoted 7 lines

"Switch the handler back, then unassign the transport's ioeventfd backing" made more sense to me (regardless of symmetry) - but we might lose a notification?

Peter: Can you check whether your problem goes away if you switch the two lines around?

The problem goes away, but its horribly slow. Maybe the lost notifications you were thinking off.

hw/virtio/virtio-bus.c +1 -1
index 1313760..7924a59 100644
@@ -176,9 +176,9 @@ static int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus,
             return r;
         }
     } else {
-        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
         k->ioeventfd_assign(proxy, notifier, n, assign);
         event_notifier_cleanup(notifier);
+        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
     }
     return r;
 }

Peter

#8 lore raw
Quoted 19 lines · On Tue, 28 Jun 2016 09:47:01 +0200 Peter Lieven <[email protected]> wrote:

Am 28.06.2016 um 09:42 schrieb Cornelia Huck:

Quoted 18 lines
Quoted 8 lines · On Tue, 28 Jun 2016 10:03:21 +0300 "Michael S. Tsirkin" <[email protected]> wrote:

I notice cleanup is a bit weird:

         virtio_queue_set_host_notifier_fd_handler(vq, false, false);
         k->ioeventfd_assign(proxy, notifier, n, assign);
         event_notifier_cleanup(notifier);

I think virtio_queue_set_host_notifier_fd_handler should happen after ioeventfd_assign for symmetry with init?

Looking at the pre-rework code, ccw used the order now in common code, while pci and mmio used the order you suggest.

"Switch the handler back, then unassign the transport's ioeventfd backing" made more sense to me (regardless of symmetry) - but we might lose a notification?

Quoted 6 lines
Quoted 3 lines

Peter: Can you check whether your problem goes away if you switch the two lines around?

The problem goes away, but its horribly slow. Maybe the lost notifications you were thinking off.

It points into that direction.

hw/virtio/virtio-bus.c static int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus, · line 179

Quoted 11 lines
hw/virtio/virtio-bus.c +0 -1
index 1313760..7924a59 100644
@@ -176,9 +176,9 @@ static int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus,
              return r;
          }
      } else {
-        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
          k->ioeventfd_assign(proxy, notifier, n, assign);

The virtio_queue_...() should go here.

Quoted 8 lines
hw/virtio/virtio-bus.c +1 -0
          event_notifier_cleanup(notifier);
+        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
      }
      return r;
  }

Peter

#9 lore raw
In reply to Peter Lieven
Quoted 2 lines · On Tue, 28 Jun 2016 09:47:01 +0200 Peter Lieven <[email protected]> wrote:

The problem goes away, but its horribly slow. Maybe the lost notifications you were thinking off.

I have the following patch (works for me on ccw as well). I'm worried about the slowness you're seeing, though. Is this just with an iscsi backing?

From a62e1518fa9c8a68c27d6997d8ca8fccf6152d1e Mon Sep 17 00:00:00 2001
From: Cornelia Huck <[email protected]>
Date: Tue, 28 Jun 2016 10:04:52 +0200
Subject: [PATCH] virtio: deassign ioeventfd before resetting handler

We should unassign the transport's ioeventfd backing before resetting the handler, or we may use notifications.

---
 hw/virtio/virtio-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-bus.c +1 -1
index 1313760..32fcc64 100644
@@ -176,8 +176,8 @@ static int set_host_notifier_internal(DeviceState *proxy, VirtioBusState *bus,
             return r;
         }
     } else {
-        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
         k->ioeventfd_assign(proxy, notifier, n, assign);
+        virtio_queue_set_host_notifier_fd_handler(vq, false, false);
         event_notifier_cleanup(notifier);
     }
     return r;
Signature · 1 line
2.9.0
#10 lore raw

Am 28.06.2016 um 10:16 schrieb Cornelia Huck:

Quoted 8 lines
Quoted 2 lines · On Tue, 28 Jun 2016 09:47:01 +0200 Peter Lieven <[email protected]> wrote:

The problem goes away, but its horribly slow. Maybe the lost notifications you were thinking off.

I have the following patch (works for me on ccw as well). I'm worried about the slowness you're seeing, though. Is this just with an iscsi backing?

Strange enough now neither my nor your version of the fix work for me anymore...

I can only reproduce with iSCSI. Neither QCOW2, RAW or NBD work.

I think it could have to do with the iSCSI event handler.

Peter

#11 lore raw
In reply to Peter Lieven
Quoted 13 lines · Peter Lieven

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Peter

In fact, I notice vhost-net does not work for master, look like we are trying to set host notifier without initialization which seems a bug

#12 lore raw
Quoted 14 lines · On Wed, 29 Jun 2016 09:41:50 +0800 Jason Wang <[email protected]> wrote:
Quoted 11 lines · Peter Lieven

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Quoted 7 lines
Quoted 3 lines

Peter

In fact, I notice vhost-net does not work for master, look like we are trying to set host notifier without initialization which seems a bug

Does the patch in <[email protected]> help?

#13 lore raw
Quoted 16 lines · Cornelia Huck
Quoted 13 lines · On Wed, 29 Jun 2016 09:41:50 +0800 Jason Wang <[email protected]> wrote:
Quoted 11 lines · Peter Lieven

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Peter

In fact, I notice vhost-net does not work for master, look like we are trying to set host notifier without initialization which seems a bug

Does the patch in <[email protected]> help?

It doesn't help.

Thanks

#14 lore raw
Quoted 22 lines · On Wed, 29 Jun 2016 16:21:07 +0800 Jason Wang <[email protected]> wrote:
Quoted 19 lines · Cornelia Huck
Quoted 16 lines · On Wed, 29 Jun 2016 09:41:50 +0800 Jason Wang <[email protected]> wrote:
Quoted 14 lines · Peter Lieven

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Peter

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

In fact, I notice vhost-net does not work for master, look like we are trying to set host notifier without initialization which seems a bug

Does the patch in <[email protected]> help?

It doesn't help.

Thanks for checking.

Debugging. This is broken here (virtio-ccw) as well.

#15 lore raw
In reply to Jason Wang
Quoted 12 lines · On Wed, 29 Jun 2016 09:41:50 +0800 Jason Wang <[email protected]> wrote:
Quoted 11 lines · Peter Lieven

Hi, with the above patch applied:

commit 9f06e71a567ba5ee8b727e65a2d5347fd331d2aa

Author: Cornelia Huck <[email protected]>
Date:   Fri Jun 10 11:04:12 2016 +0200

virtio-pci: convert to ioeventfd callbacks

a Ubuntu 14.04 VM freezes at startup when blk-mq is set up - even if there is only one queue.

Quoted 6 lines
Quoted 3 lines

Peter

In fact, I notice vhost-net does not work for master, look like we are trying to set host notifier without initialization which seems a bug

Yes, that's the problem: We switch handlers, but the notifier has not yet been setup (that's different from the dataplane call sequence). I think we need to setup the notifier without touching the handler for that case. I'm working on a patch.