aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorJohn Heffner <jheffner@psc.edu>2006-03-25 04:34:07 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-25 04:34:07 -0500
commit7b4f4b5ebceab67ce440a61081a69f0265e17c2a (patch)
treeac02c685ce23f2440fecbebaa5b55cd47947c03e /net/ipv4/tcp.c
parent2babf9daae4a3561f3264638a22ac7d0b14a6f52 (diff)
[TCP]: Set default max buffers from memory pool size
This patch sets the maximum TCP buffer sizes (available to automatic buffer tuning, not to setsockopt) based on the TCP memory pool size. The maximum sndbuf and rcvbuf each will be up to 4 MB, but no more than 1/128 of the memory pressure threshold. Signed-off-by: John Heffner <jheffner@psc.edu> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4b0272c92d66..591e96dffc28 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -276,8 +276,8 @@ atomic_t tcp_orphan_count = ATOMIC_INIT(0);
276EXPORT_SYMBOL_GPL(tcp_orphan_count); 276EXPORT_SYMBOL_GPL(tcp_orphan_count);
277 277
278int sysctl_tcp_mem[3]; 278int sysctl_tcp_mem[3];
279int sysctl_tcp_wmem[3] = { 4 * 1024, 16 * 1024, 128 * 1024 }; 279int sysctl_tcp_wmem[3];
280int sysctl_tcp_rmem[3] = { 4 * 1024, 87380, 87380 * 2 }; 280int sysctl_tcp_rmem[3];
281 281
282EXPORT_SYMBOL(sysctl_tcp_mem); 282EXPORT_SYMBOL(sysctl_tcp_mem);
283EXPORT_SYMBOL(sysctl_tcp_rmem); 283EXPORT_SYMBOL(sysctl_tcp_rmem);
@@ -2081,7 +2081,8 @@ __setup("thash_entries=", set_thash_entries);
2081void __init tcp_init(void) 2081void __init tcp_init(void)
2082{ 2082{
2083 struct sk_buff *skb = NULL; 2083 struct sk_buff *skb = NULL;
2084 int order, i; 2084 unsigned long limit;
2085 int order, i, max_share;
2085 2086
2086 if (sizeof(struct tcp_skb_cb) > sizeof(skb->cb)) 2087 if (sizeof(struct tcp_skb_cb) > sizeof(skb->cb))
2087 __skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb), 2088 __skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb),
@@ -2155,12 +2156,16 @@ void __init tcp_init(void)
2155 sysctl_tcp_mem[1] = 1024 << order; 2156 sysctl_tcp_mem[1] = 1024 << order;
2156 sysctl_tcp_mem[2] = 1536 << order; 2157 sysctl_tcp_mem[2] = 1536 << order;
2157 2158
2158 if (order < 3) { 2159 limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
2159 sysctl_tcp_wmem[2] = 64 * 1024; 2160 max_share = min(4UL*1024*1024, limit);
2160 sysctl_tcp_rmem[0] = PAGE_SIZE; 2161
2161 sysctl_tcp_rmem[1] = 43689; 2162 sysctl_tcp_wmem[0] = SK_STREAM_MEM_QUANTUM;
2162 sysctl_tcp_rmem[2] = 2 * 43689; 2163 sysctl_tcp_wmem[1] = 16*1024;
2163 } 2164 sysctl_tcp_wmem[2] = max(64*1024, max_share);
2165
2166 sysctl_tcp_rmem[0] = SK_STREAM_MEM_QUANTUM;
2167 sysctl_tcp_rmem[1] = 87380;
2168 sysctl_tcp_rmem[2] = max(87380, max_share);
2164 2169
2165 printk(KERN_INFO "TCP: Hash tables configured " 2170 printk(KERN_INFO "TCP: Hash tables configured "
2166 "(established %d bind %d)\n", 2171 "(established %d bind %d)\n",