* [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling
@ 2011-04-29 11:25 Alon Levy
2011-04-29 11:35 ` Amit Shah
2011-04-29 12:56 ` Amit Shah
0 siblings, 2 replies; 5+ messages in thread
From: Alon Levy @ 2011-04-29 11:25 UTC (permalink / raw)
To: qemu-devel; +Cc: amit.shah
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(-)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index f10d48f..ca0581b 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 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);
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.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling
2011-04-29 11:25 [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling Alon Levy
@ 2011-04-29 11:35 ` Amit Shah
2011-04-29 12:56 ` Amit Shah
1 sibling, 0 replies; 5+ messages in thread
From: Amit Shah @ 2011-04-29 11:35 UTC (permalink / raw)
To: Alon Levy; +Cc: Stefan Hajnoczi, qemu-devel, Michael S. Tsirkin
On (Fri) 29 Apr 2011 [14:25:06], Alon Levy wrote:
> 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.
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?
> ---
> hw/virtio-serial-bus.c | 12 ++++++++++--
> hw/virtio-serial.h | 5 +++++
> 2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index f10d48f..ca0581b 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 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);
> 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.5
>
Amit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling
2011-04-29 11:25 [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling Alon Levy
2011-04-29 11:35 ` Amit Shah
@ 2011-04-29 12:56 ` Amit Shah
2011-04-30 8:23 ` Alon Levy
1 sibling, 1 reply; 5+ messages in thread
From: Amit Shah @ 2011-04-29 12:56 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On (Fri) 29 Apr 2011 [14:25:06], Alon Levy wrote:
> 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.
No sign-off?
The initial tests look good, no fireworks yet.
Amit
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling
2011-04-29 12:56 ` Amit Shah
@ 2011-04-30 8:23 ` Alon Levy
2011-05-02 7:21 ` Amit Shah
0 siblings, 1 reply; 5+ messages in thread
From: Alon Levy @ 2011-04-30 8:23 UTC (permalink / raw)
To: Amit Shah; +Cc: qemu-devel
On Fri, Apr 29, 2011 at 06:26:49PM +0530, Amit Shah wrote:
> On (Fri) 29 Apr 2011 [14:25:06], Alon Levy wrote:
> > 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.
>
> No sign-off?
>
> The initial tests look good, no fireworks yet.
>
> Amit
Can I reply with a sign off?
Signed-off-by: Alon Levy <alevy@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling
2011-04-30 8:23 ` Alon Levy
@ 2011-05-02 7:21 ` Amit Shah
0 siblings, 0 replies; 5+ messages in thread
From: Amit Shah @ 2011-05-02 7:21 UTC (permalink / raw)
To: qemu-devel
On (Sat) 30 Apr 2011 [11:23:42], Alon Levy wrote:
> On Fri, Apr 29, 2011 at 06:26:49PM +0530, Amit Shah wrote:
> > On (Fri) 29 Apr 2011 [14:25:06], Alon Levy wrote:
> > > 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.
> >
> > No sign-off?
> >
> > The initial tests look good, no fireworks yet.
> >
> > Amit
>
> Can I reply with a sign off?
>
> Signed-off-by: Alon Levy <alevy@redhat.com>
Yes, this is fine.
Amit
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-05-02 7:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29 11:25 [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling Alon Levy
2011-04-29 11:35 ` Amit Shah
2011-04-29 12:56 ` Amit Shah
2011-04-30 8:23 ` Alon Levy
2011-05-02 7:21 ` Amit Shah
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).