xref: /freebsd/sys/contrib/openzfs/config/kernel-percpu.m4 (revision cc68614da8232d8baaca0ae0d0dd8f890f06623e)
1dnl #
2dnl # 3.18 API change,
3dnl # The function percpu_counter_init now must be passed a GFP mask.
4dnl #
5AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_INIT], [
6	ZFS_LINUX_TEST_SRC([percpu_counter_init_with_gfp], [
7		#include <linux/gfp.h>
8		#include <linux/percpu_counter.h>
9	],[
10		struct percpu_counter counter;
11		int error;
12
13		error = percpu_counter_init(&counter, 0, GFP_KERNEL);
14	])
15])
16
17AC_DEFUN([ZFS_AC_KERNEL_PERCPU_COUNTER_INIT], [
18	AC_MSG_CHECKING([whether percpu_counter_init() wants gfp_t])
19	ZFS_LINUX_TEST_RESULT([percpu_counter_init_with_gfp], [
20		AC_MSG_RESULT(yes)
21		AC_DEFINE(HAVE_PERCPU_COUNTER_INIT_WITH_GFP, 1,
22		    [percpu_counter_init() wants gfp_t])
23	],[
24		AC_MSG_RESULT(no)
25	])
26])
27
28dnl #
29dnl # 4.13 API change,
30dnl # __percpu_counter_add() was renamed to percpu_counter_add_batch().
31dnl #
32AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_ADD_BATCH], [
33	ZFS_LINUX_TEST_SRC([percpu_counter_add_batch], [
34		#include <linux/percpu_counter.h>
35	],[
36		struct percpu_counter counter;
37
38		percpu_counter_add_batch(&counter, 1, 1);
39	])
40])
41
42AC_DEFUN([ZFS_AC_KERNEL_PERCPU_COUNTER_ADD_BATCH], [
43	AC_MSG_CHECKING([whether percpu_counter_add_batch() is defined])
44	ZFS_LINUX_TEST_RESULT([percpu_counter_add_batch], [
45		AC_MSG_RESULT(yes)
46		AC_DEFINE(HAVE_PERCPU_COUNTER_ADD_BATCH, 1,
47		    [percpu_counter_add_batch() is defined])
48	],[
49		AC_MSG_RESULT(no)
50	])
51])
52
53dnl #
54dnl # 5.10 API change,
55dnl # The "count" was moved into ref->data, from ref
56dnl #
57AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU_REF_COUNT_IN_DATA], [
58	ZFS_LINUX_TEST_SRC([percpu_ref_count_in_data], [
59		#include <linux/percpu-refcount.h>
60	],[
61		struct percpu_ref_data d;
62
63		atomic_long_set(&d.count, 1L);
64	])
65])
66
67AC_DEFUN([ZFS_AC_KERNEL_PERCPU_REF_COUNT_IN_DATA], [
68	AC_MSG_CHECKING([whether is inside percpu_ref.data])
69	ZFS_LINUX_TEST_RESULT([percpu_ref_count_in_data], [
70		AC_MSG_RESULT(yes)
71		AC_DEFINE(ZFS_PERCPU_REF_COUNT_IN_DATA, 1,
72		    [count is located in percpu_ref.data])
73	],[
74		AC_MSG_RESULT(no)
75	])
76])
77AC_DEFUN([ZFS_AC_KERNEL_SRC_PERCPU], [
78	ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_INIT
79	ZFS_AC_KERNEL_SRC_PERCPU_COUNTER_ADD_BATCH
80	ZFS_AC_KERNEL_SRC_PERCPU_REF_COUNT_IN_DATA
81])
82
83AC_DEFUN([ZFS_AC_KERNEL_PERCPU], [
84	ZFS_AC_KERNEL_PERCPU_COUNTER_INIT
85	ZFS_AC_KERNEL_PERCPU_COUNTER_ADD_BATCH
86	ZFS_AC_KERNEL_PERCPU_REF_COUNT_IN_DATA
87])
88