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>
This commit is contained in:
committed by
Linus Torvalds
parent
4738e1b9cf
commit
4481374ce8
@ -1245,9 +1245,9 @@ static int nf_conntrack_init_init_net(void)
|
||||
* machine has 512 buckets. >= 1GB machines have 16384 buckets. */
|
||||
if (!nf_conntrack_htable_size) {
|
||||
nf_conntrack_htable_size
|
||||
= (((num_physpages << PAGE_SHIFT) / 16384)
|
||||
= (((totalram_pages << PAGE_SHIFT) / 16384)
|
||||
/ sizeof(struct hlist_head));
|
||||
if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE))
|
||||
if (totalram_pages > (1024 * 1024 * 1024 / PAGE_SIZE))
|
||||
nf_conntrack_htable_size = 16384;
|
||||
if (nf_conntrack_htable_size < 32)
|
||||
nf_conntrack_htable_size = 32;
|
||||
|
@ -617,7 +617,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
|
||||
int cpu;
|
||||
|
||||
/* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */
|
||||
if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > num_physpages)
|
||||
if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages)
|
||||
return NULL;
|
||||
|
||||
newinfo = kzalloc(XT_TABLE_INFO_SZ, GFP_KERNEL);
|
||||
|
@ -194,9 +194,9 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, u_int8_t family)
|
||||
if (minfo->cfg.size)
|
||||
size = minfo->cfg.size;
|
||||
else {
|
||||
size = ((num_physpages << PAGE_SHIFT) / 16384) /
|
||||
size = ((totalram_pages << PAGE_SHIFT) / 16384) /
|
||||
sizeof(struct list_head);
|
||||
if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE))
|
||||
if (totalram_pages > (1024 * 1024 * 1024 / PAGE_SIZE))
|
||||
size = 8192;
|
||||
if (size < 16)
|
||||
size = 16;
|
||||
@ -266,9 +266,9 @@ static int htable_create(struct xt_hashlimit_mtinfo1 *minfo, u_int8_t family)
|
||||
if (minfo->cfg.size) {
|
||||
size = minfo->cfg.size;
|
||||
} else {
|
||||
size = (num_physpages << PAGE_SHIFT) / 16384 /
|
||||
size = (totalram_pages << PAGE_SHIFT) / 16384 /
|
||||
sizeof(struct list_head);
|
||||
if (num_physpages > 1024 * 1024 * 1024 / PAGE_SIZE)
|
||||
if (totalram_pages > 1024 * 1024 * 1024 / PAGE_SIZE)
|
||||
size = 8192;
|
||||
if (size < 16)
|
||||
size = 16;
|
||||
|
Reference in New Issue
Block a user