netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] udp: calculate udp_mem based on low memory instead of all memory
@ 2008-10-29  9:22 Eric Dumazet
  2008-10-29  9:32 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2008-10-29  9:22 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List, miquels

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]

While working on UDP, I found a comment in udp_init() was outdated.

This patch could help some 32bit machines, and restore comment validity :)

No hurry, so I based it on top of my previous patch (net-next-2.6)

Thanks

[PATCH] udp: calculate udp_mem based on low memory instead of all memory

This patch mimics commit 57413ebc4e0f1e471a3b4db4aff9a85c083d090e
(tcp: calculate tcp_mem based on low memory instead of all memory)

The udp_mem array which contains limits on the total amount of memory
used by UDP 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: Eric Dumazet <dada1@cosmosbay.com>


[-- Attachment #2: udp_mem.patch --]
[-- Type: text/plain, Size: 1185 bytes --]

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 5c1cbe1..eab6b36 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -81,6 +81,8 @@
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
 #include <linux/bootmem.h>
+#include <linux/highmem.h>
+#include <linux/swap.h>
 #include <linux/types.h>
 #include <linux/fcntl.h>
 #include <linux/module.h>
@@ -1751,15 +1753,16 @@ void __init udp_table_init(struct udp_table *table)
 
 void __init udp_init(void)
 {
-	unsigned long limit;
+	unsigned long nr_pages, limit;
 
 	udp_table_init(&udp_table);
 	/* Set the pressure threshold up by the same strategy of TCP. It is a
 	 * fraction of global memory that is up to 1/2 at 256 MB, decreasing
 	 * toward zero with the amount of 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);
+	nr_pages = totalram_pages - totalhigh_pages;
+	limit = min(nr_pages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
+	limit = (limit * (nr_pages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
 	limit = max(limit, 128UL);
 	sysctl_udp_mem[0] = limit / 4 * 3;
 	sysctl_udp_mem[1] = limit;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] udp: calculate udp_mem based on low memory instead of all memory
  2008-10-29  9:22 [PATCH] udp: calculate udp_mem based on low memory instead of all memory Eric Dumazet
@ 2008-10-29  9:32 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-10-29  9:32 UTC (permalink / raw)
  To: dada1; +Cc: netdev, miquels

From: Eric Dumazet <dada1@cosmosbay.com>
Date: Wed, 29 Oct 2008 10:22:16 +0100

> While working on UDP, I found a comment in udp_init() was outdated.
> 
> This patch could help some 32bit machines, and restore comment validity :)
> 
> No hurry, so I based it on top of my previous patch (net-next-2.6)

Thanks Eric, I'll apply this and also queue it up for submitting to
-stable at some point.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-29  9:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29  9:22 [PATCH] udp: calculate udp_mem based on low memory instead of all memory Eric Dumazet
2008-10-29  9:32 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).