From patchwork Mon May 18 12:48:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 27359 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 40C36B7069 for ; Mon, 18 May 2009 22:49:01 +1000 (EST) Received: by ozlabs.org (Postfix) id 30AADDE090; Mon, 18 May 2009 22:49:01 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 96966DE066 for ; Mon, 18 May 2009 22:49:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751403AbZERMsw (ORCPT ); Mon, 18 May 2009 08:48:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751218AbZERMsw (ORCPT ); Mon, 18 May 2009 08:48:52 -0400 Received: from ozlabs.org ([203.10.76.45]:42998 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750946AbZERMsv (ORCPT ); Mon, 18 May 2009 08:48:51 -0400 Received: from vivaldi.localnet (unknown [150.101.102.135]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id C9B15DE00F; Mon, 18 May 2009 22:48:52 +1000 (EST) From: Rusty Russell To: netdev@vger.kernel.org Subject: [RFC] virtio: orphan skbs if we're relying on timer to free them Date: Mon, 18 May 2009 22:18:47 +0930 User-Agent: KMail/1.11.2 (Linux/2.6.28-11-generic; KDE/4.2.2; i686; ; ) Cc: virtualization@lists.linux-foundation.org MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200905182218.47975.rusty@rustcorp.com.au> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We check for finished xmit skbs on every xmit, or on a timer (unless the host promises to force an interrupt when the xmit ring is empty). This can penalize userspace tasks which fill their sockbuf. Not much --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html difference with TSO, but measurable with large numbers of packets. There are a finite number of packets which can be in the transmission queue. We could fire the timer more than every 100ms, but that would just hurt performance for a corner case. This seems neatest. With interrupt when Tx ring empty: Seconds TxPkts TxIRQs 1G TCP Guest->Host: 3.76 32833 32758 1M normal pings: 111 1000008 997463 1M 1k pings (-l 120): 55 1000007 488920 Without interrupt, without orphaning: 1G TCP Guest->Host: 3.64 32806 1 1M normal pings: 106 1000008 1 1M 1k pings (-l 120): 68 1000005 1 With orphaning: 1G TCP Guest->Host: 3.86 32821 1 1M normal pings: 102 1000007 1 1M 1k pings (-l 120): 43 1000005 1 Signed-off-by: Rusty Russell --- drivers/net/virtio_net.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -522,6 +522,11 @@ static int start_xmit(struct sk_buff *sk { struct virtnet_info *vi = netdev_priv(dev); + /* We queue a limited number; don't let that delay writers if + * we are slow in getting tx interrupt. */ + if (!vi->free_in_tasklet) + skb_orphan(skb); + again: /* Free up any pending old buffers before queueing new ones. */ free_old_xmit_skbs(vi);