mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
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.
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://github.com/sponsors/robn
(cherry picked from commit 03b84099d9)
This commit is contained in:
+47
-5
@@ -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], [
|
||||
|
||||
Reference in New Issue
Block a user