From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M6M2x-0005s8-Kw for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M6M2s-0005nD-6y for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:42 -0400 Received: from [199.232.76.173] (port=34898 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M6M2s-0005n5-1W for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:38 -0400 Received: from mail19.svc.cra.dublin.eircom.net ([159.134.118.218]:48164) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1M6M2r-0006g0-JP for qemu-devel@nongnu.org; Tue, 19 May 2009 05:55:37 -0400 From: Mark McLoughlin Date: Tue, 19 May 2009 10:55:26 +0100 Message-Id: <1242726931-5726-5-git-send-email-markmc@redhat.com> In-Reply-To: <1242726931-5726-4-git-send-email-markmc@redhat.com> References: <1242726931-5726-1-git-send-email-markmc@redhat.com> <1242726931-5726-2-git-send-email-markmc@redhat.com> <1242726931-5726-3-git-send-email-markmc@redhat.com> <1242726931-5726-4-git-send-email-markmc@redhat.com> Subject: [Qemu-devel] [PATCH 04/13] net: only read from tapfd when we can send List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Mark McLoughlin , qemu-devel@nongnu.org Reduce the number of packets dropped under heavy network traffic by only reading a packet from the tapfd when a client can actually handle it. Signed-off-by: Mark McLoughlin --- net.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/net.c b/net.c index a3f4674..b506ccb 100644 --- a/net.c +++ b/net.c @@ -811,6 +811,13 @@ static void tap_receive(void *opaque, const uint8_t *buf, int size) } } +static int tap_can_send(void *opaque) +{ + TAPState *s = opaque; + + return qemu_can_send_packet(s->vc); +} + #ifdef __sun__ static ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { @@ -866,7 +873,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, tap_cleanup, s); s->vc->fd_readv = tap_receive_iov; - qemu_set_fd_handler(s->fd, tap_send, NULL, s); + qemu_set_fd_handler2(s->fd, tap_can_send, tap_send, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd); return s; } -- 1.6.0.6