diff options
author | Miquel van Smoorenburg <miquels@cistron.nl> | 2008-06-27 20:23:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-27 20:23:57 -0400 |
commit | 57413ebc4e0f1e471a3b4db4aff9a85c083d090e (patch) | |
tree | 325ee5d251700d991cea87d2c4d643b374959095 /net | |
parent | 479798211967cd828e09ce27775b8cbfe99462ab (diff) |
tcp: calculate tcp_mem based on low memory instead of all memory
The tcp_mem array which contains limits on the total amount of memory
used by TCP sockets is calculated based on nr_all_pages. On a 32 bits
x86 system, we should base this on the number of lowmem pages.
Signed-off-by: Miquel van Smoorenburg <miquels@cistron.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index fc54a48fde1e..850825dc86e6 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -260,6 +260,8 @@ | |||
260 | #include <linux/socket.h> | 260 | #include <linux/socket.h> |
261 | #include <linux/random.h> | 261 | #include <linux/random.h> |
262 | #include <linux/bootmem.h> | 262 | #include <linux/bootmem.h> |
263 | #include <linux/highmem.h> | ||
264 | #include <linux/swap.h> | ||
263 | #include <linux/cache.h> | 265 | #include <linux/cache.h> |
264 | #include <linux/err.h> | 266 | #include <linux/err.h> |
265 | #include <linux/crypto.h> | 267 | #include <linux/crypto.h> |
@@ -2620,7 +2622,7 @@ __setup("thash_entries=", set_thash_entries); | |||
2620 | void __init tcp_init(void) | 2622 | void __init tcp_init(void) |
2621 | { | 2623 | { |
2622 | struct sk_buff *skb = NULL; | 2624 | struct sk_buff *skb = NULL; |
2623 | unsigned long limit; | 2625 | unsigned long nr_pages, limit; |
2624 | int order, i, max_share; | 2626 | int order, i, max_share; |
2625 | 2627 | ||
2626 | BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); | 2628 | BUILD_BUG_ON(sizeof(struct tcp_skb_cb) > sizeof(skb->cb)); |
@@ -2689,8 +2691,9 @@ void __init tcp_init(void) | |||
2689 | * is up to 1/2 at 256 MB, decreasing toward zero with the amount of | 2691 | * is up to 1/2 at 256 MB, decreasing toward zero with the amount of |
2690 | * memory, with a floor of 128 pages. | 2692 | * memory, with a floor of 128 pages. |
2691 | */ | 2693 | */ |
2692 | limit = min(nr_all_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT); | 2694 | nr_pages = totalram_pages - totalhigh_pages; |
2693 | limit = (limit * (nr_all_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11); | 2695 | limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT); |
2696 | limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11); | ||
2694 | limit = max(limit, 128UL); | 2697 | limit = max(limit, 128UL); |
2695 | sysctl_tcp_mem[0] = limit / 4 * 3; | 2698 | sysctl_tcp_mem[0] = limit / 4 * 3; |
2696 | sysctl_tcp_mem[1] = limit; | 2699 | sysctl_tcp_mem[1] = limit; |