aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohn Heffner <jheffner@psc.edu>2007-03-16 18:04:03 -0400
committerDavid S. Miller <davem@davemloft.net>2007-03-16 18:04:03 -0400
commit53cdcc04c1e85d4e423b2822b66149b6f2e52c2c (patch)
tree7a4072113c88b00f28e75dbcee3e8e803c44d79b /net
parent3e6b3b2e34ac2c72fa05b5e4b20bd88d64c298dc (diff)
[TCP]: Fix tcp_mem[] initialization.
Change tcp_mem initialization function. The fraction of total memory is now a continuous function of memory size, and independent of page size. Signed-off-by: John Heffner <jheffner@psc.edu> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 74c4d103ebc2..3834b10b5115 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2458,11 +2458,18 @@ void __init tcp_init(void)
2458 sysctl_max_syn_backlog = 128; 2458 sysctl_max_syn_backlog = 128;
2459 } 2459 }
2460 2460
2461 /* Allow no more than 3/4 kernel memory (usually less) allocated to TCP */ 2461 /* Set the pressure threshold to be a fraction of global memory that
2462 sysctl_tcp_mem[0] = (1536 / sizeof (struct inet_bind_hashbucket)) << order; 2462 * is up to 1/2 at 256 MB, decreasing toward zero with the amount of
2463 sysctl_tcp_mem[1] = sysctl_tcp_mem[0] * 4 / 3; 2463 * memory, with a floor of 128 pages.
2464 */
2465 limit = min(nr_all_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
2466 limit = (limit * (nr_all_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
2467 limit = max(limit, 128UL);
2468 sysctl_tcp_mem[0] = limit / 4 * 3;
2469 sysctl_tcp_mem[1] = limit;
2464 sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2; 2470 sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;
2465 2471
2472 /* Set per-socket limits to no more than 1/128 the pressure threshold */
2466 limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7); 2473 limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
2467 max_share = min(4UL*1024*1024, limit); 2474 max_share = min(4UL*1024*1024, limit);
2468 2475