]> granicus.if.org Git - zfs/commitdiff
3.12 compat, NUMA-aware per-superblock shrinker
authorTim Chase <tim@chase2k.com>
Sun, 14 Jun 2015 16:19:40 +0000 (11:19 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 17 Jun 2015 17:43:13 +0000 (10:43 -0700)
Kernels >= 3.12 have a NUMA-aware superblock shrinker which is used in
ZoL by zfs_sb_prune().  This patch calls the shrinker for each on-line
NUMA node in order that memory be freed for each one.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3495

config/kernel-shrink.m4
config/kernel.m4
module/zfs/zfs_vfsops.c

index 1c211ed159b4900a772d0406bc6b3b7257cee00c..a57c2afb0b6b298ea446f94a2d7c5ebcfa9025c7 100644 (file)
@@ -109,3 +109,25 @@ AC_DEFUN([ZFS_AC_KERNEL_FREE_CACHED_OBJECTS], [
                AC_MSG_RESULT(no)
        ])
 ])
+
+dnl #
+dnl # 3.12 API change
+dnl # The nid member was added to struct shrink_control to support
+dnl # NUMA-aware shrinkers.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [
+       AC_MSG_CHECKING([whether shrink_control has nid])
+       ZFS_LINUX_TRY_COMPILE([
+               #include <linux/fs.h>
+       ],[
+               struct shrink_control sc __attribute__ ((unused));
+               unsigned long scnidsize __attribute__ ((unused)) =
+                   sizeof(sc.nid);
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
+                   [struct shrink_control has nid])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
index 69470e128a4180908f5ad11f0c19705de250d370..a9f2f589844e01e3ea8a5c3fec397d2fe52e63fe 100644 (file)
@@ -87,6 +87,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_CALLBACK_SECURITY_INODE_INIT_SECURITY
        ZFS_AC_KERNEL_MOUNT_NODEV
        ZFS_AC_KERNEL_SHRINK
+       ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
        ZFS_AC_KERNEL_S_INSTANCES_LIST_HEAD
        ZFS_AC_KERNEL_S_D_OP
        ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER
index 2b532a33359a41645b315c8c9f610867ffaa5ec1..88f655a8cdb2127a80da592bdf587c0d74a04d0a 100644 (file)
@@ -68,7 +68,6 @@
 #include <sys/zpl.h>
 #include "zfs_comutil.h"
 
-
 /*ARGSUSED*/
 int
 zfs_sync(struct super_block *sb, int wait, cred_t *cr)
@@ -1093,7 +1092,17 @@ zfs_sb_prune(struct super_block *sb, unsigned long nr_to_scan, int *objects)
 
        ZFS_ENTER(zsb);
 
-#if defined(HAVE_SPLIT_SHRINKER_CALLBACK)
+#if defined(HAVE_SPLIT_SHRINKER_CALLBACK) && \
+       defined(SHRINK_CONTROL_HAS_NID) && \
+       defined(SHRINKER_NUMA_AWARE)
+       if (sb->s_shrink.flags & SHRINKER_NUMA_AWARE) {
+               *objects = 0;
+               for_each_online_node(sc.nid)
+                       *objects += (*shrinker->scan_objects)(shrinker, &sc);
+       } else {
+                       *objects = (*shrinker->scan_objects)(shrinker, &sc);
+       }
+#elif defined(HAVE_SPLIT_SHRINKER_CALLBACK)
        *objects = (*shrinker->scan_objects)(shrinker, &sc);
 #elif defined(HAVE_SHRINK)
        *objects = (*shrinker->shrink)(shrinker, &sc);