virtio-serial-bus: use bh for unthrottling
PATCH v3 1/1 virtio-serial-bus: use bh for unthrottling
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.
No migration change is required because bh are called from vm_stop.
--- hw/virtio-serial-bus.c | 12 ++++++++++-- hw/virtio-serial.h | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-)
hw/virtio-serial-bus.c +10 -2
@@ -285,6 +285,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)return 0 ; } +static void flush_queued_data_bh (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 */
@@ -726,6 +732,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)bool plugging_port0; port->vser = bus->vser; + port->bh =qemu_bh_new (flush_queued_data_bh, port);/* * Is the first console port we're seeing? If so, put it up at
@@ -792,6 +799,7 @@ static int virtser_port_qdev_exit(DeviceState *qdev)VirtIOSerialPort *port =DO_UPCAST (VirtIOSerialPort, dev, qdev);VirtIOSerial *vser = port->vser; +qemu_bh_delete (port->bh);remove_port (port->vser, port->id);QTAILQ_REMOVE (&vser->ports, port, next);
hw/virtio-serial.h +5 -0
@@ -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;
Signature · 1 line
1.7.5
Quoted 5 lines · Alon Levy
Instead of calling
flush_queued_datawhen unthrottling, schedule a bh. That way we can return immediately to the caller, and the flush uses the same call path as ahave_datafor callbackee.No migration change is required because bh are called from
vm_stop.
This one looks OK; I'll put it through some testing.
However, I'd like confirmation that accessing (and modifying) vq elements is fine in bh context. Stefan / Michael?
Quoted 68 lines
--- hw/virtio-serial-bus.c | 12 ++++++++++-- hw/virtio-serial.h | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-)hw/virtio-serial-bus.c +10
-2@@ -285,6 +285,13 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port)return 0 ; } +static void flush_queued_data_bh (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 */ @@ -726,6 +732,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base)bool plugging_port0; port->vser = bus->vser; + port->bh =qemu_bh_new (flush_queued_data_bh, port);/* * Is the first console port we're seeing? If so, put it up at @@ -792,6 +799,7 @@ static int virtser_port_qdev_exit(DeviceState *qdev)VirtIOSerialPort *port =DO_UPCAST (VirtIOSerialPort, dev, qdev);VirtIOSerial *vser = port->vser; +qemu_bh_delete (port->bh);remove_port (port->vser, port->id);QTAILQ_REMOVE (&vser->ports, port, next);hw/virtio-serial.h +5
-0@@ -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;Signature · 1 line
1.7.5
Amit
Quoted 5 lines · Alon Levy
Instead of calling
flush_queued_datawhen unthrottling, schedule a bh. That way we can return immediately to the caller, and the flush uses the same call path as ahave_datafor callbackee.No migration change is required because bh are called from
vm_stop.
No sign-off?
The initial tests look good, no fireworks yet.
Amit
Quoted 5 lines · Amit Shah
Quoted 4 lines · Alon Levy
Instead of calling
flush_queued_datawhen unthrottling, schedule a bh. That way we can return immediately to the caller, and the flush uses the same call path as ahave_datafor callbackee.
Quoted 7 lines
Quoted 1 line
No migration change is required because bh are called from
vm_stop.No sign-off?
The initial tests look good, no fireworks yet.
Amit
Can I reply with a sign off?
Quoted 10 lines · Alon Levy
Quoted 9 lines · Amit Shah
Quoted 5 lines · Alon Levy
Instead of calling
flush_queued_datawhen unthrottling, schedule a bh. That way we can return immediately to the caller, and the flush uses the same call path as ahave_datafor callbackee.No migration change is required because bh are called from
vm_stop.No sign-off?
Quoted 7 lines
Quoted 3 lines
The initial tests look good, no fireworks yet.
Amit
Can I reply with a sign off?
Signed-off-by Alon Levy <[email protected]>
Yes, this is fine.
Amit