Skip to content

Commit

Permalink
Linux 3.11 compat: Replace num_physpages with totalram_pages
Browse files Browse the repository at this point in the history
num_physpages was removed by
torvalds/linux@cfa11e0, so lets replace
it with totalram_pages.

This is a bug fix as much as it is a compatibility fix because
num_physpages did not reflect the number of pages actually available to
the kernel:

http://lkml.indiana.edu/hypermail/linux/kernel/0908.2/01001.html

Also, there are known issues with memory calculations when ZFS is in a
Xen dom0. There is a chance that using totalram_pages could resolve
them. This conjecture is untested at the time of writing.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#273
  • Loading branch information
ryao authored and behlendorf committed Aug 8, 2013
1 parent 0b15402 commit ba06298
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/sys/vmsystm.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
#define membar_producer() smp_wmb()

#define physmem num_physpages
#define physmem totalram_pages
#define freemem nr_free_pages()
#define availrmem spl_kmem_availrmem()

Expand Down
5 changes: 3 additions & 2 deletions module/spl/spl-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/spinlock.h>
#include <linux/proc_compat.h>
#include <linux/file_compat.h>
#include <linux/swap.h>
#include <sys/sysmacros.h>
#include <spl-debug.h>
#include <spl-trace.h>
Expand Down Expand Up @@ -548,7 +549,7 @@ trace_print_to_console(struct spl_debug_header *hdr, int mask, const char *buf,
static int
trace_max_debug_mb(void)
{
return MAX(512, ((num_physpages >> (20 - PAGE_SHIFT)) * 80) / 100);
return MAX(512, ((totalram_pages >> (20 - PAGE_SHIFT)) * 80) / 100);
}

static struct trace_page *
Expand Down Expand Up @@ -1188,7 +1189,7 @@ spl_debug_init(void)

/* If spl_debug_mb is set to an invalid value or uninitialized
* then just make the total buffers smp_num_cpus TCD_MAX_PAGES */
if (max > (num_physpages >> (20 - 2 - PAGE_SHIFT)) / 5 ||
if (max > (totalram_pages >> (20 - 2 - PAGE_SHIFT)) / 5 ||
max >= 512 || max < 0) {
max = TCD_MAX_PAGES;
} else {
Expand Down

0 comments on commit ba06298

Please sign in to comment.