Re: [PATCH] set default max TCP buffers from memory pool size

2006-03-25 Thread David S. Miller
From: Rick Jones [EMAIL PROTECTED]
Date: Fri, 24 Mar 2006 09:45:51 -0800

 Stephen Hemminger wrote:
  We should also tag tcp_rmem/tcp_wmem as __read_mostly
 
 That would apply to just about all the tcp sysctl's yes?

Yes, absolutely.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] set default max TCP buffers from memory pool size

2006-03-25 Thread David S. Miller
From: John Heffner [EMAIL PROTECTED]
Date: Fri, 24 Mar 2006 11:47:29 -0500

 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 [EMAIL PROTECTED]

Applied.

I made a minor modification, I calculated the max_shared thing using
unsigned long as the type for the max() calculation.  With the
shifts, the second argument perhaps could get shifted so high as to
become zero with large enough parameters on 64-bit and large
PAGE_SIZE.

Maybe it doesn't matter, but I felt safer doing it this way.
:-)

Thanks.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] set default max TCP buffers from memory pool size

2006-03-25 Thread David S. Miller
From: Stephen Hemminger [EMAIL PROTECTED]
Date: Fri, 24 Mar 2006 09:23:27 -0800

 We should also tag tcp_rmem/tcp_wmem as __read_mostly

I've done this, thanks for the suggestion.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] set default max TCP buffers from memory pool size

2006-03-24 Thread John Heffner
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 [EMAIL PROTECTED]

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4b0272c..b7dc697 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -276,8 +276,8 @@ atomic_t tcp_orphan_count = ATOMIC_INIT(
 EXPORT_SYMBOL_GPL(tcp_orphan_count);
 
 int sysctl_tcp_mem[3];
-int sysctl_tcp_wmem[3] = { 4 * 1024, 16 * 1024, 128 * 1024 };
-int sysctl_tcp_rmem[3] = { 4 * 1024, 87380, 87380 * 2 };
+int sysctl_tcp_wmem[3];
+int sysctl_tcp_rmem[3];
 
 EXPORT_SYMBOL(sysctl_tcp_mem);
 EXPORT_SYMBOL(sysctl_tcp_rmem);
@@ -2081,7 +2081,7 @@ __setup(thash_entries=, set_thash_entr
 void __init tcp_init(void)
 {
 	struct sk_buff *skb = NULL;
-	int order, i;
+	int order, i, max_share;
 
 	if (sizeof(struct tcp_skb_cb)  sizeof(skb-cb))
 		__skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb),
@@ -2154,13 +2154,16 @@ void __init tcp_init(void)
 	sysctl_tcp_mem[0] =  768  order;
 	sysctl_tcp_mem[1] = 1024  order;
 	sysctl_tcp_mem[2] = 1536  order;
-
-	if (order  3) {
-		sysctl_tcp_wmem[2] = 64 * 1024;
-		sysctl_tcp_rmem[0] = PAGE_SIZE;
-		sysctl_tcp_rmem[1] = 43689;
-		sysctl_tcp_rmem[2] = 2 * 43689;
-	}
+	
+	max_share = min(4*1024*1024, sysctl_tcp_mem[1]  (PAGE_SHIFT - 7));
+	
+	sysctl_tcp_wmem[0] = SK_STREAM_MEM_QUANTUM;
+	sysctl_tcp_wmem[1] = 16*1024;
+	sysctl_tcp_wmem[2] = max(64*1024, max_share);
+	
+	sysctl_tcp_rmem[0] = SK_STREAM_MEM_QUANTUM;
+	sysctl_tcp_rmem[1] = 87380;
+	sysctl_tcp_rmem[2] = max(87380, max_share);
 
 	printk(KERN_INFO TCP: Hash tables configured 
 	   (established %d bind %d)\n,


Re: [PATCH] set default max TCP buffers from memory pool size

2006-03-24 Thread Stephen Hemminger
On Fri, 24 Mar 2006 11:47:29 -0500
John Heffner [EMAIL PROTECTED] wrote:

 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 [EMAIL PROTECTED]
 

We should also tag tcp_rmem/tcp_wmem as __read_mostly
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] set default max TCP buffers from memory pool size

2006-03-24 Thread Rick Jones

Stephen Hemminger wrote:

On Fri, 24 Mar 2006 11:47:29 -0500
John Heffner [EMAIL PROTECTED] wrote:


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 [EMAIL PROTECTED]



We should also tag tcp_rmem/tcp_wmem as __read_mostly


That would apply to just about all the tcp sysctl's yes?

rick jones
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html