]> granicus.if.org Git - zfs/commitdiff
Linux 4.8+ compatibility fix for vm stats
authordbavatar <dbavatar@gmail.com>
Thu, 24 Aug 2017 17:48:23 +0000 (13:48 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 24 Aug 2017 17:48:23 +0000 (10:48 -0700)
vm_node_stat must be used instead of vm_zone_stat. Unfortunately the
old code still compiles potentially leading to silent failure of
arc_evictable_memory()

AKAMAI: CR 3816601: Regression in zfs dropcache test

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <tuxoko@gmail.com>
Signed-off-by: Debabrata Banerjee <dbanerje@akamai.com>
Closes #6528

config/kernel-vm_node_stat.m4 [new file with mode: 0644]
config/kernel.m4
module/zfs/arc.c

diff --git a/config/kernel-vm_node_stat.m4 b/config/kernel-vm_node_stat.m4
new file mode 100644 (file)
index 0000000..e1c42f8
--- /dev/null
@@ -0,0 +1,22 @@
+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)
+       ])
+])
index e92a659879b4be8e1418bd3d0de072d3ffe6f020..3739f85fbbfa0bff32f73f98f99c9ea6a1882f72 100644 (file)
@@ -120,6 +120,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
 
        AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
                KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
index d7ad101c3647a2f8b69b71f85d0b0ad9525b7157..75f0af9d5fd6660e719092954ec5d351f348ca07 100644 (file)
@@ -5064,8 +5064,13 @@ arc_evictable_memory(void)
         * Scale reported evictable memory in proportion to page cache, cap
         * at specified min/max.
         */
+#ifdef ZFS_GLOBAL_NODE_PAGE_STATE
+       uint64_t min = (ptob(global_node_page_state(NR_FILE_PAGES)) / 100) *
+           zfs_arc_pc_percent;
+#else
        uint64_t min = (ptob(global_page_state(NR_FILE_PAGES)) / 100) *
            zfs_arc_pc_percent;
+#endif
        min = MAX(arc_c_min, MIN(arc_c_max, min));
 
        if (arc_dirty >= min)