Received: from eggs.gnu.org ([140.186.70.92]:38058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFlzJ-0005iB-AF for qemu-devel@nongnu.org; Fri, 29 Apr 2011 07:35:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFlzI-00042q-AT for qemu-devel@nongnu.org; Fri, 29 Apr 2011 07:35:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFlzI-00042R-1D for qemu-devel@nongnu.org; Fri, 29 Apr 2011 07:35:56 -0400 Date: Fri, 29 Apr 2011 17:05:48 +0530 From: Amit Shah Message-ID: <20110429113548.GB15359@amit-x200.redhat.com> References: <1304076306-15867-1-git-send-email-alevy@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1304076306-15867-1-git-send-email-alevy@redhat.com> Subject: Re: [Qemu-devel] [PATCHv3] virtio-serial-bus: use bh for unthrottling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, "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