+fi
+
+ rm -Rf build
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether struct shrink_control exists" >&5
+$as_echo_n "checking whether struct shrink_control exists... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+
+ #include <linux/mm.h>
+
+int
+main (void)
+{
+
+ struct shrink_control sc __attribute__ ((unused));
+
+ sc.nr_to_scan = 0;
+ sc.gfp_mask = GFP_KERNEL;
+
+ ;
+ return 0;
+}
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build
+ echo "obj-m := conftest.o" >build/Makefile
+ if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SHRINK_CONTROL_STRUCT 1
+_ACEOF
+
+
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
fi
rm -Rf build
+fi
+
+ rm -Rf build
+
+
+
+
+ { $as_echo "$as_me:$LINENO: checking whether struct shrink_control exists" >&5
+$as_echo_n "checking whether struct shrink_control exists... " >&6; }
+
+
+cat confdefs.h - <<_ACEOF >conftest.c
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+
+ #include <linux/mm.h>
+
+int
+main (void)
+{
+
+ struct shrink_control sc __attribute__ ((unused));
+
+ sc.nr_to_scan = 0;
+ sc.gfp_mask = GFP_KERNEL;
+
+ ;
+ return 0;
+}
+
+_ACEOF
+
+
+ rm -Rf build && mkdir -p build
+ echo "obj-m := conftest.o" >build/Makefile
+ if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+ { $as_echo "$as_me:$LINENO: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SHRINK_CONTROL_STRUCT 1
+_ACEOF
+
+
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { $as_echo "$as_me:$LINENO: result: no" >&5
+$as_echo "no" >&6; }
+
+
+
fi
rm -Rf build
# endif /* HAVE_2ARGS_INVALIDATE_INODES */
#endif /* HAVE_INVALIDATE_INODES */
+#if !defined(HAVE_SHRINK_CONTROL_STRUCT)
+struct shrink_control {
+ gfp_t gfp_mask;
+ unsigned long nr_to_scan;
+};
+#endif /* HAVE_SHRINK_CONTROL_STRUCT */
+
/*
* 2.6.xx API compat,
* There currently exists no exposed API to partially shrink the dcache.
* which is called during memory pressure.
*/
#ifndef HAVE_SHRINK_DCACHE_MEMORY
-# ifdef HAVE_3ARGS_SHRINKER_CALLBACK
+# if defined(HAVE_SHRINK_CONTROL_STRUCT)
+typedef int (*shrink_dcache_memory_t)(struct shrinker *,
+ struct shrink_control *);
+extern shrink_dcache_memory_t shrink_dcache_memory_fn;
+# define shrink_dcache_memory(nr, gfp) \
+({ \
+ struct shrink_control sc = { .nr_to_scan = nr, .gfp_mask = gfp }; \
+ shrink_dcache_memory_fn(NULL, &sc); \
+})
+# elif defined(HAVE_3ARGS_SHRINKER_CALLBACK)
typedef int (*shrink_dcache_memory_t)(struct shrinker *, int, gfp_t);
extern shrink_dcache_memory_t shrink_dcache_memory_fn;
# define shrink_dcache_memory(nr, gfp) shrink_dcache_memory_fn(NULL, nr, gfp)
* which is called during memory pressure.
*/
#ifndef HAVE_SHRINK_ICACHE_MEMORY
-# ifdef HAVE_3ARGS_SHRINKER_CALLBACK
+# if defined(HAVE_SHRINK_CONTROL_STRUCT)
+typedef int (*shrink_icache_memory_t)(struct shrinker *,
+ struct shrink_control *);
+extern shrink_icache_memory_t shrink_icache_memory_fn;
+# define shrink_icache_memory(nr, gfp) \
+({ \
+ struct shrink_control sc = { .nr_to_scan = nr, .gfp_mask = gfp }; \
+ shrink_icache_memory_fn(NULL, &sc); \
+})
+# elif defined(HAVE_3ARGS_SHRINKER_CALLBACK)
typedef int (*shrink_icache_memory_t)(struct shrinker *, int, gfp_t);
extern shrink_icache_memory_t shrink_icache_memory_fn;
# define shrink_icache_memory(nr, gfp) shrink_icache_memory_fn(NULL, nr, gfp)
# endif /* HAVE_3ARGS_SHRINKER_CALLBACK */
#endif /* HAVE_SHRINK_ICACHE_MEMORY */
+/*
+ * Linux 2.6. - 2.6. Shrinker API Compatibility.
+ */
#ifdef HAVE_SET_SHRINKER
typedef struct spl_shrinker {
struct shrinker *shrinker;
remove_shrinker(ss->shrinker);
}
-# define SPL_SHRINKER_DECLARE(s, x, y) \
- static spl_shrinker_t s = { .shrinker = NULL, .fn = x, .seeks = y }
-# define SPL_SHRINKER_CALLBACK_PROTO(fn, x, y, z) \
- static int fn(int y, unsigned int z)
-# define spl_exec_shrinker(ss, nr, gfp) \
- ((spl_shrinker_t *)ss)->fn(nr, gfp)
+# define SPL_SHRINKER_DECLARE(s, x, y) \
+ static spl_shrinker_t s = { \
+ .shrinker = NULL, \
+ .fn = x, \
+ .seeks = y \
+ }
+
+# define SPL_SHRINKER_CALLBACK_FWD_DECLARE(fn) \
+ static int fn(int, unsigned int)
+# define SPL_SHRINKER_CALLBACK_WRAPPER(fn) \
+static int \
+fn(int nr_to_scan, unsigned int gfp_mask) \
+{ \
+ struct shrink_control sc; \
+ \
+ sc.nr_to_scan = nr_to_scan; \
+ sc.gfp_mask = gfp_mask; \
+ \
+ return __ ## fn(NULL, &sc); \
+}
-#else /* HAVE_SET_SHRINKER */
+#else
# define spl_register_shrinker(x) register_shrinker(x)
# define spl_unregister_shrinker(x) unregister_shrinker(x)
-# define SPL_SHRINKER_DECLARE(s, x, y) \
- static struct shrinker s = { .shrink = x, .seeks = y }
-
-# ifdef HAVE_3ARGS_SHRINKER_CALLBACK
-# define SPL_SHRINKER_CALLBACK_PROTO(fn, x, y, z) \
- static int fn(struct shrinker *x, int y, unsigned int z)
-# define spl_exec_shrinker(ss, nr, gfp) \
- ((struct shrinker *)ss)->shrink(NULL, nr, gfp)
-# else /* HAVE_3ARGS_SHRINKER_CALLBACK */
-# define SPL_SHRINKER_CALLBACK_PROTO(fn, x, y, z) \
- static int fn(int y, unsigned int z)
-# define spl_exec_shrinker(ss, nr, gfp) \
- ((struct shrinker *)ss)->shrink(nr, gfp)
-# endif /* HAVE_3ARGS_SHRINKER_CALLBACK */
+# define SPL_SHRINKER_DECLARE(s, x, y) \
+ static struct shrinker s = { \
+ .shrink = x, \
+ .seeks = y \
+ }
+
+/*
+ * Linux 2.6. - 2.6. Shrinker API Compatibility.
+ */
+# if defined(HAVE_SHRINK_CONTROL_STRUCT)
+# define SPL_SHRINKER_CALLBACK_FWD_DECLARE(fn) \
+ static int fn(struct shrinker *, struct shrink_control *)
+# define SPL_SHRINKER_CALLBACK_WRAPPER(fn) \
+static int \
+fn(struct shrinker *shrink, struct shrink_control *sc) { \
+ return __ ## fn(shrink, sc); \
+}
+
+/*
+ * Linux 2.6. - 2.6. Shrinker API Compatibility.
+ */
+# elif defined(HAVE_3ARGS_SHRINKER_CALLBACK)
+# define SPL_SHRINKER_CALLBACK_FWD_DECLARE(fn) \
+ static int fn(struct shrinker *, int, unsigned int)
+# define SPL_SHRINKER_CALLBACK_WRAPPER(fn) \
+static int \
+fn(struct shrinker *shrink, int nr_to_scan, unsigned int gfp_mask) \
+{ \
+ struct shrink_control sc; \
+ \
+ sc.nr_to_scan = nr_to_scan; \
+ sc.gfp_mask = gfp_mask; \
+ \
+ return __ ## fn(shrink, &sc); \
+}
+
+/*
+ * Linux 2.6. - 2.6. Shrinker API Compatibility.
+ */
+# else
+# define SPL_SHRINKER_CALLBACK_FWD_DECLARE(fn) \
+ static int fn(int, unsigned int)
+# define SPL_SHRINKER_CALLBACK_WRAPPER(fn) \
+static int \
+fn(int nr_to_scan, unsigned int gfp_mask) \
+{ \
+ struct shrink_control sc; \
+ \
+ sc.nr_to_scan = nr_to_scan; \
+ sc.gfp_mask = gfp_mask; \
+ \
+ return __ ## fn(NULL, &sc); \
+}
+
+# endif
#endif /* HAVE_SET_SHRINKER */
#endif /* SPL_MM_COMPAT_H */
static int spl_cache_flush(spl_kmem_cache_t *skc,
spl_kmem_magazine_t *skm, int flush);
-SPL_SHRINKER_CALLBACK_PROTO(spl_kmem_cache_generic_shrinker,
- shrinker_cb, nr_to_scan, gfp_mask);
+SPL_SHRINKER_CALLBACK_FWD_DECLARE(spl_kmem_cache_generic_shrinker);
SPL_SHRINKER_DECLARE(spl_kmem_cache_shrinker,
spl_kmem_cache_generic_shrinker, KMC_DEFAULT_SEEKS);
* objects should be freed, because Solaris semantics are to free
* all available objects we may free more objects than requested.
*/
-SPL_SHRINKER_CALLBACK_PROTO(spl_kmem_cache_generic_shrinker,
- shrinker_cb, nr_to_scan, gfp_mask)
+static int
+__spl_kmem_cache_generic_shrinker(struct shrinker *shrink,
+ struct shrink_control *sc)
{
spl_kmem_cache_t *skc;
int unused = 0;
down_read(&spl_kmem_cache_sem);
list_for_each_entry(skc, &spl_kmem_cache_list, skc_list) {
- if (nr_to_scan)
+ if (sc->nr_to_scan)
spl_kmem_cache_reap_now(skc);
/*
return (unused * sysctl_vfs_cache_pressure) / 100;
}
+SPL_SHRINKER_CALLBACK_WRAPPER(spl_kmem_cache_generic_shrinker);
+
/*
* Call the registered reclaim function for a cache. Depending on how
* many and which objects are released it may simply repopulate the
void
spl_kmem_reap(void)
{
- spl_exec_shrinker(&spl_kmem_cache_shrinker, KMC_REAP_CHUNK, GFP_KERNEL);
+ struct shrink_control sc;
+
+ sc.nr_to_scan = KMC_REAP_CHUNK;
+ sc.gfp_mask = GFP_KERNEL;
+
+ __spl_kmem_cache_generic_shrinker(NULL, &sc);
}
EXPORT_SYMBOL(spl_kmem_reap);