xref: /freebsd/sys/contrib/openzfs/config/kernel-workqueue.m4 (revision 22649d4dba730d46244fd2dff4fd174903c8379f)
1dnl # SPDX-License-Identifier: CDDL-1.0
2dnl #
3dnl # 5.19 API change
4dnl # flush_workqueue() will no longer compile for system/global workqueues,
5dnl # __flush_workqueue() introduced with no restrictions.
6dnl #
7dnl # 6.17 API change
8dnl # schedule_delayed_work() now queues to system_percpu_wq, system_wq
9dnl # deprecated.
10dnl #
11dnl # We cannot simply test for system_percpu_wq, as it has been backported
12dnl # to LTS kernels where it is _not_ used for the delay queue. However,
13dnl # the same commit that introduced it on mainline (a2be943b46b4a) also
14dnl # added system_percpu_wq to the flush_workqueue() macro as one of the
15dnl # global workqueues to reject at compiletime, and removed system_wq.
16dnl # That part however, was _not_ backported, so we can use it to determine
17dnl # which waitqueue is used for delay - if __flush_workqueue() accepts it,
18dnl # but flush_workqueue() does not, then it is the delay workqueue.
19dnl #
20AC_DEFUN([ZFS_AC_KERNEL_SRC_FLUSH_DELAY_WORKQUEUE], [
21	ZFS_LINUX_TEST_SRC([flush_workqueue_system], [
22		#include <linux/workqueue.h>
23	], [
24		flush_workqueue(system_wq);
25	])
26	ZFS_LINUX_TEST_SRC([flush_workqueue_percpu], [
27		#include <linux/workqueue.h>
28	], [
29		flush_workqueue(system_percpu_wq);
30	])
31	ZFS_LINUX_TEST_SRC([flush_workqueue_internal_system], [
32		#include <linux/workqueue.h>
33	], [
34		__flush_workqueue(system_wq);
35	])
36	ZFS_LINUX_TEST_SRC([flush_workqueue_internal_percpu], [
37		#include <linux/workqueue.h>
38	], [
39		__flush_workqueue(system_percpu_wq);
40	])
41])
42
43AC_DEFUN([ZFS_AC_KERNEL_FLUSH_DELAY_WORKQUEUE], [
44	AC_MSG_CHECKING([how to flush delay workqueue])
45	ZFS_LINUX_TEST_RESULT([flush_workqueue_internal_percpu], [
46		dnl system_percpu_wq exists. the flush_workqueue()
47		dnl macro will reject the one used for delay
48		ZFS_LINUX_TEST_RESULT([flush_workqueue_percpu], [
49			AC_MSG_RESULT([internal+system])
50			AC_DEFINE(HAVE_FLUSH_DELAY_WORKQUEUE_INTERNAL, 1,
51			    [use __flush_workqueue() to flush delay workqueue])
52		], [
53			AC_MSG_RESULT([internal+percpu])
54			AC_DEFINE(HAVE_FLUSH_DELAY_WORKQUEUE_INTERNAL, 1,
55			    [use __flush_workqueue() to flush delay workqueue])
56			AC_DEFINE(HAVE_FLUSH_DELAY_WORKQUEUE_PERCPU, 1,
57			    [use system_delay_wq for delay workqueue])
58		])
59	], [
60		dnl system_percpu_wq does not exist. use whichever did
61		dnl not reject it
62		ZFS_LINUX_TEST_RESULT([flush_workqueue_internal_system], [
63			AC_MSG_RESULT([internal+system])
64			AC_DEFINE(HAVE_FLUSH_DELAY_WORKQUEUE_INTERNAL, 1,
65			    [use __flush_workqueue() to flush delay workqueue])
66		], [
67			AC_MSG_RESULT([system])
68		])
69	])
70])
71
72AC_DEFUN([ZFS_AC_KERNEL_SRC_WORKQUEUE], [
73	ZFS_AC_KERNEL_SRC_FLUSH_DELAY_WORKQUEUE
74])
75AC_DEFUN([ZFS_AC_KERNEL_WORKQUEUE], [
76	ZFS_AC_KERNEL_FLUSH_DELAY_WORKQUEUE
77])
78