Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Oct 2012 21:04:13 +0000 (UTC)
From:      Andrey Zonov <zont@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r242375 - stable/9/sys/netinet
Message-ID:  <201210302104.q9UL4DTZ075546@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zont
Date: Tue Oct 30 21:04:12 2012
New Revision: 242375
URL: http://svn.freebsd.org/changeset/base/242375

Log:
  MFC r241735:
  - Update cachelimit after hashsize and bucketlimit were set.
  
  Approved by:	kib (mentor)

Modified:
  stable/9/sys/netinet/tcp_hostcache.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/tcp_hostcache.c
==============================================================================
--- stable/9/sys/netinet/tcp_hostcache.c	Tue Oct 30 21:00:46 2012	(r242374)
+++ stable/9/sys/netinet/tcp_hostcache.c	Tue Oct 30 21:04:12 2012	(r242375)
@@ -174,6 +174,7 @@ static MALLOC_DEFINE(M_HOSTCACHE, "hostc
 void
 tcp_hc_init(void)
 {
+	u_int cache_limit;
 	int i;
 
 	/*
@@ -182,23 +183,27 @@ tcp_hc_init(void)
 	V_tcp_hostcache.cache_count = 0;
 	V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE;
 	V_tcp_hostcache.bucket_limit = TCP_HOSTCACHE_BUCKETLIMIT;
-	V_tcp_hostcache.cache_limit =
-	    V_tcp_hostcache.hashsize * V_tcp_hostcache.bucket_limit;
 	V_tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE;
 	V_tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE;
 
 	TUNABLE_INT_FETCH("net.inet.tcp.hostcache.hashsize",
 	    &V_tcp_hostcache.hashsize);
-	TUNABLE_INT_FETCH("net.inet.tcp.hostcache.cachelimit",
-	    &V_tcp_hostcache.cache_limit);
-	TUNABLE_INT_FETCH("net.inet.tcp.hostcache.bucketlimit",
-	    &V_tcp_hostcache.bucket_limit);
 	if (!powerof2(V_tcp_hostcache.hashsize)) {
 		printf("WARNING: hostcache hash size is not a power of 2.\n");
 		V_tcp_hostcache.hashsize = TCP_HOSTCACHE_HASHSIZE; /* default */
 	}
 	V_tcp_hostcache.hashmask = V_tcp_hostcache.hashsize - 1;
 
+	TUNABLE_INT_FETCH("net.inet.tcp.hostcache.bucketlimit",
+	    &V_tcp_hostcache.bucket_limit);
+
+	cache_limit = V_tcp_hostcache.hashsize * V_tcp_hostcache.bucket_limit;
+	V_tcp_hostcache.cache_limit = cache_limit;
+	TUNABLE_INT_FETCH("net.inet.tcp.hostcache.cachelimit",
+	    &V_tcp_hostcache.cache_limit);
+	if (V_tcp_hostcache.cache_limit > cache_limit)
+		V_tcp_hostcache.cache_limit = cache_limit;
+
 	/*
 	 * Allocate the hash table.
 	 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210302104.q9UL4DTZ075546>