From patchwork Fri Sep 19 13:07:55 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarek Poplawski X-Patchwork-Id: 619 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org 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 70E8CDDFCE for ; Fri, 19 Sep 2008 23:08:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752694AbYISNIL (ORCPT ); Fri, 19 Sep 2008 09:08:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752660AbYISNIL (ORCPT ); Fri, 19 Sep 2008 09:08:11 -0400 Received: from fg-out-1718.google.com ([72.14.220.156]:33915 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752082AbYISNIJ (ORCPT ); Fri, 19 Sep 2008 09:08:09 -0400 Received: by fg-out-1718.google.com with SMTP id 19so560667fgg.17 for ; Fri, 19 Sep 2008 06:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=iq65ttgXk6rCtbLXeHzK7qnqeU1Sug/RPq/zlxLw7tg=; b=XEmFr83WVwSQ68TmB8L9Mz8gCMcGW4Li6naFEGuc/q2hTEkZ9x1/UMeEeTaPgZ5yaz dug+yuCnuM2FCHlZf/+yicYyF0oKglxVWhR0n6HwZAL4E2f+I9DU19wNDMCRf0sak2VE dkBYk3tfvXyvLgLpKnOFoaFsWVBlJwLueOXzw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=iam7tq+vICa0Km9rDvjOCKyTXupUY5RyPqMfwH5QrQrPuK5nnkOPxgn1e0m5YqcqkJ 5SNq60fmHu0mucejoUA2bk7ZBGERyS3kWbz1x5YDiSS1aEBpcKi5G99cdrju6Ppf5y+/ BF4K0b+pBaYvIxCkMHNkvb5jYmJKxx/r6YoRg= Received: by 10.86.80.17 with SMTP id d17mr1894006fgb.47.1221829687511; Fri, 19 Sep 2008 06:08:07 -0700 (PDT) Received: from ff.dom.local (bv170.internetdsl.tpnet.pl [80.53.205.170]) by mx.google.com with ESMTPS id 12sm95879fgg.0.2008.09.19.06.07.59 (version=SSLv3 cipher=RC4-MD5); Fri, 19 Sep 2008 06:08:03 -0700 (PDT) Date: Fri, 19 Sep 2008 13:07:55 +0000 From: Jarek Poplawski To: David Miller Cc: Alexander Duyck , Alexander Duyck , netdev@vger.kernel.org, herbert@gondor.apana.org.au, kaber@trash.net Subject: [PATCH] pkt_sched: Fix TX state checking in qdisc_run() Message-ID: <20080919130755.GA13578@ff.dom.local> References: <20080918063036.27934.91273.stgit@localhost.localdomain> <20080918194419.GA2982@ami.dom.local> <5f2db9d90809181811q74c3211fp9a099acb8e895fd4@mail.gmail.com> <20080919103225.GB9135@ff.dom.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20080919103225.GB9135@ff.dom.local> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org pkt_sched: Fix TX state checking in qdisc_run() Current check wrongly uses the state of the first tx queue for all tx queues. This patch brings back per dev __LINK_STATE_XOFF flag, which is set when all tx queues are stopped. This check is needed in qdisc_run() to avoid useless __netif_schedule() calls. Signed-off-by: Jarek Poplawski diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 488c56e..dc76e4b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -271,6 +271,7 @@ struct header_ops { enum netdev_state_t { + __LINK_STATE_XOFF, __LINK_STATE_START, __LINK_STATE_PRESENT, __LINK_STATE_NOCARRIER, @@ -1043,6 +1044,7 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue) static inline void netif_wake_queue(struct net_device *dev) { netif_tx_wake_queue(netdev_get_tx_queue(dev, 0)); + clear_bit(__LINK_STATE_XOFF, &dev->state); } static inline void netif_tx_wake_all_queues(struct net_device *dev) @@ -1053,6 +1055,7 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev) struct netdev_queue *txq = netdev_get_tx_queue(dev, i); netif_tx_wake_queue(txq); } + clear_bit(__LINK_STATE_XOFF, &dev->state); } static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) @@ -1069,6 +1072,7 @@ static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) */ static inline void netif_stop_queue(struct net_device *dev) { + set_bit(__LINK_STATE_XOFF, &dev->state); netif_tx_stop_queue(netdev_get_tx_queue(dev, 0)); } @@ -1076,6 +1080,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev) { unsigned int i; + set_bit(__LINK_STATE_XOFF, &dev->state); for (i = 0; i < dev->num_tx_queues; i++) { struct netdev_queue *txq = netdev_get_tx_queue(dev, i); netif_tx_stop_queue(txq); @@ -1095,7 +1100,7 @@ static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) */ static inline int netif_queue_stopped(const struct net_device *dev) { - return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); + return test_bit(__LINK_STATE_XOFF, &dev->state); } static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue) diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index b786a5b..1718a60 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h @@ -90,9 +90,7 @@ extern void __qdisc_run(struct Qdisc *q); static inline void qdisc_run(struct Qdisc *q) { - struct netdev_queue *txq = q->dev_queue; - - if (!netif_tx_queue_stopped(txq) && + if (!netif_queue_stopped(qdisc_dev(q)) && !test_and_set_bit(__QDISC_STATE_RUNNING, &q->state)) __qdisc_run(q); }