qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv2 0/3] virtio-serial-bus: use a bh for flush_queued_data
@ 2011-04-28 12:04 Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 1/3] virtio-serial-bus: use bh for unthrottling Alon Levy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alon Levy @ 2011-04-28 12:04 UTC (permalink / raw)
  To: qemu-devel

This replaces the direct call of flush_queued_data with a bottom half,
making the callpath for the chardev identical in a normal write and a write
resulting from unthrottling.

It includes a patch to add an accessor to QEMUBH to get scheduled status,
to keep the bh scheduled across migration.

Migration only trivially tested - just that it didn't break.

Alon Levy (3):
  virtio-serial-bus: use bh for unthrottling
  bh: add qemu_bh_is_scheduled
  virtio-serial-bus: on migration send status of pending ports bh

 async.c                |    4 ++++
 hw/virtio-serial-bus.c |   25 ++++++++++++++++++++-----
 hw/virtio-serial.h     |    5 +++++
 qemu-common.h          |    1 +
 4 files changed, 30 insertions(+), 5 deletions(-)

-- 
1.7.4.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCHv2 1/3] virtio-serial-bus: use bh for unthrottling
  2011-04-28 12:04 [Qemu-devel] [PATCHv2 0/3] virtio-serial-bus: use a bh for flush_queued_data Alon Levy
@ 2011-04-28 12:04 ` Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 2/3] bh: add qemu_bh_is_scheduled Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 3/3] virtio-serial-bus: on migration send status of pending ports bh Alon Levy
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2011-04-28 12:04 UTC (permalink / raw)
  To: qemu-devel

Instead of calling flush_queued_data when unthrottling, schedule
a bh. That way we can return immediately to the caller, and the
flush uses the same call path as a have_data for callbackee.
---
 hw/virtio-serial-bus.c |   11 +++++++++--
 hw/virtio-serial.h     |    5 +++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 6227379..8556e08 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -285,6 +285,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)
     return 0;
 }
 
+static void bh_virtio_serial_flush_queued_data(void *opaque)
+{
+    VirtIOSerialPort *port = opaque;
+
+    flush_queued_data(port);
+}
+
 void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle)
 {
     if (!port) {
@@ -295,8 +302,7 @@ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle)
     if (throttle) {
         return;
     }
-
-    flush_queued_data(port);
+    qemu_bh_schedule(port->bh);
 }
 
 /* Guest wants to notify us of some event */
@@ -724,6 +730,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)
     bool plugging_port0;
 
     port->vser = bus->vser;
+    port->bh = qemu_bh_new(bh_virtio_serial_flush_queued_data, port);
 
     /*
      * Is the first console port we're seeing? If so, put it up at
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index 5eb948e..0fa03d1 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -119,6 +119,11 @@ struct VirtIOSerialPort {
     uint32_t iov_idx;
     uint64_t iov_offset;
 
+    /*
+     * When unthrottling we use a buttomhalf to call flush_queued_data.
+     */
+    QEMUBH *bh;
+
     /* Identify if this is a port that binds with hvc in the guest */
     uint8_t is_console;
 
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCHv2 2/3] bh: add qemu_bh_is_scheduled
  2011-04-28 12:04 [Qemu-devel] [PATCHv2 0/3] virtio-serial-bus: use a bh for flush_queued_data Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 1/3] virtio-serial-bus: use bh for unthrottling Alon Levy
@ 2011-04-28 12:04 ` Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 3/3] virtio-serial-bus: on migration send status of pending ports bh Alon Levy
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2011-04-28 12:04 UTC (permalink / raw)
  To: qemu-devel

---
 async.c       |    4 ++++
 qemu-common.h |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/async.c b/async.c
index 57ac3a8..204716e 100644
--- a/async.c
+++ b/async.c
@@ -214,3 +214,7 @@ void qemu_bh_update_timeout(int *timeout)
     }
 }
 
+int qemu_bh_is_scheduled(QEMUBH *bh)
+{
+    return bh->scheduled;
+}
diff --git a/qemu-common.h b/qemu-common.h
index f9f705d..a107468 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -151,6 +151,7 @@ void qemu_bh_cancel(QEMUBH *bh);
 void qemu_bh_delete(QEMUBH *bh);
 int qemu_bh_poll(void);
 void qemu_bh_update_timeout(int *timeout);
+int qemu_bh_is_scheduled(QEMUBH *bh);
 
 void qemu_get_timedate(struct tm *tm, int offset);
 int qemu_timedate_diff(struct tm *tm);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCHv2 3/3] virtio-serial-bus: on migration send status of pending ports bh
  2011-04-28 12:04 [Qemu-devel] [PATCHv2 0/3] virtio-serial-bus: use a bh for flush_queued_data Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 1/3] virtio-serial-bus: use bh for unthrottling Alon Levy
  2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 2/3] bh: add qemu_bh_is_scheduled Alon Levy
@ 2011-04-28 12:04 ` Alon Levy
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2011-04-28 12:04 UTC (permalink / raw)
  To: qemu-devel

migration protocol bumped to 4, adding a single byte per port which is 1 if
there is a bh scheduled, 0 otherwise.
---
 hw/virtio-serial-bus.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 8556e08..7fb8ade 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -536,7 +536,7 @@ static void virtio_serial_save(QEMUFile *f, void *opaque)
         qemu_put_byte(f, port->guest_connected);
         qemu_put_byte(f, port->host_connected);
 
-	elem_popped = 0;
+        elem_popped = 0;
         if (port->elem.out_num) {
             elem_popped = 1;
         }
@@ -548,6 +548,8 @@ static void virtio_serial_save(QEMUFile *f, void *opaque)
             qemu_put_buffer(f, (unsigned char *)&port->elem,
                             sizeof(port->elem));
         }
+        /* Pending bh */
+        qemu_put_byte(f, !!qemu_bh_is_scheduled(port->bh));
     }
 }
 
@@ -558,7 +560,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
     uint32_t max_nr_ports, nr_active_ports, ports_map;
     unsigned int i;
 
-    if (version_id > 3) {
+    if (version_id > 4) {
         return -EINVAL;
     }
 
@@ -637,7 +639,13 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
                 virtio_serial_throttle_port(port, false);
             }
         }
+        if (version_id > 3) {
+            if (qemu_get_byte(f)) {
+                qemu_bh_schedule(port->bh);
+            }
+        }
     }
+
     return 0;
 }
 
@@ -889,7 +897,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
      * Register for the savevm section with the virtio-console name
      * to preserve backward compat
      */
-    register_savevm(dev, "virtio-console", -1, 3, virtio_serial_save,
+    register_savevm(dev, "virtio-console", -1, 4, virtio_serial_save,
                     virtio_serial_load, vser);
 
     return vdev;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-28 12:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28 12:04 [Qemu-devel] [PATCHv2 0/3] virtio-serial-bus: use a bh for flush_queued_data Alon Levy
2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 1/3] virtio-serial-bus: use bh for unthrottling Alon Levy
2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 2/3] bh: add qemu_bh_is_scheduled Alon Levy
2011-04-28 12:04 ` [Qemu-devel] [PATCHv2 3/3] virtio-serial-bus: on migration send status of pending ports bh Alon Levy

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).