]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - config/kernel-shrink.m4
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / config / kernel-shrink.m4
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>
10
11                 int shrink(struct shrinker *s, struct shrink_control *sc)
12                     { return 0; }
13
14                 static const struct super_block
15                     sb __attribute__ ((unused)) = {
16                         .s_shrink.seeks = DEFAULT_SEEKS,
17                         .s_shrink.batch = 0,
18                 };
19         ],[])
20 ])
21
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         ])
29 ])
30
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         ])
44 ])
45
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         ])
55 ])
56
57 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK], [
58         ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control], [
59                 #include <linux/mm.h>
60                 int shrinker_cb(struct shrinker *shrink,
61                     struct shrink_control *sc) { return 0; }
62         ],[
63                 struct shrinker cache_shrinker = {
64                         .shrink = shrinker_cb,
65                         .seeks = DEFAULT_SEEKS,
66                 };
67                 register_shrinker(&cache_shrinker);
68         ])
69
70         ZFS_LINUX_TEST_SRC([shrinker_cb_shrink_control_split], [
71                 #include <linux/mm.h>
72                 unsigned long shrinker_cb(struct shrinker *shrink,
73                     struct shrink_control *sc) { return 0; }
74         ],[
75                 struct shrinker cache_shrinker = {
76                         .count_objects = shrinker_cb,
77                         .scan_objects = shrinker_cb,
78                         .seeks = DEFAULT_SEEKS,
79                 };
80                 register_shrinker(&cache_shrinker);
81         ])
82 ])
83
84 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER_CALLBACK],[
85         dnl #
86         dnl # 3.0 - 3.11 API change
87         dnl # ->shrink(struct shrinker *, struct shrink_control *sc)
88         dnl #
89         AC_MSG_CHECKING([whether new 2-argument shrinker exists])
90         ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control], [
91                 AC_MSG_RESULT(yes)
92                 AC_DEFINE(HAVE_SINGLE_SHRINKER_CALLBACK, 1,
93                     [new shrinker callback wants 2 args])
94         ],[
95                 AC_MSG_RESULT(no)
96
97                 dnl #
98                 dnl # 3.12 API change,
99                 dnl # ->shrink() is logically split in to
100                 dnl # ->count_objects() and ->scan_objects()
101                 dnl #
102                 AC_MSG_CHECKING([whether ->count_objects callback exists])
103                 ZFS_LINUX_TEST_RESULT([shrinker_cb_shrink_control_split], [
104                         AC_MSG_RESULT(yes)
105                         AC_DEFINE(HAVE_SPLIT_SHRINKER_CALLBACK, 1,
106                             [->count_objects exists])
107                 ],[
108                         ZFS_LINUX_TEST_ERROR([shrinker])
109                 ])
110         ])
111 ])
112
113 dnl #
114 dnl # 2.6.39 API change,
115 dnl # Shrinker adjust to use common shrink_control structure.
116 dnl #
117 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT], [
118         ZFS_LINUX_TEST_SRC([shrink_control_struct], [
119                 #include <linux/mm.h>
120         ],[
121                 struct shrink_control sc __attribute__ ((unused));
122
123                 sc.nr_to_scan = 0;
124                 sc.gfp_mask = GFP_KERNEL;
125         ])
126 ])
127
128 AC_DEFUN([ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT], [
129         AC_MSG_CHECKING([whether struct shrink_control exists])
130         ZFS_LINUX_TEST_RESULT([shrink_control_struct], [
131                 AC_MSG_RESULT(yes)
132                 AC_DEFINE(HAVE_SHRINK_CONTROL_STRUCT, 1,
133                     [struct shrink_control exists])
134         ],[
135                 ZFS_LINUX_TEST_ERROR([shrink_control])
136         ])
137 ])
138
139 AC_DEFUN([ZFS_AC_KERNEL_SRC_SHRINKER], [
140         ZFS_AC_KERNEL_SRC_SUPER_BLOCK_S_SHRINK
141         ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_HAS_NID
142         ZFS_AC_KERNEL_SRC_SHRINKER_CALLBACK
143         ZFS_AC_KERNEL_SRC_SHRINK_CONTROL_STRUCT
144 ])
145
146 AC_DEFUN([ZFS_AC_KERNEL_SHRINKER], [
147         ZFS_AC_KERNEL_SUPER_BLOCK_S_SHRINK
148         ZFS_AC_KERNEL_SHRINK_CONTROL_HAS_NID
149         ZFS_AC_KERNEL_SHRINKER_CALLBACK
150         ZFS_AC_KERNEL_SHRINK_CONTROL_STRUCT
151 ])