netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 3/8] netpoll per device txq
Date: Thu, 26 Oct 2006 15:46:51 -0700	[thread overview]
Message-ID: <20061026225645.834331783@osdl.org> (raw)
In-Reply-To: 20061026225535.443288276@osdl.org

[-- Attachment #1: netpoll-per-dev.patch --]
[-- Type: text/plain, Size: 2990 bytes --]

When the netpoll beast got really busy, it tended to clog
things, so it stored them for later. But the beast was putting
all it's skb's in one basket. This was bad because maybe some
pipes were clogged and others were not.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
---
 include/linux/netpoll.h |    2 +
 net/core/netpoll.c      |   50 ++++++++++++++----------------------------------
 2 files changed, 17 insertions(+), 35 deletions(-)

--- linux-2.6.orig/include/linux/netpoll.h
+++ linux-2.6/include/linux/netpoll.h
@@ -33,6 +33,8 @@ struct netpoll_info {
 	spinlock_t rx_lock;
 	struct netpoll *rx_np; /* netpoll that registered an rx_hook */
 	struct sk_buff_head arp_tx; /* list of arp requests to reply to */
+	struct sk_buff_head txq;
+	struct work_struct tx_work;
 };
 
 void netpoll_poll(struct netpoll *np);
--- linux-2.6.orig/net/core/netpoll.c
+++ linux-2.6/net/core/netpoll.c
@@ -38,10 +38,6 @@
 
 static struct sk_buff_head skb_pool;
 
-static DEFINE_SPINLOCK(queue_lock);
-static int queue_depth;
-static struct sk_buff *queue_head, *queue_tail;
-
 static atomic_t trapped;
 
 #define NETPOLL_RX_ENABLED  1
@@ -56,46 +52,25 @@ static void arp_reply(struct sk_buff *sk
 
 static void queue_process(void *p)
 {
-	unsigned long flags;
+	struct netpoll_info *npinfo = p;
 	struct sk_buff *skb;
 
-	while (queue_head) {
-		spin_lock_irqsave(&queue_lock, flags);
-
-		skb = queue_head;
-		queue_head = skb->next;
-		if (skb == queue_tail)
-			queue_head = NULL;
-
-		queue_depth--;
-
-		spin_unlock_irqrestore(&queue_lock, flags);
-
+	while ((skb = skb_dequeue(&npinfo->txq)))
 		dev_queue_xmit(skb);
-	}
-}
 
-static DECLARE_WORK(send_queue, queue_process, NULL);
+}
 
 void netpoll_queue(struct sk_buff *skb)
 {
-	unsigned long flags;
+	struct net_device *dev = skb->dev;
+	struct netpoll_info *npinfo = dev->npinfo;
 
-	if (queue_depth == MAX_QUEUE_DEPTH) {
-		__kfree_skb(skb);
-		return;
+	if (!npinfo)
+		kfree_skb(skb);
+	else {
+		skb_queue_tail(&npinfo->txq, skb);
+		schedule_work(&npinfo->tx_work);
 	}
-
-	spin_lock_irqsave(&queue_lock, flags);
-	if (!queue_head)
-		queue_head = skb;
-	else
-		queue_tail->next = skb;
-	queue_tail = skb;
-	queue_depth++;
-	spin_unlock_irqrestore(&queue_lock, flags);
-
-	schedule_work(&send_queue);
 }
 
 static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
@@ -649,6 +624,9 @@ int netpoll_setup(struct netpoll *np)
 		npinfo->tries = MAX_RETRIES;
 		spin_lock_init(&npinfo->rx_lock);
 		skb_queue_head_init(&npinfo->arp_tx);
+		skb_queue_head_init(&npinfo->txq);
+		INIT_WORK(&npinfo->tx_work, queue_process, npinfo);
+
 		atomic_set(&npinfo->refcnt, 1);
 	} else {
 		npinfo = ndev->npinfo;
@@ -771,6 +749,8 @@ void netpoll_cleanup(struct netpoll *np)
 			np->dev->npinfo = NULL;
 			if (atomic_dec_and_test(&npinfo->refcnt)) {
 				skb_queue_purge(&npinfo->arp_tx);
+ 				skb_queue_purge(&npinfo->txq);
+ 				flush_scheduled_work();
 
 				kfree(npinfo);
 			}

--
Stephen Hemminger <shemminger@osdl.org>


  parent reply	other threads:[~2006-10-26 23:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26 22:46 [PATCH 0/8] netpoll: A Halloween horror mystery Stephen Hemminger
2006-10-26 22:46 ` [PATCH 1/8] netpoll: skb private pool management Stephen Hemminger
2006-10-27  0:12   ` David Miller
2006-10-27  1:04     ` Stephen Hemminger
2006-10-27  1:08       ` David Miller
2006-10-27  2:29         ` Stephen Hemminger
2006-11-14  1:00           ` David Miller
2006-11-14 21:55             ` netpoll patches Stephen Hemminger
2006-11-15  4:43               ` David Miller
2006-10-26 22:46 ` [PATCH 2/8] netpoll info leak Stephen Hemminger
2006-10-26 22:46 ` Stephen Hemminger [this message]
2006-10-26 22:46 ` [PATCH 4/8] netpoll setup error handling Stephen Hemminger
2006-10-26 22:46 ` [PATCH 5/8] netpoll deferred transmit path Stephen Hemminger
2006-10-26 22:46 ` [PATCH 6/8] netpoll retry cleanup Stephen Hemminger
2006-10-26 22:46 ` [PATCH 7/8] netpoll queue cleanup Stephen Hemminger
2006-10-26 22:46 ` [PATCH 8/8] netpoll header cleanup Stephen Hemminger

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=20061026225645.834331783@osdl.org \
    --to=shemminger@osdl.org \
    --cc=davem@davemloft.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).