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, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] netpoll: use skb_buff_head for skb cache
Date: Thu, 19 Oct 2006 10:15:44 -0700	[thread overview]
Message-ID: <20061019171814.497048492@osdl.org> (raw)
In-Reply-To: 20061019171541.062261760@osdl.org

[-- Attachment #1: netpoll-freelist.patch --]
[-- Type: text/plain, Size: 2842 bytes --]

The private skb cache should be managed with normal skb_buff_head rather
than a DIY queue. If pool is exhausted, don't print anything that just
makes the problem worse. After a number of attempts, punt and drop
the message (callers handle it already).

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

---
 net/core/netpoll.c |   55 +++++++++++++++++++++--------------------------------
 1 file changed, 22 insertions(+), 33 deletions(-)

--- linux-2.6.orig/net/core/netpoll.c	2006-10-19 09:49:03.000000000 -0700
+++ linux-2.6/net/core/netpoll.c	2006-10-19 10:06:39.000000000 -0700
@@ -36,9 +36,7 @@
 #define MAX_QUEUE_DEPTH (MAX_SKBS / 2)
 #define MAX_RETRIES 20000
 
-static DEFINE_SPINLOCK(skb_list_lock);
-static int nr_skbs;
-static struct sk_buff *skbs;
+static struct sk_buff_head skb_list;
 
 static atomic_t trapped;
 
@@ -51,6 +49,7 @@
 
 static void zap_completion_queue(void);
 static void arp_reply(struct sk_buff *skb);
+static void refill_skbs(void);
 
 static void netpoll_run(unsigned long arg)
 {
@@ -79,6 +78,7 @@
 			break;
 		}
 	}
+	refill_skbs();
 }
 
 static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
@@ -169,19 +169,14 @@
 static void refill_skbs(void)
 {
 	struct sk_buff *skb;
-	unsigned long flags;
 
-	spin_lock_irqsave(&skb_list_lock, flags);
-	while (nr_skbs < MAX_SKBS) {
+	while (skb_queue_len(&skb_list) < MAX_SKBS) {
 		skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC);
 		if (!skb)
 			break;
 
-		skb->next = skbs;
-		skbs = skb;
-		nr_skbs++;
+		skb_queue_tail(&skb_list, skb);
 	}
-	spin_unlock_irqrestore(&skb_list_lock, flags);
 }
 
 static void zap_completion_queue(void)
@@ -210,37 +205,24 @@
 	put_cpu_var(softnet_data);
 }
 
-static struct sk_buff * find_skb(struct netpoll *np, int len, int reserve)
+static struct sk_buff *find_skb(struct netpoll *np, int len, int reserve)
 {
-	int once = 1, count = 0;
-	unsigned long flags;
-	struct sk_buff *skb = NULL;
+	struct sk_buff *skb;
+	int tries = 0;
 
 	zap_completion_queue();
-repeat:
-	if (nr_skbs < MAX_SKBS)
-		refill_skbs();
 
+repeat:
 	skb = alloc_skb(len, GFP_ATOMIC);
-
-	if (!skb) {
-		spin_lock_irqsave(&skb_list_lock, flags);
-		skb = skbs;
-		if (skb) {
-			skbs = skb->next;
-			skb->next = NULL;
-			nr_skbs--;
-		}
-		spin_unlock_irqrestore(&skb_list_lock, flags);
-	}
+	if (!skb)
+		skb = skb_dequeue(&skb_list);
 
 	if(!skb) {
-		count++;
-		if (once && (count == 1000000)) {
-			printk("out of netpoll skbs!\n");
-			once = 0;
-		}
+		if (++tries > MAX_RETRIES)
+			return NULL;
+
 		netpoll_poll(np);
+		tasklet_schedule(&np->dev->npinfo->tx_task);
 		goto repeat;
 	}
 
@@ -589,6 +571,13 @@
 	return -1;
 }
 
+static __init int netpoll_init(void)
+{
+	skb_queue_head_init(&skb_list);
+	return 0;
+}
+core_initcall(netpoll_init);
+
 int netpoll_setup(struct netpoll *np)
 {
 	struct net_device *ndev = NULL;

--

  parent reply	other threads:[~2006-10-19 17:15 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-19 17:15 [PATCH 0/3] netpoll/netconsole fixes Stephen Hemminger
2006-10-19 17:15 ` [PATCH 1/3] netpoll: initialize skb for UDP Stephen Hemminger
2006-10-20  6:58   ` David Miller
2006-10-19 17:15 ` [PATCH 2/3] netpoll: rework skb transmit queue Stephen Hemminger
2006-10-20  7:15   ` David Miller
2006-10-20 15:18     ` Stephen Hemminger
2006-10-20 19:24       ` David Miller
2006-10-20 19:25         ` Stephen Hemminger
2006-10-20 19:52           ` David Miller
2006-10-20 20:14             ` Stephen Hemminger
2006-10-20 20:25             ` Stephen Hemminger
2006-10-21  5:00               ` Dave Jones
2006-10-21  6:38                 ` David Miller
2006-10-20 15:40     ` Stephen Hemminger
2006-10-20 19:27       ` David Miller
2006-10-20 19:31         ` Stephen Hemminger
2006-10-20 20:42       ` David Miller
2006-10-20 20:48         ` Stephen Hemminger
2006-10-20 21:01           ` Andi Kleen
2006-10-20 21:08             ` David Miller
2006-10-20 21:16               ` Andi Kleen
2006-10-20 21:41                 ` Stephen Hemminger
2006-10-20 21:01           ` David Miller
2006-10-20 22:30             ` [PATCH 1/3] netpoll: use sk_buff_head for txq Stephen Hemminger
2006-10-23  3:42               ` David Miller
2006-10-23 19:02                 ` [PATCH 1/5] " Stephen Hemminger
2006-10-23 19:04                   ` [PATCH 5/5] netpoll: interface cleanup Stephen Hemminger
2006-10-24  6:03                   ` [PATCH 1/5] netpoll: use sk_buff_head for txq David Miller
2006-10-24 14:51                     ` Stephen Hemminger
     [not found]                 ` <20061023115111.0d69846e@dxpl.pdx.osdl.net>
2006-10-23 19:02                   ` [PATCH 2/5] netpoll: cleanup queued transmit Stephen Hemminger
     [not found]                 ` <20061023115337.1f636ffb@dxpl.pdx.osdl.net>
2006-10-23 19:02                   ` [PATCH 4/5] netpoll: move drop hook inline Stephen Hemminger
2006-10-23 19:03                   ` [PATCH 3/5] netpoll: cleanup transmit retry logic Stephen Hemminger
2006-10-20 22:32             ` [PATCH 2/3] netpoll: use device xmit directly Stephen Hemminger
2006-10-20 22:35             ` [PATCH 3/3] netpoll: retry logic cleanup Stephen Hemminger
2006-10-19 17:15 ` Stephen Hemminger [this message]
2006-10-20  6:57 ` [PATCH 0/3] netpoll/netconsole fixes Andrew Morton
2006-10-20  7:16   ` David Miller

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=20061019171814.497048492@osdl.org \
    --to=shemminger@osdl.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --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).