Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4481374c authored by Jan Beulich's avatar Jan Beulich Committed by Linus Torvalds
Browse files

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: default avatarJan Beulich <jbeulich@novell.com>
Acked-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Acked-by: default avatarIngo 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4738e1b9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -210,8 +210,8 @@ static ssize_t microcode_write(struct file *file, const char __user *buf,
{
	ssize_t ret = -EINVAL;

	if ((len >> PAGE_SHIFT) > num_physpages) {
		pr_err("microcode: too much data (max %ld pages)\n", num_physpages);
	if ((len >> PAGE_SHIFT) > totalram_pages) {
		pr_err("microcode: too much data (max %ld pages)\n", totalram_pages);
		return ret;
	}

+2 −2
Original line number Diff line number Diff line
@@ -114,9 +114,9 @@ static int agp_find_max(void)
	long memory, index, result;

#if PAGE_SHIFT < 20
	memory = num_physpages >> (20 - PAGE_SHIFT);
	memory = totalram_pages >> (20 - PAGE_SHIFT);
#else
	memory = num_physpages << (PAGE_SHIFT - 20);
	memory = totalram_pages << (PAGE_SHIFT - 20);
#endif
	index = 1;

+2 −2
Original line number Diff line number Diff line
@@ -1266,7 +1266,7 @@ ccio_ioc_init(struct ioc *ioc)
	** Hot-Plug/Removal of PCI cards. (aka PCI OLARD).
	*/

	iova_space_size = (u32) (num_physpages / count_parisc_driver(&ccio_driver));
	iova_space_size = (u32) (totalram_pages / count_parisc_driver(&ccio_driver));

	/* limit IOVA space size to 1MB-1GB */

@@ -1305,7 +1305,7 @@ ccio_ioc_init(struct ioc *ioc)

	DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n",
			__func__, ioc->ioc_regs,
			(unsigned long) num_physpages >> (20 - PAGE_SHIFT),
			(unsigned long) totalram_pages >> (20 - PAGE_SHIFT),
			iova_space_size>>20,
			iov_order + PAGE_SHIFT);

+2 −2
Original line number Diff line number Diff line
@@ -1390,7 +1390,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
	** for DMA hints - ergo only 30 bits max.
	*/

	iova_space_size = (u32) (num_physpages/global_ioc_cnt);
	iova_space_size = (u32) (totalram_pages/global_ioc_cnt);

	/* limit IOVA space size to 1MB-1GB */
	if (iova_space_size < (1 << (20 - PAGE_SHIFT))) {
@@ -1415,7 +1415,7 @@ sba_ioc_init(struct parisc_device *sba, struct ioc *ioc, int ioc_num)
	DBG_INIT("%s() hpa 0x%lx mem %ldMB IOV %dMB (%d bits)\n",
			__func__,
			ioc->ioc_hpa,
			(unsigned long) num_physpages >> (20 - PAGE_SHIFT),
			(unsigned long) totalram_pages >> (20 - PAGE_SHIFT),
			iova_space_size>>20,
			iov_order + PAGE_SHIFT);

+0 −4
Original line number Diff line number Diff line
@@ -96,11 +96,7 @@ static struct balloon_stats balloon_stats;
/* We increase/decrease in batches which fit in a page */
static unsigned long frame_list[PAGE_SIZE / sizeof(unsigned long)];

/* VM /proc information for memory */
extern unsigned long totalram_pages;

#ifdef CONFIG_HIGHMEM
extern unsigned long totalhigh_pages;
#define inc_totalhigh_pages() (totalhigh_pages++)
#define dec_totalhigh_pages() (totalhigh_pages--)
#else
Loading