aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp.c')
-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