fix up sysctl_tcp_mem initialization
Subsystems (3)
PATCH 1/1 fix up sysctl_tcp_mem initialization
The initial values of sysctl_tcp_mem are sometimes greater than the total memory in the system (particularly on SMP systems). This patch ensures that tcp_mem[2] is always <= 3/4 nr_kernel_pages.
However, I wonder if we want to set this differently than the way this patch does it. Depending on how far off the memory size is from a power of two (exactly equal to a power of two is the worst case), and if total memory <128M, it can be substantially less than 3/4.
-John
Fix up tcp_mem initiail settings to take into account the size of the hash entries (different on SMP and non-SMP systems).
---
commit d4ef8c8245c0a033622ce9ba9e25d379475254f6
tree 5377b8af0bac3b92161188e7369a84e472b5acb2
parent ea55b7c31b47edf90132baea9a088da3bbe2bb5c
author John Heffner <[email protected]> Tue, 14 Nov 2006 14:53:27 -0500 committer John Heffner <[email protected]> Tue, 14 Nov 2006 14:53:27 -0500
net/ipv4/tcp.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
net/ipv4/tcp.c +4 -3
@@ -2316,9 +2316,10 @@ void __init tcp_init(void) sysctl_max_syn_backlog =128 ; } - sysctl_tcp_mem[0 ] =768 << order; - sysctl_tcp_mem[1 ] =1024 << order; - sysctl_tcp_mem[2 ] =1536 << order; +/* Allow no more than 3/4 kernel memory (usually less) allocated to TCP */ + sysctl_tcp_mem[0 ] = (1536 /sizeof (struct inet_bind_hashbucket )) << order; + sysctl_tcp_mem[1 ] = sysctl_tcp_mem[0 ] *4 /3 ; + sysctl_tcp_mem[2 ] = sysctl_tcp_mem[0 ] *2 ; limit = ((unsigned long )sysctl_tcp_mem[1 ]) << (PAGE_SHIFT -7 ); max_share =min (4UL *1024 *1024 , limit);
David Miller
maintainerFrom: John Heffner <[email protected]>
Date: Tue, 14 Nov 2006 15:02:05 -0500
Quoted 3 lines
The initial values of
sysctl_tcp_memare sometimes greater than the total memory in the system (particularly on SMP systems). This patch ensures that tcp_mem[2] is always <= 3/4nr_kernel_pages.
This is a genuine bug fix so I'll apply this, thanks for taking care of these corner-case bugs in TCP sizing Jeff.
Quoted 4 lines
However, I wonder if we want to set this differently than the way this patch does it. Depending on how far off the memory size is from a power of two (exactly equal to a power of two is the worst case), and if total memory <128M, it can be substantially less than 3/4.
Longer term, yes, probably a better way exists.
So you concern is that when we round to a power of 2 like we do now, we often mis-shoot?
Quoted 6 lines · David Miller
Quoted 1 line
However, I wonder if we want to set this differently than the way this patch does it. Depending on how far off the memory size is from a power of two (exactly equal to a power of two is the worst case), and if total memory <128M, it can be substantially less than 3/4.
Longer term, yes, probably a better way exists.
So you concern is that when we round to a power of 2 like we do now, we often mis-shoot?
I'm not that concerned about it, but basically yes, there are big (x2) jumps on power-of-two memory size boundaries. There's also a bigger (x8) discontinuity at 128k pages. It could be smoother.
-John