summaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-02-09 23:54:09 +0100
committerRafael J. Wysocki <rjw@sisk.pl>2012-02-09 23:54:09 +0100
commit3ed3c7b559f3cae7a5a92860a127ceb0cafd5a9c (patch)
treec8ab8e608222f07edf46a42e6ec3cb27ac4ceaa0 /net/ipv4/tcp.c
parente470d06655e00749f6f9372e4fa4f20cea7ed7c5 (diff)
parentd020283dc694c9ec31b410f522252f7a8397e67d (diff)
downloadlinux-3ed3c7b559f3cae7a5a92860a127ceb0cafd5a9c.tar.gz
linux-3ed3c7b559f3cae7a5a92860a127ceb0cafd5a9c.tar.bz2
linux-3ed3c7b559f3cae7a5a92860a127ceb0cafd5a9c.zip
Merge commit 'pm-fixes-for-3.3-rc3' into pm-sleep
New material in the pm-sleep branch depends on recent power management fixes.
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)
}
__setup("thash_entries=", set_thash_entries);
+void tcp_init_mem(struct net *net)
+{
+ /* Set per-socket limits to no more than 1/128 the pressure threshold */
+ unsigned long limit = nr_free_buffer_pages() / 8;
+ limit = max(limit, 128UL);
+ net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3;
+ net->ipv4.sysctl_tcp_mem[1] = limit;
+ net->ipv4.sysctl_tcp_mem[2] = net->ipv4.sysctl_tcp_mem[0] * 2;
+}
+
void __init tcp_init(void)
{
struct sk_buff *skb = NULL;
@@ -3276,9 +3286,9 @@ void __init tcp_init(void)
sysctl_tcp_max_orphans = cnt / 2;
sysctl_max_syn_backlog = max(128, cnt / 256);
- /* Set per-socket limits to no more than 1/128 the pressure threshold */
- limit = ((unsigned long)init_net.ipv4.sysctl_tcp_mem[1])
- << (PAGE_SHIFT - 7);
+ tcp_init_mem(&init_net);
+ limit = nr_free_buffer_pages() / 8;
+ limit = max(limit, 128UL);
max_share = min(4UL*1024*1024, limit);
sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;