From patchwork Fri May 29 14:16:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 27855 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 098EBB7066 for ; Sat, 30 May 2009 00:16:53 +1000 (EST) Received: by ozlabs.org (Postfix) id EE26DDDFAB; Sat, 30 May 2009 00:16:52 +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 6D641DDFAA for ; Sat, 30 May 2009 00:16:52 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758816AbZE2OQl (ORCPT ); Fri, 29 May 2009 10:16:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758637AbZE2OQl (ORCPT ); Fri, 29 May 2009 10:16:41 -0400 Received: from ozlabs.org ([203.10.76.45]:39005 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757538AbZE2OQk (ORCPT ); Fri, 29 May 2009 10:16:40 -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 26F45DDE16; Sat, 30 May 2009 00:16:41 +1000 (EST) From: Rusty Russell Date: Fri, 29 May 2009 23:46:37 +0930 To: netdev@vger.kernel.org Cc: virtualization@lists.linux-foundation.org, lguest@ozlabs.org CC: lguest@ozlabs.org Subject: [PATCH 4/4] lguest: don't force VIRTIO_F_NOTIFY_ON_EMPTY MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200905292346.38017.rusty@rustcorp.com.au> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org VIRTIO_F_NOTIFY_ON_EMPTY indicates to the Guest that we will hit them with an interrupt every time the xmit queue is emptied. Because it results in lots of tx interrupts, modern Guests probably don't want it, so let's only force it when they accept the option. Signed-off-by: Rusty Russell --- Documentation/lguest/lguest.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) -- 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 diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c --- a/Documentation/lguest/lguest.c +++ b/Documentation/lguest/lguest.c @@ -130,6 +130,9 @@ struct device /* Is it operational */ bool running; + /* Does Guest want an intrrupt on empty? */ + bool irq_on_empty; + /* Device-specific data. */ void *priv; }; @@ -569,11 +572,14 @@ static void trigger_irq(struct virtqueue return; vq->pending_used = 0; - /* If they don't want an interrupt, don't send one, unless empty. */ - if ((vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) - && lg_last_avail(vq) != vq->vring.avail->idx) { - (*vq->irq_suppressed)++; - return; + /* If they don't want an interrupt, don't send one... */ + if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) { + /* ... unless they've asked us to force one on empty. */ + if (!vq->dev->irq_on_empty || + lg_last_avail(vq) != vq->vring.avail->idx) { + (*vq->irq_suppressed)++; + return; + } } /* Send the Guest an interrupt tell them we used something up. */ @@ -925,6 +930,15 @@ static void create_thread(struct virtque close(vq->eventfd); } +static bool accepted_feature(struct device *dev, unsigned int bit) +{ + const u8 *features = get_feature_bits(dev) + dev->feature_len; + + if (dev->feature_len < bit / CHAR_BIT) + return false; + return features[bit / CHAR_BIT] & (1 << (bit % CHAR_BIT)); +} + static void start_device(struct device *dev) { unsigned int i; @@ -938,6 +952,8 @@ static void start_device(struct device * verbose(" %02x", get_feature_bits(dev) [dev->feature_len+i]); + dev->irq_on_empty = accepted_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY); + for (vq = dev->vq; vq; vq = vq->next) { if (vq->service) create_thread(vq);