netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dada1@cosmosbay.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 2/2] [IPV4] route: Dynamic hash table sizing.
Date: Wed, 09 Aug 2006 02:09:39 -0700 (PDT)	[thread overview]
Message-ID: <20060809.020939.106265428.davem@davemloft.net> (raw)
In-Reply-To: <200608091032.55232.dada1@cosmosbay.com>

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Wed, 9 Aug 2006 10:32:54 +0200

> On Wednesday 09 August 2006 09:53, David Miller wrote:
> > [IPV4] route: Dynamic hash table sizing.
> >
> 
>  Excellent work David, Thank you !!!

No problem.  It's much more productive than all the pure-talk that
usually occurs on these topics.

Here is a patch implementing fixes for the problems you found, thanks
for reviewing.

commit fc03f220a20f0fef0567e7427d0e06d234b98531
Author: David S. Miller <davem@sunset.davemloft.net>
Date:   Wed Aug 9 02:06:33 2006 -0700

    [IPV4] route: Fix 3 bugs in dynamic hash table code.
    
    All problems were spotted by Eric Dumazet.
    
    1) During rehashing, the hash function was wrong.
       It should "xor" in the iface number not "and" it.
    
    2) Mark ip_rt_hashsz_limit __read_mostly
    
    3) Instead of rejecting non-power-of-2 rhash_entries
       values, round them up just like the alloc_large_system_hash
       function was doing for us previously
    
    Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 897e67c..a9216e2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -123,7 +123,6 @@ #define RT_GC_TIMEOUT (300*HZ)
 static int ip_rt_min_delay		= 2 * HZ;
 static int ip_rt_max_delay		= 10 * HZ;
 static int ip_rt_max_size;
-static int ip_rt_hashsz_limit		= (8 * 1024 * 1024) / sizeof(void *);
 static int ip_rt_gc_timeout		= RT_GC_TIMEOUT;
 static int ip_rt_gc_interval		= 60 * HZ;
 static int ip_rt_gc_min_interval	= HZ / 2;
@@ -253,6 +252,8 @@ static seqlock_t rt_hash_seq __read_most
 static struct rt_hash_bucket 	*__rt_hash_table __read_mostly;
 static unsigned			__rt_hash_mask __read_mostly;
 static unsigned int		rt_hash_rnd __read_mostly;
+static int ip_rt_hashsz_limit __read_mostly =
+	(8 * 1024 * 1024) / sizeof(void *);
 
 static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
 #define RT_CACHE_STAT_INC(field) \
@@ -351,7 +352,7 @@ static void rtcache_transfer(struct rtab
 		if (!iface)
 			iface = list->fl.oif;
 		hash = __rt_hash_code(list->fl.fl4_dst,
-				      list->fl.fl4_src &
+				      list->fl.fl4_src ^
 				      (iface << 5),
 				      nhashmask);
 		ent = &new_table[hash];
@@ -3338,9 +3339,7 @@ static int __init set_rhash_entries(char
 		return 0;
 	val = simple_strtoul(str, &str, 0);
 
-	/* Only use it if it's a power-of-2. */
-	if (!(val & (val - 1)))
-		rhash_entries = val;
+	rhash_entries = roundup_pow_of_two(val);
 
 	return 1;
 }

  reply	other threads:[~2006-08-09  9:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09  7:49 [PATCHSET]: Dymamic route cache hash sizing David Miller
2006-08-09  7:53 ` [PATCH 1/2]: [IPV4] route: Locking infrastructure for dynamic routing cache sizing David Miller
2006-08-09 11:31   ` Herbert Xu
2006-08-09 23:05     ` David Miller
2006-08-09  7:53 ` [PATCH 2/2] [IPV4] route: Dynamic hash table sizing David Miller
2006-08-09  8:32   ` Eric Dumazet
2006-08-09  9:09     ` David Miller [this message]
2006-08-09 10:09   ` Eric Dumazet
2006-08-09 10:12     ` Michael Tokarev
2006-08-09 10:18       ` Evgeniy Polyakov
2006-08-09 11:14     ` David Miller
2006-08-15  8:35       ` 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=20060809.020939.106265428.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dada1@cosmosbay.com \
    --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).