From patchwork Thu May 31 10:03:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 162131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AF496B6FD9 for ; Thu, 31 May 2012 20:04:03 +1000 (EST) Received: from localhost ([::1]:44176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa2Eb-0008LN-7H for incoming@patchwork.ozlabs.org; Thu, 31 May 2012 06:04:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa2EO-000863-JD for qemu-devel@nongnu.org; Thu, 31 May 2012 06:03:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sa2EG-0005p0-GN for qemu-devel@nongnu.org; Thu, 31 May 2012 06:03:48 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:35115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sa2EG-0005oW-3k for qemu-devel@nongnu.org; Thu, 31 May 2012 06:03:40 -0400 Received: by pbbro12 with SMTP id ro12so1401517pbb.4 for ; Thu, 31 May 2012 03:03:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=R75ITNVsnTYQjOythPV335/RUreepkze1v93jJLwCxI=; b=ktKLOVWpbS+9iiqhvlsCfUJHs7VQSZMysVpVu4ydkpzfzqiMVK2Dhr70MiBEWyhzs4 HY9c+w3vlXOonZ5Tw233dReK25i9cSDuOFyMRdhgR1NeA26x6eDW7E1rk2U4GVoPb3vS p54Rjgyuus4Vzaf4FAWmRogsmdI6LeGGsi0xb51xz74y6J2Qwp4yUgvllK4PD1zB7s5D 85DscUrSXIsXm44v4myJ22l4YKXzjD6ayRaMt3SurjtX/LVaEqKnnVWqAGu8bWYVxD/M s1gNeiq3RQCSb5xyqx1F+CZ+BlI3i/wS+XRplA+ILw2B+T4AvdnX7SFBkGrr61Vp6WFv 9+Vw== Received: by 10.68.203.73 with SMTP id ko9mr59781990pbc.66.1338458617981; Thu, 31 May 2012 03:03:37 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-204-25.ip51.fastwebnet.it. [93.34.204.25]) by mx.google.com with ESMTPS id ka5sm3688205pbb.37.2012.05.31.03.03.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 May 2012 03:03:36 -0700 (PDT) Message-ID: <4FC741F1.4000905@redhat.com> Date: Thu, 31 May 2012 12:03:29 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Jan Kiszka References: <20120530202311.GA1768@onelab2.iet.unipi.it> <20120530212333.GD2672@onelab2.iet.unipi.it> <4FC69389.8050404@web.de> <4FC69B28.1000106@web.de> <4FC71FEB.9030100@redhat.com> <4FC72A95.4040808@web.de> In-Reply-To: <4FC72A95.4040808@web.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Luigi Rizzo , rizzo@iet.unipi.it, qemu-devel@nongnu.org, Stefano Stabellini Subject: Re: [Qemu-devel] Proposed patch: huge RX speedup for hw/e1000.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Il 31/05/2012 10:23, Jan Kiszka ha scritto: >> > @@ -922,6 +923,7 @@ set_rdt(E1000State *s, int index, uint32_t val) >> > { >> > s->check_rxov = 0; >> > s->mac_reg[index] = val & 0xffff; >> > + qemu_notify_event(); > This still looks like the wrong tool: Packets that can't be delivered > are queued. Packets that are read from the tap but can't be delivered are queued; packets that are left on the tap need qemu_notify_event to be flushed. > So we need to flush the queue and clear the blocked delivery > there. qemu_flush_queued_packets appears more appropriate for this. Right, and qemu_flush_queued_packets needs to call qemu_notify_event which makes the call in virtio-net unnecessary. Paolo Tested-by: Luigi Rizzo Tested-by: Luigi Rizzo diff --git a/hw/e1000.c b/hw/e1000.c index 4573f13..43d933a 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -295,6 +295,7 @@ set_rx_control(E1000State *s, int index, uint32_t val) s->rxbuf_min_shift = ((val / E1000_RCTL_RDMTS_QUAT) & 3) + 1; DBGOUT(RX, "RCTL: %d, mac_reg[RCTL] = 0x%x\n", s->mac_reg[RDT], s->mac_reg[RCTL]); + qemu_flush_queued_packets(&s->nic->nc); } static void @@ -926,6 +927,9 @@ set_rdt(E1000State *s, int index, uint32_t val) { s->check_rxov = 0; s->mac_reg[index] = val & 0xffff; + if (e1000_has_rxbufs(s, 1)) { + qemu_flush_queued_packets(&s->nic->nc); + } } static void diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 3f190d4..0974945 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -447,10 +447,6 @@ static void virtio_net_handle_rx(VirtIODevice *vdev, VirtQueue *vq) VirtIONet *n = to_virtio_net(vdev); qemu_flush_queued_packets(&n->nic->nc); - - /* We now have RX buffers, signal to the IO thread to break out of the - * select to re-poll the tap file descriptor */ - qemu_notify_event(); } static int virtio_net_can_receive(VLANClientState *nc) diff --git a/net.c b/net.c index 1922d8a..fa846ae 100644 --- a/net.c +++ b/net.c @@ -491,7 +491,12 @@ void qemu_flush_queued_packets(VLANClientState *vc) queue = vc->send_queue; } - qemu_net_queue_flush(queue); + if (qemu_net_queue_flush(queue)) { + /* We emptied the queue successfully, signal to the IO thread to repoll + * the file descriptor (for tap, for example). + */ + qemu_notify_event(); + } } static ssize_t qemu_send_packet_async_with_flags(VLANClientState *sender, diff --git a/net/queue.c b/net/queue.c index 1ab5247..fd1c7e6 100644 --- a/net/queue.c +++ b/net/queue.c @@ -232,7 +232,7 @@ void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from) } } -void qemu_net_queue_flush(NetQueue *queue) +bool qemu_net_queue_flush(NetQueue *queue) { while (!QTAILQ_EMPTY(&queue->packets)) { NetPacket *packet; @@ -248,7 +248,7 @@ void qemu_net_queue_flush(NetQueue *queue) packet->size); if (ret == 0) { QTAILQ_INSERT_HEAD(&queue->packets, packet, entry); - break; + return 0; } if (packet->sent_cb) { @@ -257,4 +257,5 @@ void qemu_net_queue_flush(NetQueue *queue) g_free(packet); } + return 1; } diff --git a/net/queue.h b/net/queue.h index a31958e..4bf6d3c 100644 --- a/net/queue.h +++ b/net/queue.h @@ -66,6 +66,6 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue, NetPacketSent *sent_cb); void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from); -void qemu_net_queue_flush(NetQueue *queue); +bool qemu_net_queue_flush(NetQueue *queue); #endif /* QEMU_NET_QUEUE_H */