From 851a549305ad9001e7a6dfbf735f501b286e9d08 Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Wed, 12 Aug 2015 09:57:35 -0500 Subject: [PATCH] Include other sources of freeable memory in the freemem calculation Prevents ARC collapse when non-ZFS filesystems, the block layer or other memory consumers use a lot of reclaimable memory in the page cache. Signed-off-by: Brian Behlendorf Signed-off-by: Tim Chase Closes zfsonlinux/zfs#3680 Closes #471 --- include/sys/vmsystm.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/sys/vmsystm.h b/include/sys/vmsystm.h index 2fa169523d..9d334fe0a1 100644 --- a/include/sys/vmsystm.h +++ b/include/sys/vmsystm.h @@ -35,7 +35,10 @@ #define membar_producer() smp_wmb() #define physmem totalram_pages -#define freemem nr_free_pages() +#define freemem (nr_free_pages() + \ + global_page_state(NR_INACTIVE_FILE) + \ + global_page_state(NR_INACTIVE_ANON) + \ + global_page_state(NR_SLAB_RECLAIMABLE)) #define xcopyin(from, to, size) copy_from_user(to, from, size) #define xcopyout(from, to, size) copy_to_user(to, from, size)