CI: Move perl script to dist_noinst_DATA
[zfs.git] / config / kernel-shrink.m4
blob0c702153e8c4585957725fe240811243a63c3d25
1 dnl #
2 dnl # 3.1 API change
3 dnl # The super_block structure now stores a per-filesystem shrinker.
4 dnl # This interface is preferable because it can be used to specifically
5 dnl # target only the zfs filesystem for pruning.
6 dnl #
7 AC_DEFUN([ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK], [
8         ZFS_LINUX_TEST_SRC([super_block_s_shrink], [
9                 #include <linux/fs.h>
11                 int shrink(struct shrinker *s, struct shrink_control *sc)
12                     { return 0; }
14                 static const struct super_block
15                     sb __attribute__ ((unused)) = {
16                         .s_shrink.seeks = DEFAULT_SEEKS,
17                         .s_shrink.batch = 0,
18                 };
19         ],[])
22 AC_DEFUN([ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK], [
23         AC_MSG_CHECKING([whether super_block has s_shrink])
24         ZFS_LINUX_TEST_RESULT([super_block_s_shrink], [
25                 AC_MSG_RESULT(yes)
26         ],[
27                 ZFS_LINUX_TEST_ERROR([sb->s_shrink()])
28         ])
31 dnl #
32 dnl # 3.12 API change
33 dnl # The nid member was added to struct shrink_control to support
34 dnl # NUMA-aware shrinkers.
35 dnl #
36 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID], [
37         ZFS_LINUX_TEST_SRC([shrink_control_nid], [
38                 #include <linux/fs.h>
39         ],[
40                 struct shrink_control sc __attribute__ ((unused));
41                 unsigned long scnidsize __attribute__ ((unused)) =
42                     sizeof(sc.nid);
43         ])
46 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID], [
47         AC_MSG_CHECKING([whether shrink_control has nid])
48         ZFS_LINUX_TEST_RESULT([shrink_control_nid], [
49                 AC_MSG_RESULT(yes)
50                 AC_DEFINE(SHRINK_CONTROL_HAS_NID, 1,
51                     [struct shrink_control has nid])
52         ],[
53                 AC_MSG_RESULT(no)
54         ])
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG], [
58         ZFS_LINUX_TEST_SRC([register_shrinker_vararg], [
59                 #include <linux/mm.h>
60                 unsigned long shrinker_cb(struct shrinker *shrink,
61                     struct shrink_control *sc) { return 0; }
62         ],[
63                 struct shrinker cache_shrinker = {
64                         .count_objects = shrinker_cb,
65                         .scan_objects = shrinker_cb,
66                         .seeks = DEFAULT_SEEKS,
67                 };
68                 register_shrinker(&cache_shrinker, "vararg-reg-shrink-test");
69         ])
72 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
73         ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
74                 #include <linux/mm.h>
75                 int shrinker_cb(struct shrinker *shrink,
76                     struct shrink_control *sc) { return 0; }
77         ],[
78                 struct shrinker cache_shrinker = {
79                         .shrink = shrinker_cb,
80                         .seeks = DEFAULT_SEEKS,
81                 };
82                 register_shrinker(&cache_shrinker);
83         ])
85         ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
86                 #include <linux/mm.h>
87                 unsigned long shrinker_cb(struct shrinker *shrink,
88                     struct shrink_control *sc) { return 0; }
89         ],[
90                 struct shrinker cache_shrinker = {
91                         .count_objects = shrinker_cb,
92                         .scan_objects = shrinker_cb,
93                         .seeks = DEFAULT_SEEKS,
94                 };
95                 register_shrinker(&cache_shrinker);
96         ])
99 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
100         dnl #
101         dnl # 6.0 API change
102         dnl # register_shrinker() becomes a var-arg function that takes
103         dnl # a printf-style format string as args > 0
104         dnl #
105         AC_MSG_CHECKING([whether new var-arg register_shrinker() exists])
106         ZFS_LINUX_TEST_RESULT([register_shrinker_vararg], [
107                 AC_MSG_RESULT(yes)
108                 AC_DEFINE(HAVE_REGISTER_SHRINKER_VARARG, 1,
109                     [register_shrinker is vararg])
111                 dnl # We assume that the split shrinker callback exists if the
112                 dnl # vararg register_shrinker() exists, because the latter is
113                 dnl # a much more recent addition, and the macro test for the
114                 dnl # var-arg version only works if the callback is split
115                 AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
116                         [cs->count_objects exists])
117         ],[
118                 AC_MSG_RESULT(no)
119                 dnl #
120                 dnl # 3.0 - 3.11 API change
121                 dnl # cs->shrink(struct shrinker *, struct shrink_control *sc)
122                 dnl #
123                 AC_MSG_CHECKING([whether new 2-argument shrinker exists])
124                 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
125                         AC_MSG_RESULT(yes)
126                         AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
127                                 [new shrinker callback wants 2 args])
128                 ],[
129                         AC_MSG_RESULT(no)
131                         dnl #
132                         dnl # 3.12 API change,
133                         dnl # cs->shrink() is logically split in to
134                         dnl # cs->count_objects() and cs->scan_objects()
135                         dnl #
136                         AC_MSG_CHECKING([if cs->count_objects callback exists])
137                         ZFS_LINUX_TEST_RESULT(
138                                 [shrinker_cb_shrink_control_split],[
139                                         AC_MSG_RESULT(yes)
140                                         AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
141                                                 [cs->count_objects exists])
142                         ],[
143                                         ZFS_LINUX_TEST_ERROR([shrinker])
144                         ])
145                 ])
146         ])
149 dnl #
150 dnl # 2.6.39 API change,
151 dnl # Shrinker adjust to use common shrink_control structure.
152 dnl #
153 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
154         ZFS_LINUX_TEST_SRC([shrink_control_struct], [
155                 #include <linux/mm.h>
156         ],[
157                 struct shrink_control sc __attribute__ ((unused));
159                 sc.nr_to_scan = 0;
160                 sc.gfp_mask = GFP_KERNEL;
161         ])
164 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
165         AC_MSG_CHECKING([whether struct shrink_control exists])
166         ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
167                 AC_MSG_RESULT(yes)
168                 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
169                     [struct shrink_control exists])
170         ],[
171                 ZFS_LINUX_TEST_ERROR([shrink_control])
172         ])
175 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
176         ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
177         ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
178         ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
179         ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
180         ZFS_AC_KERNEL_SRC_REGISTER_SHRINKER_VARARG
183 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
184         ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
185         ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
186         ZFS_AC_KERNEL_SHRINKER_CALLBACK
187         ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT