From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail191.messagelabs.com (mail191.messagelabs.com [216.82.242.19]) by kanga.kvack.org (Postfix) with ESMTP id 6AF2E6B004A for ; Thu, 2 Sep 2010 08:28:57 -0400 (EDT) Message-Id: <4C7FB4A40200007800013F30@vpn.id2.novell.com> Date: Thu, 02 Sep 2010 13:28:52 +0100 From: "Jan Beulich" Subject: [PATCH] use total_highpages when calculating lowmem-only allocation sizes Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: owner-linux-mm@kvack.org To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org List-ID: For those (large) table allocations that come only from lowmem, the total amount of memory shouldn't really matter. vfs_caches_init() should really also be called with a lowmem-only value, but since it does arithmetic involving nr_free_pages() and there is no nr_free_high_pages(), it's not clear how to make this work. Signed-off-by: Jan Beulich --- init/main.c | 3 ++- net/dccp/proto.c | 8 +++++--- net/decnet/dn_route.c | 3 ++- net/netfilter/nf_conntrack_core.c | 7 +++++-- net/netlink/af_netlink.c | 8 +++++--- net/sctp/protocol.c | 6 +++--- 6 files changed, 22 insertions(+), 13 deletions(-) --- linux-2.6.36-rc3/init/main.c +++ 2.6.36-rc3-use-totalhigh_pages/init/main.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -676,7 +677,7 @@ asmlinkage void __init start_kernel(void #endif thread_info_cache_init(); cred_init(); - fork_init(totalram_pages); + fork_init(totalram_pages - totalhigh_pages); proc_caches_init(); buffer_init(); key_init(); --- linux-2.6.36-rc3/net/dccp/proto.c +++ 2.6.36-rc3-use-totalhigh_pages/net/dccp/proto.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -1049,10 +1050,11 @@ static int __init dccp_init(void) * * The methodology is similar to that of the buffer cache. */ - if (totalram_pages >=3D (128 * 1024)) - goal =3D totalram_pages >> (21 - PAGE_SHIFT); + goal =3D totalram_pages - totalhigh_pages; + if (goal >=3D (128 * 1024)) + goal >>=3D 21 - PAGE_SHIFT; else - goal =3D totalram_pages >> (23 - PAGE_SHIFT); + goal >>=3D 23 - PAGE_SHIFT; =20 if (thash_entries) goal =3D (thash_entries * --- linux-2.6.36-rc3/net/decnet/dn_route.c +++ 2.6.36-rc3-use-totalhigh_pages/net/decnet/dn_route.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -1762,7 +1763,7 @@ void __init dn_route_init(void) dn_route_timer.expires =3D jiffies + decnet_dst_gc_interval * HZ; add_timer(&dn_route_timer); =20 - goal =3D totalram_pages >> (26 - PAGE_SHIFT); + goal =3D (totalram_pages - totalhigh_pages) >> (26 - PAGE_SHIFT); =20 for(order =3D 0; (1UL << order) < goal; order++) /* NOTHING */; --- linux-2.6.36-rc3/net/netfilter/nf_conntrack_core.c +++ 2.6.36-rc3-use-totalhigh_pages/net/netfilter/nf_conntrack_core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -1346,10 +1347,12 @@ static int nf_conntrack_init_init_net(vo /* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB * machine has 512 buckets. >=3D 1GB machines have 16384 buckets. = */ if (!nf_conntrack_htable_size) { + unsigned long nr_pages =3D totalram_pages - totalhigh_pages= ; + nf_conntrack_htable_size - =3D (((totalram_pages << PAGE_SHIFT) / 16384) + =3D (((nr_pages << PAGE_SHIFT) / 16384) / sizeof(struct hlist_head)); - if (totalram_pages > (1024 * 1024 * 1024 / PAGE_SIZE)) + if (nr_pages > (1024 * 1024 * 1024 / PAGE_SIZE)) nf_conntrack_htable_size =3D 16384; if (nf_conntrack_htable_size < 32) nf_conntrack_htable_size =3D 32; --- linux-2.6.36-rc3/net/netlink/af_netlink.c +++ 2.6.36-rc3-use-totalhigh_pages/net/netlink/af_netlink.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -2124,10 +2125,11 @@ static int __init netlink_proto_init(voi if (!nl_table) goto panic; =20 - if (totalram_pages >=3D (128 * 1024)) - limit =3D totalram_pages >> (21 - PAGE_SHIFT); + limit =3D totalram_pages - totalhigh_pages; + if (limit >=3D (128 * 1024)) + limit >>=3D 21 - PAGE_SHIFT; else - limit =3D totalram_pages >> (23 - PAGE_SHIFT); + limit >>=3D 23 - PAGE_SHIFT; =20 order =3D get_bitmask_order(limit) - 1 + PAGE_SHIFT; limit =3D (1UL << order) / sizeof(struct hlist_head); --- linux-2.6.36-rc3/net/sctp/protocol.c +++ 2.6.36-rc3-use-totalhigh_pages/net/sctp/protocol.c @@ -1189,10 +1189,10 @@ SCTP_STATIC __init int sctp_init(void) /* Size and allocate the association hash table. * The methodology is similar to that of the tcp hash tables. */ - if (totalram_pages >=3D (128 * 1024)) - goal =3D totalram_pages >> (22 - PAGE_SHIFT); + if (nr_pages >=3D (128 * 1024)) + goal =3D nr_pages >> (22 - PAGE_SHIFT); else - goal =3D totalram_pages >> (24 - PAGE_SHIFT); + goal =3D nr_pages >> (24 - PAGE_SHIFT); =20 for (order =3D 0; (1UL << order) < goal; order++) ; -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org