diff options
author | chrisrd <[email protected]> | 2018-02-24 03:50:06 +1100 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2018-03-14 16:10:37 -0700 |
commit | 338523dd6ec641cc4d552c3f67e1becfb9e22b0a (patch) | |
tree | f68d1b01ee49068723a3bf424b7723d63b69b6b6 /config | |
parent | 2644784f49a6b6be063d54ca0e1662ee6bef7ebd (diff) |
Fix free memory calculation on v3.14+
Provide infrastructure to auto-configure to enum and API changes in the
global page stats used for our free memory calculations.
arc_free_memory has been broken since an API change in Linux v3.14:
2016-07-28 v4.8 599d0c95 mm, vmscan: move LRU lists to node
2016-07-28 v4.8 75ef7184 mm, vmstat: add infrastructure for per-node
vmstats
These commits moved some of global_page_state() into
global_node_page_state(). The API change was particularly egregious as,
instead of breaking the old code, it silently did the wrong thing and we
continued using global_page_state() where we should have been using
global_node_page_state(), thus indexing into the wrong array via
NR_SLAB_RECLAIMABLE et al.
There have been further API changes along the way:
2017-07-06 v4.13 385386cf mm: vmstat: move slab statistics from zone to
node counters
2017-09-06 v4.14 c41f012a mm: rename global_page_state to
global_zone_page_state
...and various (incomplete, as it turns out) attempts to accomodate
these changes in ZoL:
2017-08-24 2209e409 Linux 4.8+ compatibility fix for vm stats
2017-09-16 787acae0 Linux 3.14 compat: IO acct, global_page_state, etc
2017-09-19 661907e6 Linux 4.14 compat: IO acct, global_page_state, etc
The config infrastructure provided here resolves these issues going back
to the original API change in v3.14 and is robust against further Linux
changes in this area.
Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Chris Dunlop <[email protected]>
Closes #7170
Diffstat (limited to 'config')
-rw-r--r-- | config/kernel-global_page_state.m4 | 109 | ||||
-rw-r--r-- | config/kernel-vm_node_stat.m4 | 22 | ||||
-rw-r--r-- | config/kernel.m4 | 2 |
3 files changed, 110 insertions, 23 deletions
diff --git a/config/kernel-global_page_state.m4 b/config/kernel-global_page_state.m4 new file mode 100644 index 000000000..f4a40011f --- /dev/null +++ b/config/kernel-global_page_state.m4 @@ -0,0 +1,109 @@ +dnl # +dnl # 4.8 API change +dnl # +dnl # 75ef71840539 mm, vmstat: add infrastructure for per-node vmstats +dnl # 599d0c954f91 mm, vmscan: move LRU lists to node +dnl # +AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_NODE_PAGE_STATE], [ + AC_MSG_CHECKING([whether global_node_page_state() exists]) + ZFS_LINUX_TRY_COMPILE([ + #include <linux/mm.h> + #include <linux/vmstat.h> + ],[ + (void) global_node_page_state(0); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GLOBAL_NODE_PAGE_STATE, 1, [global_node_page_state() exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # 4.14 API change +dnl # +dnl # c41f012ade0b mm: rename global_page_state to global_zone_page_state +dnl # +AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE], [ + AC_MSG_CHECKING([whether global_zone_page_state() exists]) + ZFS_LINUX_TRY_COMPILE([ + #include <linux/mm.h> + #include <linux/vmstat.h> + ],[ + (void) global_zone_page_state(0); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(ZFS_GLOBAL_ZONE_PAGE_STATE, 1, [global_zone_page_state() exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) + +dnl # +dnl # Create a define and autoconf variable for an enum member +dnl # +AC_DEFUN([ZFS_AC_KERNEL_ENUM_MEMBER], [ + AC_MSG_CHECKING([whether enum $2 contains $1]) + AS_IF([AC_TRY_COMMAND("${srcdir}/scripts/enum-extract.pl" "$2" "$3" | egrep -qx $1)],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(m4_join([_], [ZFS_ENUM], m4_toupper($2), $1), 1, [enum $2 contains $1]) + m4_join([_], [ZFS_ENUM], m4_toupper($2), $1)=1 + ],[ + AC_MSG_RESULT([no]) + ]) +]) + +dnl # +dnl # Sanity check helpers +dnl # +AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_ERROR],[ + AC_MSG_RESULT(no) + AC_MSG_RESULT([$1 in either node_stat_item or zone_stat_item: $2]) + AC_MSG_RESULT([configure needs updating, see: config/kernel-global_page_state.m4]) + AC_MSG_FAILURE([SHUT 'ER DOWN CLANCY, SHE'S PUMPIN' MUD!]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK], [ + enum_check_a="m4_join([_], [$ZFS_ENUM_NODE_STAT_ITEM], $1)" + enum_check_b="m4_join([_], [$ZFS_ENUM_ZONE_STAT_ITEM], $1)" + AS_IF([test -n "$enum_check_a" -a -n "$enum_check_b"],[ + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_ERROR([$1], [DUPLICATE]) + ]) + AS_IF([test -z "$enum_check_a" -a -z "$enum_check_b"],[ + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_ERROR([$1], [NOT FOUND]) + ]) +]) + +dnl # +dnl # Ensure the config tests are finding one and only one of each enum of interest +dnl # +AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY], [ + AC_MSG_CHECKING([global_page_state enums are sane]) + + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_FILE_PAGES]) + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_INACTIVE_ANON]) + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_INACTIVE_FILE]) + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE_ENUM_CHECK([NR_SLAB_RECLAIMABLE]) + + AC_MSG_RESULT(yes) +]) + +dnl # +dnl # enum members in which we're interested +dnl # +AC_DEFUN([ZFS_AC_KERNEL_GLOBAL_PAGE_STATE], [ + ZFS_AC_KERNEL_GLOBAL_NODE_PAGE_STATE + ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE + + ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], [node_stat_item], [$LINUX/include/linux/mmzone.h]) + ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_ANON], [node_stat_item], [$LINUX/include/linux/mmzone.h]) + ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_FILE], [node_stat_item], [$LINUX/include/linux/mmzone.h]) + ZFS_AC_KERNEL_ENUM_MEMBER([NR_SLAB_RECLAIMABLE], [node_stat_item], [$LINUX/include/linux/mmzone.h]) + + ZFS_AC_KERNEL_ENUM_MEMBER([NR_FILE_PAGES], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) + ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_ANON], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) + ZFS_AC_KERNEL_ENUM_MEMBER([NR_INACTIVE_FILE], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) + ZFS_AC_KERNEL_ENUM_MEMBER([NR_SLAB_RECLAIMABLE], [zone_stat_item], [$LINUX/include/linux/mmzone.h]) + + ZFS_AC_KERNEL_GLOBAL_ZONE_PAGE_STATE_SANITY +]) diff --git a/config/kernel-vm_node_stat.m4 b/config/kernel-vm_node_stat.m4 deleted file mode 100644 index 5dcd9d827..000000000 --- a/config/kernel-vm_node_stat.m4 +++ /dev/null @@ -1,22 +0,0 @@ -dnl # -dnl # 4.8 API change -dnl # kernel vm counters change -dnl # -AC_DEFUN([ZFS_AC_KERNEL_VM_NODE_STAT], [ - AC_MSG_CHECKING([whether to use vm_node_stat based fn's]) - ZFS_LINUX_TRY_COMPILE([ - #include <linux/mm.h> - #include <linux/vmstat.h> - ],[ - int a __attribute__ ((unused)) = NR_VM_NODE_STAT_ITEMS; - long x __attribute__ ((unused)) = - atomic_long_read(&vm_node_stat[0]); - (void) global_node_page_state(0); - ],[ - AC_MSG_RESULT(yes) - AC_DEFINE(ZFS_GLOBAL_NODE_PAGE_STATE, 1, - [using global_node_page_state()]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 7bb86a96e..3e499e447 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -123,7 +123,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_RENAME_WANTS_FLAGS ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR ZFS_AC_KERNEL_CURRENT_TIME - ZFS_AC_KERNEL_VM_NODE_STAT + ZFS_AC_KERNEL_GLOBAL_PAGE_STATE ZFS_AC_KERNEL_ACL_HAS_REFCOUNT AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ |