aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorRob Norris <[email protected]>2023-12-17 00:36:21 +1100
committerBrian Behlendorf <[email protected]>2023-12-20 11:47:55 -0800
commit957dc1037a87cf4e2748010b9469511b721f7067 (patch)
tree6c971bc4fd6c00336cf680c7d4b592d365304269 /config
parent1d324aceefff81ee605f8d0368e2b6a711b631cf (diff)
Linux 6.7 compat: rework shrinker setup for heap allocations
6.7 changes the shrinker API such that shrinkers must be allocated dynamically by the kernel. To accomodate this, this commit reworks spl_register_shrinker() to do something similar against earlier kernels. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Sponsored-by: https://github.com/sponsors/robn Closes #15681
Diffstat (limited to 'config')
-rw-r--r--config/kernel-shrink.m452
1 files changed, 47 insertions, 5 deletions
diff --git a/config/kernel-shrink.m4 b/config/kernel-shrink.m4
index 1c5f753d4..4a529c43b 100644
--- a/config/kernel-shrink.m4
+++ b/config/kernel-shrink.m4
@@ -128,6 +128,25 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
])
])
+dnl #
+dnl # 6.7 API change
+dnl # register_shrinker has been replaced by shrinker_register.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER], [
+ ZFS_LINUX_TEST_SRC([shrinker_register], [
+ #include <linux/shrinker.h>
+ unsigned long shrinker_cb(struct shrinker *shrink,
+ struct shrink_control *sc) { return 0; }
+ ],[
+ struct shrinker cache_shrinker = {
+ .count_objects = shrinker_cb,
+ .scan_objects = shrinker_cb,
+ .seeks = DEFAULT_SEEKS,
+ };
+ shrinker_register(&cache_shrinker);
+ ])
+])
+
AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
dnl #
dnl # 6.0 API change
@@ -165,14 +184,36 @@ AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
dnl # cs->shrink() is logically split in to
dnl # cs->count_objects() and cs->scan_objects()
dnl #
- AC_MSG_CHECKING([if cs->count_objects callback exists])
+ AC_MSG_CHECKING(
+ [whether cs->count_objects callback exists])
ZFS_LINUX_TEST_RESULT(
- [shrinker_cb_shrink_control_split],[
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
- [cs->count_objects exists])
+ [shrinker_cb_shrink_control_split],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
+ [cs->count_objects exists])
],[
+ AC_MSG_RESULT(no)
+
+ AC_MSG_CHECKING(
+ [whether shrinker_register exists])
+ ZFS_LINUX_TEST_RESULT([shrinker_register], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_SHRINKER_REGISTER, 1,
+ [shrinker_register exists])
+
+ dnl # We assume that the split shrinker
+ dnl # callback exists if
+ dnl # shrinker_register() exists,
+ dnl # because the latter is a much more
+ dnl # recent addition, and the macro
+ dnl # test for shrinker_register() only
+ dnl # works if the callback is split
+ AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK,
+ 1, [cs->count_objects exists])
+ ],[
+ AC_MSG_RESULT(no)
ZFS_LINUX_TEST_ERROR([shrinker])
+ ])
])
])
])
@@ -211,6 +252,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG
+ ZFS_AC_KERNEL_SRC_SHRINKER_REGISTER
])
AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [