svn commit: r241735 - head/sys/netinet
Andrey Zonov
zont at FreeBSD.org
Fri Oct 19 14:00:04 UTC 2012
Author: zont
Date: Fri Oct 19 14:00:03 2012
New Revision: 241735
URL: http://svn.freebsd.org/changeset/base/241735
Log:
- Update cachelimit after hashsize and bucketlimit were set.
Reported by: az
Reviewed by: melifaro
Approved by: kib (mentor)
MFC after: 1 week
Modified:
head/sys/netinet/tcp_hostcache.c
Modified: head/sys/netinet/tcp_hostcache.c
==============================================================================
--- head/sys/netinet/tcp_hostcache.c Fri Oct 19 13:32:37 2012 (r241734)
+++ head/sys/netinet/tcp_hostcache.c Fri Oct 19 14:00:03 2012 (r241735)
@@ -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.
*/
More information about the svn-src-all
mailing list