netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@davemloft.net>
To: yoshfuji@linux-ipv6.org
Cc: laforge@gnumonks.org, netdev@oss.sgi.com
Subject: Re: [6/6]: jenkins hash for neigh
Date: Sat, 25 Sep 2004 01:30:36 -0700	[thread overview]
Message-ID: <20040925013036.76586445.davem@davemloft.net> (raw)
In-Reply-To: <20040925.172712.30172597.yoshfuji@linux-ipv6.org>

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

On Sat, 25 Sep 2004 17:27:12 +0900 (JST)
YOSHIFUJI Hideaki / ^[$B5HF#1QL@^[(B <yoshfuji@linux-ipv6.org> wrote:

> In article <20040925.171412.75484376.yoshfuji@linux-ipv6.org> (at Sat, 25 Sep 2004 17:14:12 +0900 (JST)), YOSHIFUJI Hideaki / ^[$B5HF#1QL@^[(B <yoshfuji@linux-ipv6.org> says:
> 
> > In article <20040925005623.2faf8faf.davem@davemloft.net> (at Sat, 25 Sep 2004 00:56:23 -0700), "David S. Miller" <davem@davemloft.net> says:
> > 
> > 
> > > +			if (n->nud_state -= NUD_INCOMPLETE &&
> > 
> > I guess this is typo of:
> > 			if (n->nud_state == NUD_INCOMPLETE &&
> > 
> > Am I wrong?
> 
> Sorry, I forgot to state the source; this lives in diff4.

Good catch, you are correct.

Fixed version attached.

[-- Attachment #2: diff4 --]
[-- Type: application/octet-stream, Size: 2379 bytes --]

===== net/core/neighbour.c 1.47 vs edited =====
--- 1.47/net/core/neighbour.c	2004-09-24 16:21:49 -07:00
+++ edited/net/core/neighbour.c	2004-09-25 01:11:47 -07:00
@@ -110,13 +110,13 @@
 	return (net_random() % base) + (base >> 1);
 }
 
-
-static int neigh_forced_gc(struct neigh_table *tbl)
+static int neigh_forced_gc(struct neigh_table *tbl, int goal)
 {
-	int shrunk = 0;
+	int shrunk = 0, num_incomplete = 0, reap_incomplete = 0;
 	int i;
 
 	write_lock_bh(&tbl->lock);
+rescan:
 	for (i = 0; i <= tbl->hash_mask; i++) {
 		struct neighbour *n, **np;
 
@@ -125,30 +125,46 @@
 			/* Neighbour record may be discarded if:
 			   - nobody refers to it.
 			   - it is not permanent
-			   - (NEW and probably wrong)
+			   - On the first pass of this scan,
 			     INCOMPLETE entries are kept at least for
 			     n->parms->retrans_time, otherwise we could
 			     flood network with resolution requests.
-			     It is not clear, what is better table overflow
-			     or flooding.
 			 */
 			write_lock(&n->lock);
-			if (atomic_read(&n->refcnt) == 1 &&
-			    !(n->nud_state & NUD_PERMANENT) &&
-			    (n->nud_state != NUD_INCOMPLETE ||
-			     time_after(jiffies, n->used + n->parms->retrans_time))) {
-				*np	= n->next;
-				n->dead = 1;
-				shrunk	= 1;
-				write_unlock(&n->lock);
-				neigh_release(n);
-				continue;
+			if (atomic_read(&n->refcnt) != 1)
+				goto next_ent;
+
+			if (n->nud_state & NUD_PERMANENT)
+				goto next_ent;
+
+			if (n->nud_state == NUD_INCOMPLETE &&
+			    reap_incomplete == 0 &&
+			    time_after(jiffies,
+				       n->used + n->parms->retrans_time)) {
+				num_incomplete++;
+				goto next_ent;
 			}
+
+			*np	= n->next;
+			n->dead = 1;
+			shrunk++;
+			write_unlock(&n->lock);
+			neigh_release(n);
+			continue;
+
+		next_ent:
 			write_unlock(&n->lock);
 			np = &n->next;
 		}
 	}
 
+	if (reap_incomplete == 0 &&
+	    shrunk < goal &&
+	    (shrunk + num_incomplete) >= goal) {
+		reap_incomplete = 1;
+		goto rescan;
+	}
+
 	tbl->last_flush = jiffies;
 
 	write_unlock_bh(&tbl->lock);
@@ -261,7 +277,9 @@
 	if (tbl->entries > tbl->gc_thresh3 ||
 	    (tbl->entries > tbl->gc_thresh2 &&
 	     time_after(now, tbl->last_flush + 5 * HZ))) {
-		if (!neigh_forced_gc(tbl) &&
+		int goal = tbl->entries - tbl->gc_thresh3;
+
+		if (!neigh_forced_gc(tbl, goal) &&
 		    tbl->entries > tbl->gc_thresh3)
 			goto out;
 	}

  reply	other threads:[~2004-09-25  8:30 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-24  5:51 [6/6]: jenkins hash for neigh David S. Miller
2004-09-24  8:52 ` Harald Welte
2004-09-24 21:27   ` David S. Miller
2004-09-25  6:44     ` Harald Welte
2004-09-25  7:56       ` David S. Miller
2004-09-25  8:14         ` YOSHIFUJI Hideaki / 吉藤英明
2004-09-25  8:27           ` YOSHIFUJI Hideaki / 吉藤英明
2004-09-25  8:30             ` David S. Miller [this message]
2004-09-25  9:09         ` Harald Welte
2004-09-25 13:33           ` Steven Whitehouse
2004-09-26  0:48             ` David S. Miller
2004-09-26  3:31           ` David S. Miller
2004-09-26 11:21             ` Thomas Graf
2004-09-27  9:29           ` Harald Welte
2004-09-27 18:57             ` David S. Miller
2004-09-26 10:11         ` YOSHIFUJI Hideaki / 吉藤英明
2004-09-27 11:43         ` Herbert Xu
2004-09-27 19:12           ` David S. Miller
2004-09-27 11:48         ` Herbert Xu
2004-09-27 18:15           ` David S. Miller
2004-09-27 21:41             ` Herbert Xu
2004-09-27 22:00               ` Herbert Xu
2004-10-02  7:50             ` Herbert Xu
2004-10-03 21:55               ` David S. Miller
2004-09-27 11:56         ` Herbert Xu
2004-09-27 19:14           ` David S. Miller
2004-09-27 22:26             ` [6/6]: jenkins hash for neigh / Statistics Harald Welte
2004-09-27 23:06               ` David S. Miller
2004-09-27 23:27                 ` Stephen Hemminger
2004-09-28  8:44                   ` Robert Olsson
2004-09-28 11:19                     ` [PATCH 2.6] generic network statistics (was Re: [6/6]: jenkins hash for neigh / Statistics) Harald Welte
2004-09-28 12:48                       ` jamal
2004-09-28 13:33                         ` Thomas Graf
2004-09-29  2:22                           ` jamal
2004-09-28 14:22                         ` Robert Olsson
2004-09-29  2:16                           ` jamal
2004-09-28 14:55                       ` Harald Welte
2004-09-28 15:17                         ` Robert Olsson
2004-09-28 16:24                           ` Harald Welte
2004-09-28 21:43                       ` David S. Miller
2004-09-29  8:04                         ` Harald Welte
2004-09-28 16:27                     ` [6/6]: jenkins hash for neigh / Statistics Stephen Hemminger
2004-09-28 17:06                       ` Harald Welte

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=20040925013036.76586445.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=laforge@gnumonks.org \
    --cc=netdev@oss.sgi.com \
    --cc=yoshfuji@linux-ipv6.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).