diff mbox

use total_highpages when calculating lowmem-only allocation sizes (dccp)

Message ID 4CFD2096020000780002627B@vpn.id2.novell.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Jan Beulich Dec. 6, 2010, 4:42 p.m. UTC
For those (large) table allocations that come only from lowmem, the
total amount of memory shouldn't really matter.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

---
 net/dccp/proto.c                  |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)




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

Comments

David Miller Dec. 6, 2010, 5:36 p.m. UTC | #1
From: "Jan Beulich" <JBeulich@novell.com>
Date: Mon, 06 Dec 2010 16:42:46 +0000

> For those (large) table allocations that come only from lowmem, the
> total amount of memory shouldn't really matter.
> 
> Signed-off-by: Jan Beulich <jbeulich@novell.com>

Instead of continually tweaking the bits in these code paths,
we should be converting them over to using a central routine
such as alloc_large_system_hash() where the logic is consolidated
_AND_ the code knows to use vmalloc() and NUMA aware allocations
when warranted.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Beulich Dec. 7, 2010, 2:38 p.m. UTC | #2
>>> On 06.12.10 at 18:36, David Miller <davem@davemloft.net> wrote:
> From: "Jan Beulich" <JBeulich@novell.com>
> Date: Mon, 06 Dec 2010 16:42:46 +0000
> 
>> For those (large) table allocations that come only from lowmem, the
>> total amount of memory shouldn't really matter.
>> 
>> Signed-off-by: Jan Beulich <jbeulich@novell.com>
> 
> Instead of continually tweaking the bits in these code paths,
> we should be converting them over to using a central routine
> such as alloc_large_system_hash() where the logic is consolidated
> _AND_ the code knows to use vmalloc() and NUMA aware allocations
> when warranted.

Hmm, not sure. For one, alloc_large_system_hash() is (and imo
ought to remain) an __init function. Second, looking at the one
non-modular case (netlink_proto_init()), I don't think using this
function would be the intention here.

Jan

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Dec. 8, 2010, 12:49 a.m. UTC | #3
From: "Jan Beulich" <JBeulich@novell.com>
Date: Tue, 07 Dec 2010 14:38:21 +0000

>>>> On 06.12.10 at 18:36, David Miller <davem@davemloft.net> wrote:
>> From: "Jan Beulich" <JBeulich@novell.com>
>> Date: Mon, 06 Dec 2010 16:42:46 +0000
>> 
>>> For those (large) table allocations that come only from lowmem, the
>>> total amount of memory shouldn't really matter.
>>> 
>>> Signed-off-by: Jan Beulich <jbeulich@novell.com>
>> 
>> Instead of continually tweaking the bits in these code paths,
>> we should be converting them over to using a central routine
>> such as alloc_large_system_hash() where the logic is consolidated
>> _AND_ the code knows to use vmalloc() and NUMA aware allocations
>> when warranted.
> 
> Hmm, not sure. For one, alloc_large_system_hash() is (and imo
> ought to remain) an __init function. Second, looking at the one
> non-modular case (netlink_proto_init()), I don't think using this
> function would be the intention here.

I think the one and only reason DCCP and friends do not use this
interface is exactly because it's not available to modules.

So much (partially incorrect, as you found) code would be removed
if this common routine were exported and utilized.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

--- linux-2.6.37-rc4/net/dccp/proto.c
+++ 2.6.37-rc4-use-totalhigh_pages/net/dccp/proto.c
@@ -14,6 +14,7 @@ 
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
+#include <linux/highmem.h>
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/in.h>
@@ -1068,10 +1069,11 @@  static int __init dccp_init(void)
 	 *
 	 * The methodology is similar to that of the buffer cache.
 	 */
-	if (totalram_pages >= (128 * 1024))
-		goal = totalram_pages >> (21 - PAGE_SHIFT);
+	goal = totalram_pages - totalhigh_pages;
+	if (goal >= (128 * 1024))
+		goal >>= 21 - PAGE_SHIFT;
 	else
-		goal = totalram_pages >> (23 - PAGE_SHIFT);
+		goal >>= 23 - PAGE_SHIFT;
 
 	if (thash_entries)
 		goal = (thash_entries *