diff options
author | Jan Beulich <JBeulich@novell.com> | 2009-09-21 20:03:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:38 -0400 |
commit | 4481374ce88ba8f460c8b89f2572027bd27057d0 (patch) | |
tree | 6896601b6a1da0e3e932ffa75fcff966c834c02c /net | |
parent | 4738e1b9cf8f9e28d7de080a5e6ce5d0095ea18f (diff) |
mm: replace various uses of num_physpages by totalram_pages
Sizing of memory allocations shouldn't depend on the number of physical
pages found in a system, as that generally includes (perhaps a huge amount
of) non-RAM pages. The amount of what actually is usable as storage
should instead be used as a basis here.
Some of the calculations (i.e. those not intending to use high memory)
should likely even use (totalram_pages - totalhigh_pages).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Dave Airlie <airlied@linux.ie>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Patrick McHardy <kaber@trash.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock.c | 4 | ||||
-rw-r--r-- | net/dccp/proto.c | 6 | ||||
-rw-r--r-- | net/decnet/dn_route.c | 2 | ||||
-rw-r--r-- | net/ipv4/route.c | 2 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 4 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 4 | ||||
-rw-r--r-- | net/netfilter/x_tables.c | 2 | ||||
-rw-r--r-- | net/netfilter/xt_hashlimit.c | 8 | ||||
-rw-r--r-- | net/netlink/af_netlink.c | 6 | ||||
-rw-r--r-- | net/sctp/protocol.c | 6 |
10 files changed, 22 insertions, 22 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 30d5446512f9..524712a7b154 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -1206,12 +1206,12 @@ EXPORT_SYMBOL_GPL(sk_setup_caps); | |||
1206 | 1206 | ||
1207 | void __init sk_init(void) | 1207 | void __init sk_init(void) |
1208 | { | 1208 | { |
1209 | if (num_physpages <= 4096) { | 1209 | if (totalram_pages <= 4096) { |
1210 | sysctl_wmem_max = 32767; | 1210 | sysctl_wmem_max = 32767; |
1211 | sysctl_rmem_max = 32767; | 1211 | sysctl_rmem_max = 32767; |
1212 | sysctl_wmem_default = 32767; | 1212 | sysctl_wmem_default = 32767; |
1213 | sysctl_rmem_default = 32767; | 1213 | sysctl_rmem_default = 32767; |
1214 | } else if (num_physpages >= 131072) { | 1214 | } else if (totalram_pages >= 131072) { |
1215 | sysctl_wmem_max = 131071; | 1215 | sysctl_wmem_max = 131071; |
1216 | sysctl_rmem_max = 131071; | 1216 | sysctl_rmem_max = 131071; |
1217 | } | 1217 | } |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 923db06c7e55..bc4467082a00 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -1049,10 +1049,10 @@ static int __init dccp_init(void) | |||
1049 | * | 1049 | * |
1050 | * The methodology is similar to that of the buffer cache. | 1050 | * The methodology is similar to that of the buffer cache. |
1051 | */ | 1051 | */ |
1052 | if (num_physpages >= (128 * 1024)) | 1052 | if (totalram_pages >= (128 * 1024)) |
1053 | goal = num_physpages >> (21 - PAGE_SHIFT); | 1053 | goal = totalram_pages >> (21 - PAGE_SHIFT); |
1054 | else | 1054 | else |
1055 | goal = num_physpages >> (23 - PAGE_SHIFT); | 1055 | goal = totalram_pages >> (23 - PAGE_SHIFT); |
1056 | 1056 | ||
1057 | if (thash_entries) | 1057 | if (thash_entries) |
1058 | goal = (thash_entries * | 1058 | goal = (thash_entries * |
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index 9383d3e5a1ab..57662cabaf9b 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c | |||
@@ -1750,7 +1750,7 @@ void __init dn_route_init(void) | |||
1750 | dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ; | 1750 | dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ; |
1751 | add_timer(&dn_route_timer); | 1751 | add_timer(&dn_route_timer); |
1752 | 1752 | ||
1753 | goal = num_physpages >> (26 - PAGE_SHIFT); | 1753 | goal = totalram_pages >> (26 - PAGE_SHIFT); |
1754 | 1754 | ||
1755 | for(order = 0; (1UL << order) < goal; order++) | 1755 | for(order = 0; (1UL << order) < goal; order++) |
1756 | /* NOTHING */; | 1756 | /* NOTHING */; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 91867d3e6328..df9347314538 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -3414,7 +3414,7 @@ int __init ip_rt_init(void) | |||
3414 | alloc_large_system_hash("IP route cache", | 3414 | alloc_large_system_hash("IP route cache", |
3415 | sizeof(struct rt_hash_bucket), | 3415 | sizeof(struct rt_hash_bucket), |
3416 | rhash_entries, | 3416 | rhash_entries, |
3417 | (num_physpages >= 128 * 1024) ? | 3417 | (totalram_pages >= 128 * 1024) ? |
3418 | 15 : 17, | 3418 | 15 : 17, |
3419 | 0, | 3419 | 0, |
3420 | &rt_hash_log, | 3420 | &rt_hash_log, |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 19a0612b8a20..21387ebabf00 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2862,7 +2862,7 @@ void __init tcp_init(void) | |||
2862 | alloc_large_system_hash("TCP established", | 2862 | alloc_large_system_hash("TCP established", |
2863 | sizeof(struct inet_ehash_bucket), | 2863 | sizeof(struct inet_ehash_bucket), |
2864 | thash_entries, | 2864 | thash_entries, |
2865 | (num_physpages >= 128 * 1024) ? | 2865 | (totalram_pages >= 128 * 1024) ? |
2866 | 13 : 15, | 2866 | 13 : 15, |
2867 | 0, | 2867 | 0, |
2868 | &tcp_hashinfo.ehash_size, | 2868 | &tcp_hashinfo.ehash_size, |
@@ -2879,7 +2879,7 @@ void __init tcp_init(void) | |||
2879 | alloc_large_system_hash("TCP bind", | 2879 | alloc_large_system_hash("TCP bind", |
2880 | sizeof(struct inet_bind_hashbucket), | 2880 | sizeof(struct inet_bind_hashbucket), |
2881 | tcp_hashinfo.ehash_size, | 2881 | tcp_hashinfo.ehash_size, |
2882 | (num_physpages >= 128 * 1024) ? | 2882 | (totalram_pages >= 128 * 1024) ? |
2883 | 13 : 15, | 2883 | 13 : 15, |
2884 | 0, | 2884 | 0, |
2885 | &tcp_hashinfo.bhash_size, | 2885 | &tcp_hashinfo.bhash_size, |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index b37109817a98..7c9ec3dee96e 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -1245,9 +1245,9 @@ static int nf_conntrack_init_init_net(void) | |||
1245 | * machine has 512 buckets. >= 1GB machines have 16384 buckets. */ | 1245 | * machine has 512 buckets. >= 1GB machines have 16384 buckets. */ |
1246 | if (!nf_conntrack_htable_size) { | 1246 | if (!nf_conntrack_htable_size) { |
1247 | nf_conntrack_htable_size | 1247 | nf_conntrack_htable_size |
1248 | = (((num_physpages << PAGE_SHIFT) / 16384) | 1248 | = (((totalram_pages << PAGE_SHIFT) / 16384) |
1249 | / sizeof(struct hlist_head)); | 1249 | / sizeof(struct hlist_head)); |
1250 | if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE)) | 1250 | if (totalram_pages > (1024 * 1024 * 1024 / PAGE_SIZE)) |
1251 | nf_conntrack_htable_size = 16384; | 1251 | nf_conntrack_htable_size = 16384; |
1252 | if (nf_conntrack_htable_size < 32) | 1252 | if (nf_conntrack_htable_size < 32) |
1253 | nf_conntrack_htable_size = 32; | 1253 | nf_conntrack_htable_size = 32; |
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index a6ac83a93348..f01955cce314 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
@@ -617,7 +617,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) | |||
617 | int cpu; | 617 | int cpu; |
618 | 618 | ||
619 | /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ | 619 | /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ |
620 | if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > num_physpages) | 620 | if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages) |
621 | return NULL; | 621 | return NULL; |
622 | 622 | ||
623 | newinfo = kzalloc(XT_TABLE_INFO_SZ, GFP_KERNEL); | 623 | newinfo = kzalloc(XT_TABLE_INFO_SZ, GFP_KERNEL); |
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 219dcdbe388c..dd16e404424f 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c | |||
@@ -194,9 +194,9 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, u_int8_t family) | |||
194 | if (minfo->cfg.size) | 194 | if (minfo->cfg.size) |
195 | size = minfo->cfg.size; | 195 | size = minfo->cfg.size; |
196 | else { | 196 | else { |
197 | size = ((num_physpages << PAGE_SHIFT) / 16384) / | 197 | size = ((totalram_pages << PAGE_SHIFT) / 16384) / |
198 | sizeof(struct list_head); | 198 | sizeof(struct list_head); |
199 | if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE)) | 199 | if (totalram_pages > (1024 * 1024 * 1024 / PAGE_SIZE)) |
200 | size = 8192; | 200 | size = 8192; |
201 | if (size < 16) | 201 | if (size < 16) |
202 | size = 16; | 202 | size = 16; |
@@ -266,9 +266,9 @@ static int htable_create(struct xt_hashlimit_mtinfo1 *minfo, u_int8_t family) | |||
266 | if (minfo->cfg.size) { | 266 | if (minfo->cfg.size) { |
267 | size = minfo->cfg.size; | 267 | size = minfo->cfg.size; |
268 | } else { | 268 | } else { |
269 | size = (num_physpages << PAGE_SHIFT) / 16384 / | 269 | size = (totalram_pages << PAGE_SHIFT) / 16384 / |
270 | sizeof(struct list_head); | 270 | sizeof(struct list_head); |
271 | if (num_physpages > 1024 * 1024 * 1024 / PAGE_SIZE) | 271 | if (totalram_pages > 1024 * 1024 * 1024 / PAGE_SIZE) |
272 | size = 8192; | 272 | size = 8192; |
273 | if (size < 16) | 273 | if (size < 16) |
274 | size = 16; | 274 | size = 16; |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index c5aab6a368ce..55180b99562a 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -2091,10 +2091,10 @@ static int __init netlink_proto_init(void) | |||
2091 | if (!nl_table) | 2091 | if (!nl_table) |
2092 | goto panic; | 2092 | goto panic; |
2093 | 2093 | ||
2094 | if (num_physpages >= (128 * 1024)) | 2094 | if (totalram_pages >= (128 * 1024)) |
2095 | limit = num_physpages >> (21 - PAGE_SHIFT); | 2095 | limit = totalram_pages >> (21 - PAGE_SHIFT); |
2096 | else | 2096 | else |
2097 | limit = num_physpages >> (23 - PAGE_SHIFT); | 2097 | limit = totalram_pages >> (23 - PAGE_SHIFT); |
2098 | 2098 | ||
2099 | order = get_bitmask_order(limit) - 1 + PAGE_SHIFT; | 2099 | order = get_bitmask_order(limit) - 1 + PAGE_SHIFT; |
2100 | limit = (1UL << order) / sizeof(struct hlist_head); | 2100 | limit = (1UL << order) / sizeof(struct hlist_head); |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index c557f1fb1c66..612dc878e05c 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1184,10 +1184,10 @@ SCTP_STATIC __init int sctp_init(void) | |||
1184 | /* Size and allocate the association hash table. | 1184 | /* Size and allocate the association hash table. |
1185 | * The methodology is similar to that of the tcp hash tables. | 1185 | * The methodology is similar to that of the tcp hash tables. |
1186 | */ | 1186 | */ |
1187 | if (num_physpages >= (128 * 1024)) | 1187 | if (totalram_pages >= (128 * 1024)) |
1188 | goal = num_physpages >> (22 - PAGE_SHIFT); | 1188 | goal = totalram_pages >> (22 - PAGE_SHIFT); |
1189 | else | 1189 | else |
1190 | goal = num_physpages >> (24 - PAGE_SHIFT); | 1190 | goal = totalram_pages >> (24 - PAGE_SHIFT); |
1191 | 1191 | ||
1192 | for (order = 0; (1UL << order) < goal; order++) | 1192 | for (order = 0; (1UL << order) < goal; order++) |
1193 | ; | 1193 | ; |