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.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 9bcdec3ad772..06373b4a449a 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3216,6 +3216,16 @@ static int __init set_thash_entries(char *str)
3216} 3216}
3217__setup("thash_entries=", set_thash_entries); 3217__setup("thash_entries=", set_thash_entries);
3218 3218
3219void tcp_init_mem(struct net *net)
3220{
3221 /* Set per-socket limits to no more than 1/128 the pressure threshold */
3222 unsigned long limit = nr_free_buffer_pages() / 8;
3223 limit = max(limit, 128UL);
3224 net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3;
3225 net->ipv4.sysctl_tcp_mem[1] = limit;
3226 net->ipv4.sysctl_tcp_mem[2] = net->ipv4.sysctl_tcp_mem[0] * 2;
3227}
3228
3219void __init tcp_init(void) 3229void __init tcp_init(void)
3220{ 3230{
3221 struct sk_buff *skb = NULL; 3231 struct sk_buff *skb = NULL;
@@ -3276,9 +3286,9 @@ void __init tcp_init(void)
3276 sysctl_tcp_max_orphans = cnt / 2; 3286 sysctl_tcp_max_orphans = cnt / 2;
3277 sysctl_max_syn_backlog = max(128, cnt / 256); 3287 sysctl_max_syn_backlog = max(128, cnt / 256);
3278 3288
3279 /* Set per-socket limits to no more than 1/128 the pressure threshold */ 3289 tcp_init_mem(&init_net);
3280 limit = ((unsigned long)init_net.ipv4.sysctl_tcp_mem[1]) 3290 limit = nr_free_buffer_pages() / 8;
3281 << (PAGE_SHIFT - 7); 3291 limit = max(limit, 128UL);
3282 max_share = min(4UL*1024*1024, limit); 3292 max_share = min(4UL*1024*1024, limit);
3283 3293
3284 sysctl_tcp_wmem[0] = SK_MEM_QUANTUM; 3294 sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;