From patchwork Mon Feb 25 09:17:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 222872 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 425DE2C02AB for ; Mon, 25 Feb 2013 20:17:39 +1100 (EST) Received: from localhost ([::1]:43939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9uBl-0003UF-8x for incoming@patchwork.ozlabs.org; Mon, 25 Feb 2013 04:17:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9uBX-0003SS-Po for qemu-devel@nongnu.org; Mon, 25 Feb 2013 04:17:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9uBK-0002A2-9V for qemu-devel@nongnu.org; Mon, 25 Feb 2013 04:17:23 -0500 Received: from ssl.dlhnet.de ([91.198.192.8]:51587 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9uBK-00029T-2D for qemu-devel@nongnu.org; Mon, 25 Feb 2013 04:17:10 -0500 Received: from localhost (localhost [127.0.0.1]) by ssl.dlh.net (Postfix) with ESMTP id 1910014D7F8; Mon, 25 Feb 2013 10:17:09 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ssl.dlh.net Received: from ssl.dlh.net ([127.0.0.1]) by localhost (ssl.dlh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gkmO+TKt6ewj; Mon, 25 Feb 2013 10:17:08 +0100 (CET) Received: from [172.21.12.60] (unknown [82.141.1.226]) by ssl.dlh.net (Postfix) with ESMTPSA id BA5D414BD1A; Mon, 25 Feb 2013 10:17:08 +0100 (CET) Message-ID: <512B2C14.2010108@dlhnet.de> Date: Mon, 25 Feb 2013 10:17:08 +0100 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: qemu-devel@nongnu.org References: <20121123110146.GC7051@redhat.com> <50FE5607.9020405@dlhnet.de> <20130123100312.GA8108@redhat.com> <5119E9DC.3000505@dlhnet.de> <20130212090850.GB22029@redhat.com> <056542E4-18E4-4C9F-AC96-60661768D6AF@dlhnet.de> <511A0DBB.7080907@msgid.tls.msk.ru> <20130212095422.GA23270@redhat.com> <20130212104331.GA23495@redhat.com> In-Reply-To: <20130212104331.GA23495@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.198.192.8 Cc: Stefan Hajnoczi , Michael Tokarev , Christian Borntraeger , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCHv3] tap: set IFF_ONE_QUEUE per default 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 historically the kernel queues packets two times. once at the device and second in qdisc. this is believed to cause interface stalls if one of these queues overruns. setting IFF_ONE_QUEUE is the default in kernels >= 3.8. the flag is ignored since then. see kernel commit 5d097109257c03a71845729f8db6b5770c4bbedc v3: - probe if IFF_ONE_QUEUE feature is available v2: - do only set the flag on linux as it breaks macvtap - define IFF_ONE_QUEUE in tap-linux.h Signed-off-by: Peter Lieven Acked-by: Michael S. Tsirkin --- net/tap-linux.c | 10 ++++++---- net/tap-linux.h | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/net/tap-linux.c b/net/tap-linux.c index a953189..36c09e2 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -42,6 +42,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, struct ifreq ifr; int fd, ret; int len = sizeof(struct virtio_net_hdr); + unsigned int features; TFR(fd = open(PATH_NET_TUN, O_RDWR)); if (fd < 0) { @@ -51,9 +52,12 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; - if (*vnet_hdr) { - unsigned int features; + if (ioctl(fd, TUNGETFEATURES, &features) == 0 && + features & IFF_ONE_QUEUE) { + ifr.ifr_flags |= IFF_ONE_QUEUE; + } + if (*vnet_hdr) { if (ioctl(fd, TUNGETFEATURES, &features) == 0 && features & IFF_VNET_HDR) { *vnet_hdr = 1; @@ -78,8 +82,6 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, } if (mq_required) { - unsigned int features; - if ((ioctl(fd, TUNGETFEATURES, &features) != 0) || !(features & IFF_MULTI_QUEUE)) { error_report("multiqueue required, but no kernel " diff --git a/net/tap-linux.h b/net/tap-linux.h index 65087e1..5704efb 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -34,10 +34,11 @@ #endif /* TUNSETIFF ifr flags */ -#define IFF_TAP 0x0002 -#define IFF_NO_PI 0x1000 -#define IFF_VNET_HDR 0x4000 -#define IFF_MULTI_QUEUE 0x0100 +#define IFF_TAP 0x0002 +#define IFF_NO_PI 0x1000 +#define IFF_ONE_QUEUE 0x2000 +#define IFF_VNET_HDR 0x4000 +#define IFF_MULTI_QUEUE 0x0100 #define IFF_ATTACH_QUEUE 0x0200 #define IFF_DETACH_QUEUE 0x0400