All of lore.kernel.org
 help / color / mirror / Atom feed
From: Changli Gao <xiaosuo@gmail.com>
To: jamal <hadi@cyberus.ca>
Cc: netdev@vger.kernel.org, jamal <hadi@cyberus.ca>,
	Changli Gao <xiaosuo@gmail.com>
Subject: [PATCH 3/3] ifb: move tq from ifb_private
Date: Sat,  4 Dec 2010 13:55:21 +0800	[thread overview]
Message-ID: <1291442121-3302-3-git-send-email-xiaosuo@gmail.com> (raw)
In-Reply-To: <1291442121-3302-1-git-send-email-xiaosuo@gmail.com>

tq is only used in ri_tasklet, so we move it from ifb_private to a
stack variable of ri_tasklet.

skb_queue_splice_tail_init() is used instead of the open coded and slow
one.

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
 drivers/net/ifb.c |   49 ++++++++++++-------------------------------------
 1 file changed, 12 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index d1e362a..cd6e90d 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -39,9 +39,7 @@
 #define TX_Q_LIMIT    32
 struct ifb_private {
 	struct tasklet_struct   ifb_tasklet;
-	int     tasklet_pending;
 	struct sk_buff_head     rq;
-	struct sk_buff_head     tq;
 };
 
 static int numifbs = 2;
@@ -53,27 +51,25 @@ static int ifb_close(struct net_device *dev);
 
 static void ri_tasklet(unsigned long dev)
 {
-
 	struct net_device *_dev = (struct net_device *)dev;
 	struct ifb_private *dp = netdev_priv(_dev);
 	struct net_device_stats *stats = &_dev->stats;
 	struct netdev_queue *txq;
 	struct sk_buff *skb;
+	struct sk_buff_head tq;
 
+	__skb_queue_head_init(&tq);
 	txq = netdev_get_tx_queue(_dev, 0);
-	if ((skb = skb_peek(&dp->tq)) == NULL) {
-		if (__netif_tx_trylock(txq)) {
-			while ((skb = skb_dequeue(&dp->rq)) != NULL) {
-				skb_queue_tail(&dp->tq, skb);
-			}
-			__netif_tx_unlock(txq);
-		} else {
-			/* reschedule */
-			goto resched;
-		}
+	if (!__netif_tx_trylock(txq)) {
+		tasklet_schedule(&dp->ifb_tasklet);
+		return;
 	}
+	skb_queue_splice_tail_init(&dp->rq, &tq);
+	if (netif_tx_queue_stopped(txq))
+		netif_tx_wake_queue(txq);
+	__netif_tx_unlock(txq);
 
-	while ((skb = skb_dequeue(&dp->tq)) != NULL) {
+	while ((skb = __skb_dequeue(&tq)) != NULL) {
 		u32 from = G_TC_FROM(skb->tc_verd);
 
 		skb->tc_verd = 0;
@@ -87,7 +83,7 @@ static void ri_tasklet(unsigned long dev)
 			rcu_read_unlock();
 			dev_kfree_skb(skb);
 			stats->tx_dropped++;
-			break;
+			continue;
 		}
 		rcu_read_unlock();
 		skb->skb_iif = _dev->ifindex;
@@ -100,23 +96,6 @@ static void ri_tasklet(unsigned long dev)
 		} else
 			BUG();
 	}
-
-	if (__netif_tx_trylock(txq)) {
-		if ((skb = skb_peek(&dp->rq)) == NULL) {
-			dp->tasklet_pending = 0;
-			if (netif_queue_stopped(_dev))
-				netif_wake_queue(_dev);
-		} else {
-			__netif_tx_unlock(txq);
-			goto resched;
-		}
-		__netif_tx_unlock(txq);
-	} else {
-resched:
-		dp->tasklet_pending = 1;
-		tasklet_schedule(&dp->ifb_tasklet);
-	}
-
 }
 
 static const struct net_device_ops ifb_netdev_ops = {
@@ -162,10 +141,8 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	skb_queue_tail(&dp->rq, skb);
-	if (!dp->tasklet_pending) {
-		dp->tasklet_pending = 1;
+	if (skb_queue_len(&dp->rq) == 1)
 		tasklet_schedule(&dp->ifb_tasklet);
-	}
 
 	return NETDEV_TX_OK;
 }
@@ -177,7 +154,6 @@ static int ifb_close(struct net_device *dev)
 	tasklet_kill(&dp->ifb_tasklet);
 	netif_stop_queue(dev);
 	skb_queue_purge(&dp->rq);
-	skb_queue_purge(&dp->tq);
 	return 0;
 }
 
@@ -187,7 +163,6 @@ static int ifb_open(struct net_device *dev)
 
 	tasklet_init(&dp->ifb_tasklet, ri_tasklet, (unsigned long)dev);
 	skb_queue_head_init(&dp->rq);
-	skb_queue_head_init(&dp->tq);
 	netif_start_queue(dev);
 
 	return 0;

  parent reply	other threads:[~2010-12-04  5:56 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04  5:55 [PATCH 1/3] ifb: remove the useless debug stats Changli Gao
2010-12-04  5:55 ` [PATCH 2/3] ifb: remove unused macro TX_TIMEOUT Changli Gao
2010-12-04 14:13   ` jamal
2010-12-04  5:55 ` Changli Gao [this message]
2010-12-04 13:15   ` [PATCH 3/3] ifb: move tq from ifb_private Jarek Poplawski
2010-12-04 13:29     ` Changli Gao
2010-12-04 14:28     ` jamal
2010-12-04 14:45       ` Changli Gao
2010-12-04 14:55         ` jamal
2010-12-04 15:01           ` Changli Gao
2010-12-04 15:09             ` jamal
2010-12-04 14:48       ` jamal
2010-12-04 15:40         ` Jarek Poplawski
2010-12-04 16:08           ` jamal
2010-12-04 16:56             ` Jarek Poplawski
2010-12-05  0:22               ` Changli Gao
2010-12-05  1:13                 ` Changli Gao
2010-12-05 14:30                   ` jamal
2010-12-05 14:40                     ` Changli Gao
2010-12-05 15:13                       ` Eric Dumazet
2010-12-05 15:16                         ` Changli Gao
2010-12-05 15:13                       ` jamal
2010-12-05 15:22                         ` Changli Gao
2010-12-05 15:31                           ` jamal
2010-12-05 14:27                 ` jamal
2010-12-05 19:09                   ` Jarek Poplawski
2010-12-04 14:18   ` jamal
2010-12-04 14:20     ` Changli Gao
2010-12-04 14:42     ` jamal
2010-12-04 14:50       ` Changli Gao
2010-12-04 14:59         ` jamal
2010-12-04 15:07           ` Changli Gao
2010-12-04 15:11             ` jamal
2010-12-04 14:12 ` [PATCH 1/3] ifb: remove the useless debug stats jamal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291442121-3302-3-git-send-email-xiaosuo@gmail.com \
    --to=xiaosuo@gmail.com \
    --cc=hadi@cyberus.ca \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.