提交 53cdcc04 编写于 作者: J John Heffner 提交者: David S. Miller

[TCP]: Fix tcp_mem[] initialization.

Change tcp_mem initialization function.  The fraction of total memory
is now a continuous function of memory size, and independent of page
size.
Signed-off-by: NJohn Heffner <jheffner@psc.edu>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3e6b3b2e
...@@ -2458,11 +2458,18 @@ void __init tcp_init(void) ...@@ -2458,11 +2458,18 @@ void __init tcp_init(void)
sysctl_max_syn_backlog = 128; sysctl_max_syn_backlog = 128;
} }
/* Allow no more than 3/4 kernel memory (usually less) allocated to TCP */ /* Set the pressure threshold to be a fraction of global memory that
sysctl_tcp_mem[0] = (1536 / sizeof (struct inet_bind_hashbucket)) << order; * is up to 1/2 at 256 MB, decreasing toward zero with the amount of
sysctl_tcp_mem[1] = sysctl_tcp_mem[0] * 4 / 3; * memory, with a floor of 128 pages.
*/
limit = min(nr_all_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
limit = (limit * (nr_all_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
limit = max(limit, 128UL);
sysctl_tcp_mem[0] = limit / 4 * 3;
sysctl_tcp_mem[1] = limit;
sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2; sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;
/* Set per-socket limits to no more than 1/128 the pressure threshold */
limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7); limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
max_share = min(4UL*1024*1024, limit); max_share = min(4UL*1024*1024, limit);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册