diff options
author | Jason Wang <jasowang@redhat.com> | 2012-02-01 19:07:00 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-02 14:34:41 -0500 |
commit | c43b874d5d714f271b80d4c3f49e05d0cbf51ed2 (patch) | |
tree | c56f3500327b081228d4c7369d39740e9bb4a0a9 /net/ipv4/tcp.c | |
parent | 786f528119722f564a22ad953411374e06116333 (diff) |
tcp: properly initialize tcp memory limits
Commit 4acb4190 tries to fix the using uninitialized value
introduced by commit 3dc43e3, but it would make the
per-socket memory limits too small.
This patch fixes this and also remove the redundant codes
introduced in 4acb4190.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index a34f5cfdd44c..37755ccc0e96 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -3229,7 +3229,6 @@ __setup("thash_entries=", set_thash_entries); | |||
3229 | 3229 | ||
3230 | void tcp_init_mem(struct net *net) | 3230 | void tcp_init_mem(struct net *net) |
3231 | { | 3231 | { |
3232 | /* Set per-socket limits to no more than 1/128 the pressure threshold */ | ||
3233 | unsigned long limit = nr_free_buffer_pages() / 8; | 3232 | unsigned long limit = nr_free_buffer_pages() / 8; |
3234 | limit = max(limit, 128UL); | 3233 | limit = max(limit, 128UL); |
3235 | net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; | 3234 | net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; |
@@ -3298,7 +3297,8 @@ void __init tcp_init(void) | |||
3298 | sysctl_max_syn_backlog = max(128, cnt / 256); | 3297 | sysctl_max_syn_backlog = max(128, cnt / 256); |
3299 | 3298 | ||
3300 | tcp_init_mem(&init_net); | 3299 | tcp_init_mem(&init_net); |
3301 | limit = nr_free_buffer_pages() / 8; | 3300 | /* Set per-socket limits to no more than 1/128 the pressure threshold */ |
3301 | limit = nr_free_buffer_pages() << (PAGE_SHIFT - 10); | ||
3302 | limit = max(limit, 128UL); | 3302 | limit = max(limit, 128UL); |
3303 | max_share = min(4UL*1024*1024, limit); | 3303 | max_share = min(4UL*1024*1024, limit); |
3304 | 3304 | ||