From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41583 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4bKw-0001R6-Ib for qemu-devel@nongnu.org; Tue, 29 Mar 2011 12:00:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4bKv-0001tG-9o for qemu-devel@nongnu.org; Tue, 29 Mar 2011 12:00:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4bKv-0001sf-0Y for qemu-devel@nongnu.org; Tue, 29 Mar 2011 12:00:05 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2TFxxDO029696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 29 Mar 2011 11:59:59 -0400 Received: from playa.tlv.redhat.com (dhcp-3-110.tlv.redhat.com [10.35.3.110]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2TFxv44002599 for ; Tue, 29 Mar 2011 11:59:58 -0400 From: Alon Levy Date: Tue, 29 Mar 2011 17:59:56 +0200 Message-Id: <1301414396-13562-1-git-send-email-alevy@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-serial-bus: use bh for unthrottling List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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. migration: since version 2 of the migration protocol we unthrottle if there is data. So we don't need to add anything special here, just the unthrottling mechanism changed, from directl function call to bh. --- 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 a82fbe9..e8a892d 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 */ @@ -721,6 +727,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.1