aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorJan Beulich <JBeulich@novell.com>2009-09-21 20:03:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-22 10:17:38 -0400
commit4481374ce88ba8f460c8b89f2572027bd27057d0 (patch)
tree6896601b6a1da0e3e932ffa75fcff966c834c02c /net/netfilter
parent4738e1b9cf8f9e28d7de080a5e6ce5d0095ea18f (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/netfilter')
-rw-r--r--net/netfilter/nf_conntrack_core.c4
-rw-r--r--net/netfilter/x_tables.c2
-rw-r--r--net/netfilter/xt_hashlimit.c8
3 files changed, 7 insertions, 7 deletions
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;