xref: /openbmc/linux/include/linux/workqueue.h (revision d320c038)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * workqueue.h --- work queue handling for Linux.
31da177e4SLinus Torvalds  */
41da177e4SLinus Torvalds 
51da177e4SLinus Torvalds #ifndef _LINUX_WORKQUEUE_H
61da177e4SLinus Torvalds #define _LINUX_WORKQUEUE_H
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #include <linux/timer.h>
91da177e4SLinus Torvalds #include <linux/linkage.h>
101da177e4SLinus Torvalds #include <linux/bitops.h>
114e6045f1SJohannes Berg #include <linux/lockdep.h>
127a22ad75STejun Heo #include <linux/threads.h>
13a08727baSLinus Torvalds #include <asm/atomic.h>
141da177e4SLinus Torvalds 
151da177e4SLinus Torvalds struct workqueue_struct;
161da177e4SLinus Torvalds 
1765f27f38SDavid Howells struct work_struct;
1865f27f38SDavid Howells typedef void (*work_func_t)(struct work_struct *work);
196bb49e59SDavid Howells 
20a08727baSLinus Torvalds /*
21a08727baSLinus Torvalds  * The first word is the work queue pointer and the flags rolled into
22a08727baSLinus Torvalds  * one
23a08727baSLinus Torvalds  */
24a08727baSLinus Torvalds #define work_data_bits(work) ((unsigned long *)(&(work)->data))
25a08727baSLinus Torvalds 
2622df02bbSTejun Heo enum {
2722df02bbSTejun Heo 	WORK_STRUCT_PENDING_BIT	= 0,	/* work item is pending execution */
28affee4b2STejun Heo 	WORK_STRUCT_LINKED_BIT	= 1,	/* next work is linked to this one */
2922df02bbSTejun Heo #ifdef CONFIG_DEBUG_OBJECTS_WORK
30affee4b2STejun Heo 	WORK_STRUCT_STATIC_BIT	= 2,	/* static initializer (debugobjects) */
3173f53c4aSTejun Heo 	WORK_STRUCT_COLOR_SHIFT	= 3,	/* color for workqueue flushing */
320f900049STejun Heo #else
3373f53c4aSTejun Heo 	WORK_STRUCT_COLOR_SHIFT	= 2,	/* color for workqueue flushing */
3422df02bbSTejun Heo #endif
3522df02bbSTejun Heo 
3673f53c4aSTejun Heo 	WORK_STRUCT_COLOR_BITS	= 4,
3773f53c4aSTejun Heo 
3822df02bbSTejun Heo 	WORK_STRUCT_PENDING	= 1 << WORK_STRUCT_PENDING_BIT,
39affee4b2STejun Heo 	WORK_STRUCT_LINKED	= 1 << WORK_STRUCT_LINKED_BIT,
4022df02bbSTejun Heo #ifdef CONFIG_DEBUG_OBJECTS_WORK
4122df02bbSTejun Heo 	WORK_STRUCT_STATIC	= 1 << WORK_STRUCT_STATIC_BIT,
4222df02bbSTejun Heo #else
4322df02bbSTejun Heo 	WORK_STRUCT_STATIC	= 0,
4422df02bbSTejun Heo #endif
4522df02bbSTejun Heo 
4673f53c4aSTejun Heo 	/*
4773f53c4aSTejun Heo 	 * The last color is no color used for works which don't
4873f53c4aSTejun Heo 	 * participate in workqueue flushing.
4973f53c4aSTejun Heo 	 */
5073f53c4aSTejun Heo 	WORK_NR_COLORS		= (1 << WORK_STRUCT_COLOR_BITS) - 1,
5173f53c4aSTejun Heo 	WORK_NO_COLOR		= WORK_NR_COLORS,
5273f53c4aSTejun Heo 
5373f53c4aSTejun Heo 	/*
5473f53c4aSTejun Heo 	 * Reserve 6 bits off of cwq pointer w/ debugobjects turned
5573f53c4aSTejun Heo 	 * off.  This makes cwqs aligned to 64 bytes which isn't too
5673f53c4aSTejun Heo 	 * excessive while allowing 15 workqueue flush colors.
5773f53c4aSTejun Heo 	 */
5873f53c4aSTejun Heo 	WORK_STRUCT_FLAG_BITS	= WORK_STRUCT_COLOR_SHIFT +
5973f53c4aSTejun Heo 				  WORK_STRUCT_COLOR_BITS,
6073f53c4aSTejun Heo 
610f900049STejun Heo 	WORK_STRUCT_FLAG_MASK	= (1UL << WORK_STRUCT_FLAG_BITS) - 1,
6222df02bbSTejun Heo 	WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK,
637a22ad75STejun Heo 	WORK_STRUCT_NO_CPU	= NR_CPUS << WORK_STRUCT_FLAG_BITS,
6422df02bbSTejun Heo };
6522df02bbSTejun Heo 
661da177e4SLinus Torvalds struct work_struct {
67a08727baSLinus Torvalds 	atomic_long_t data;
681da177e4SLinus Torvalds 	struct list_head entry;
696bb49e59SDavid Howells 	work_func_t func;
704e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP
714e6045f1SJohannes Berg 	struct lockdep_map lockdep_map;
724e6045f1SJohannes Berg #endif
7352bad64dSDavid Howells };
7452bad64dSDavid Howells 
757a22ad75STejun Heo #define WORK_DATA_INIT()	ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU)
767a22ad75STejun Heo #define WORK_DATA_STATIC_INIT()	\
777a22ad75STejun Heo 	ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU | WORK_STRUCT_STATIC)
78a08727baSLinus Torvalds 
7952bad64dSDavid Howells struct delayed_work {
8052bad64dSDavid Howells 	struct work_struct work;
811da177e4SLinus Torvalds 	struct timer_list timer;
821da177e4SLinus Torvalds };
831da177e4SLinus Torvalds 
84bf6aede7SJean Delvare static inline struct delayed_work *to_delayed_work(struct work_struct *work)
85bf6aede7SJean Delvare {
86bf6aede7SJean Delvare 	return container_of(work, struct delayed_work, work);
87bf6aede7SJean Delvare }
88bf6aede7SJean Delvare 
891fa44ecaSJames Bottomley struct execute_work {
901fa44ecaSJames Bottomley 	struct work_struct work;
911fa44ecaSJames Bottomley };
921fa44ecaSJames Bottomley 
934e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP
944e6045f1SJohannes Berg /*
954e6045f1SJohannes Berg  * NB: because we have to copy the lockdep_map, setting _key
964e6045f1SJohannes Berg  * here is required, otherwise it could get initialised to the
974e6045f1SJohannes Berg  * copy of the lockdep_map!
984e6045f1SJohannes Berg  */
994e6045f1SJohannes Berg #define __WORK_INIT_LOCKDEP_MAP(n, k) \
1004e6045f1SJohannes Berg 	.lockdep_map = STATIC_LOCKDEP_MAP_INIT(n, k),
1014e6045f1SJohannes Berg #else
1024e6045f1SJohannes Berg #define __WORK_INIT_LOCKDEP_MAP(n, k)
1034e6045f1SJohannes Berg #endif
1044e6045f1SJohannes Berg 
10565f27f38SDavid Howells #define __WORK_INITIALIZER(n, f) {				\
106dc186ad7SThomas Gleixner 	.data = WORK_DATA_STATIC_INIT(),			\
10765f27f38SDavid Howells 	.entry	= { &(n).entry, &(n).entry },			\
10865f27f38SDavid Howells 	.func = (f),						\
1094e6045f1SJohannes Berg 	__WORK_INIT_LOCKDEP_MAP(#n, &(n))			\
11065f27f38SDavid Howells 	}
11165f27f38SDavid Howells 
11265f27f38SDavid Howells #define __DELAYED_WORK_INITIALIZER(n, f) {			\
11365f27f38SDavid Howells 	.work = __WORK_INITIALIZER((n).work, (f)),		\
1141da177e4SLinus Torvalds 	.timer = TIMER_INITIALIZER(NULL, 0, 0),			\
1151da177e4SLinus Torvalds 	}
1161da177e4SLinus Torvalds 
11765f27f38SDavid Howells #define DECLARE_WORK(n, f)					\
11865f27f38SDavid Howells 	struct work_struct n = __WORK_INITIALIZER(n, f)
11965f27f38SDavid Howells 
12065f27f38SDavid Howells #define DECLARE_DELAYED_WORK(n, f)				\
12165f27f38SDavid Howells 	struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f)
12265f27f38SDavid Howells 
1231da177e4SLinus Torvalds /*
12465f27f38SDavid Howells  * initialize a work item's function pointer
1251da177e4SLinus Torvalds  */
12665f27f38SDavid Howells #define PREPARE_WORK(_work, _func)				\
1271da177e4SLinus Torvalds 	do {							\
12852bad64dSDavid Howells 		(_work)->func = (_func);			\
1291da177e4SLinus Torvalds 	} while (0)
1301da177e4SLinus Torvalds 
13165f27f38SDavid Howells #define PREPARE_DELAYED_WORK(_work, _func)			\
13265f27f38SDavid Howells 	PREPARE_WORK(&(_work)->work, (_func))
13352bad64dSDavid Howells 
134dc186ad7SThomas Gleixner #ifdef CONFIG_DEBUG_OBJECTS_WORK
135dc186ad7SThomas Gleixner extern void __init_work(struct work_struct *work, int onstack);
136dc186ad7SThomas Gleixner extern void destroy_work_on_stack(struct work_struct *work);
1374690c4abSTejun Heo static inline unsigned int work_static(struct work_struct *work)
1384690c4abSTejun Heo {
13922df02bbSTejun Heo 	return *work_data_bits(work) & WORK_STRUCT_STATIC;
1404690c4abSTejun Heo }
141dc186ad7SThomas Gleixner #else
142dc186ad7SThomas Gleixner static inline void __init_work(struct work_struct *work, int onstack) { }
143dc186ad7SThomas Gleixner static inline void destroy_work_on_stack(struct work_struct *work) { }
1444690c4abSTejun Heo static inline unsigned int work_static(struct work_struct *work) { return 0; }
145dc186ad7SThomas Gleixner #endif
146dc186ad7SThomas Gleixner 
1471da177e4SLinus Torvalds /*
14852bad64dSDavid Howells  * initialize all of a work item in one go
149a08727baSLinus Torvalds  *
150b9049df5SDmitri Vorobiev  * NOTE! No point in using "atomic_long_set()": using a direct
151a08727baSLinus Torvalds  * assignment of the work data initializer allows the compiler
152a08727baSLinus Torvalds  * to generate better code.
1531da177e4SLinus Torvalds  */
1544e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP
155dc186ad7SThomas Gleixner #define __INIT_WORK(_work, _func, _onstack)				\
1564e6045f1SJohannes Berg 	do {								\
1574e6045f1SJohannes Berg 		static struct lock_class_key __key;			\
1584e6045f1SJohannes Berg 									\
159dc186ad7SThomas Gleixner 		__init_work((_work), _onstack);				\
1604e6045f1SJohannes Berg 		(_work)->data = (atomic_long_t) WORK_DATA_INIT();	\
1614e6045f1SJohannes Berg 		lockdep_init_map(&(_work)->lockdep_map, #_work, &__key, 0);\
1624e6045f1SJohannes Berg 		INIT_LIST_HEAD(&(_work)->entry);			\
1634e6045f1SJohannes Berg 		PREPARE_WORK((_work), (_func));				\
1644e6045f1SJohannes Berg 	} while (0)
1654e6045f1SJohannes Berg #else
166dc186ad7SThomas Gleixner #define __INIT_WORK(_work, _func, _onstack)				\
1671da177e4SLinus Torvalds 	do {								\
168dc186ad7SThomas Gleixner 		__init_work((_work), _onstack);				\
16923b2e599SOleg Nesterov 		(_work)->data = (atomic_long_t) WORK_DATA_INIT();	\
17065f27f38SDavid Howells 		INIT_LIST_HEAD(&(_work)->entry);			\
17165f27f38SDavid Howells 		PREPARE_WORK((_work), (_func));				\
17265f27f38SDavid Howells 	} while (0)
1734e6045f1SJohannes Berg #endif
17465f27f38SDavid Howells 
175dc186ad7SThomas Gleixner #define INIT_WORK(_work, _func)					\
176dc186ad7SThomas Gleixner 	do {							\
177dc186ad7SThomas Gleixner 		__INIT_WORK((_work), (_func), 0);		\
178dc186ad7SThomas Gleixner 	} while (0)
179dc186ad7SThomas Gleixner 
180dc186ad7SThomas Gleixner #define INIT_WORK_ON_STACK(_work, _func)			\
181dc186ad7SThomas Gleixner 	do {							\
182dc186ad7SThomas Gleixner 		__INIT_WORK((_work), (_func), 1);		\
183dc186ad7SThomas Gleixner 	} while (0)
184dc186ad7SThomas Gleixner 
18565f27f38SDavid Howells #define INIT_DELAYED_WORK(_work, _func)				\
18665f27f38SDavid Howells 	do {							\
18765f27f38SDavid Howells 		INIT_WORK(&(_work)->work, (_func));		\
18865f27f38SDavid Howells 		init_timer(&(_work)->timer);			\
18965f27f38SDavid Howells 	} while (0)
19065f27f38SDavid Howells 
1916d612b0fSPeter Zijlstra #define INIT_DELAYED_WORK_ON_STACK(_work, _func)		\
1926d612b0fSPeter Zijlstra 	do {							\
193dc186ad7SThomas Gleixner 		INIT_WORK_ON_STACK(&(_work)->work, (_func));	\
1946d612b0fSPeter Zijlstra 		init_timer_on_stack(&(_work)->timer);		\
1956d612b0fSPeter Zijlstra 	} while (0)
1966d612b0fSPeter Zijlstra 
19728287033SVenki Pallipadi #define INIT_DELAYED_WORK_DEFERRABLE(_work, _func)		\
19828287033SVenki Pallipadi 	do {							\
19928287033SVenki Pallipadi 		INIT_WORK(&(_work)->work, (_func));		\
20028287033SVenki Pallipadi 		init_timer_deferrable(&(_work)->timer);		\
20128287033SVenki Pallipadi 	} while (0)
20228287033SVenki Pallipadi 
203365970a1SDavid Howells /**
204365970a1SDavid Howells  * work_pending - Find out whether a work item is currently pending
205365970a1SDavid Howells  * @work: The work item in question
206365970a1SDavid Howells  */
207365970a1SDavid Howells #define work_pending(work) \
20822df02bbSTejun Heo 	test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))
209365970a1SDavid Howells 
210365970a1SDavid Howells /**
211365970a1SDavid Howells  * delayed_work_pending - Find out whether a delayable work item is currently
212365970a1SDavid Howells  * pending
213365970a1SDavid Howells  * @work: The work item in question
214365970a1SDavid Howells  */
2150221872aSLinus Torvalds #define delayed_work_pending(w) \
2160221872aSLinus Torvalds 	work_pending(&(w)->work)
217365970a1SDavid Howells 
21865f27f38SDavid Howells /**
21923b2e599SOleg Nesterov  * work_clear_pending - for internal use only, mark a work item as not pending
22023b2e599SOleg Nesterov  * @work: The work item in question
22165f27f38SDavid Howells  */
22223b2e599SOleg Nesterov #define work_clear_pending(work) \
22322df02bbSTejun Heo 	clear_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))
22465f27f38SDavid Howells 
22597e37d7bSTejun Heo enum {
22697e37d7bSTejun Heo 	WQ_FREEZEABLE		= 1 << 0, /* freeze during suspend */
227502ca9d8STejun Heo 	WQ_SINGLE_CPU		= 1 << 1, /* only single cpu at a time */
22818aa9effSTejun Heo 	WQ_NON_REENTRANT	= 1 << 2, /* guarantee non-reentrance */
229e22bee78STejun Heo 	WQ_RESCUER		= 1 << 3, /* has an rescue worker */
230b71ab8c2STejun Heo 
231b71ab8c2STejun Heo 	WQ_MAX_ACTIVE		= 512,	  /* I like 512, better ideas? */
232b71ab8c2STejun Heo 	WQ_DFL_ACTIVE		= WQ_MAX_ACTIVE / 2,
23397e37d7bSTejun Heo };
23452bad64dSDavid Howells 
235d320c038STejun Heo /*
236d320c038STejun Heo  * System-wide workqueues which are always present.
237d320c038STejun Heo  *
238d320c038STejun Heo  * system_wq is the one used by schedule[_delayed]_work[_on]().
239d320c038STejun Heo  * Multi-CPU multi-threaded.  There are users which expect relatively
240d320c038STejun Heo  * short queue flush time.  Don't queue works which can run for too
241d320c038STejun Heo  * long.
242d320c038STejun Heo  *
243d320c038STejun Heo  * system_long_wq is similar to system_wq but may host long running
244d320c038STejun Heo  * works.  Queue flushing might take relatively long.
245d320c038STejun Heo  *
246d320c038STejun Heo  * system_nrt_wq is non-reentrant and guarantees that any given work
247d320c038STejun Heo  * item is never executed in parallel by multiple CPUs.  Queue
248d320c038STejun Heo  * flushing might take relatively long.
249d320c038STejun Heo  */
250d320c038STejun Heo extern struct workqueue_struct *system_wq;
251d320c038STejun Heo extern struct workqueue_struct *system_long_wq;
252d320c038STejun Heo extern struct workqueue_struct *system_nrt_wq;
253d320c038STejun Heo 
2544e6045f1SJohannes Berg extern struct workqueue_struct *
255d320c038STejun Heo __alloc_workqueue_key(const char *name, unsigned int flags, int max_active,
256c790bce0STejun Heo 		      struct lock_class_key *key, const char *lock_name);
2574e6045f1SJohannes Berg 
2584e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP
259d320c038STejun Heo #define alloc_workqueue(name, flags, max_active)		\
2604e6045f1SJohannes Berg ({								\
2614e6045f1SJohannes Berg 	static struct lock_class_key __key;			\
262eb13ba87SJohannes Berg 	const char *__lock_name;				\
263eb13ba87SJohannes Berg 								\
264eb13ba87SJohannes Berg 	if (__builtin_constant_p(name))				\
265eb13ba87SJohannes Berg 		__lock_name = (name);				\
266eb13ba87SJohannes Berg 	else							\
267eb13ba87SJohannes Berg 		__lock_name = #name;				\
2684e6045f1SJohannes Berg 								\
269d320c038STejun Heo 	__alloc_workqueue_key((name), (flags), (max_active),	\
2701e19ffc6STejun Heo 			      &__key, __lock_name);		\
2714e6045f1SJohannes Berg })
2724e6045f1SJohannes Berg #else
273d320c038STejun Heo #define alloc_workqueue(name, flags, max_active)		\
274d320c038STejun Heo 	__alloc_workqueue_key((name), (flags), (max_active), NULL, NULL)
2754e6045f1SJohannes Berg #endif
2764e6045f1SJohannes Berg 
27797e37d7bSTejun Heo #define create_workqueue(name)					\
278d320c038STejun Heo 	alloc_workqueue((name), WQ_RESCUER, 1)
27997e37d7bSTejun Heo #define create_freezeable_workqueue(name)			\
280d320c038STejun Heo 	alloc_workqueue((name), WQ_FREEZEABLE | WQ_SINGLE_CPU | WQ_RESCUER, 1)
28197e37d7bSTejun Heo #define create_singlethread_workqueue(name)			\
282d320c038STejun Heo 	alloc_workqueue((name), WQ_SINGLE_CPU | WQ_RESCUER, 1)
2831da177e4SLinus Torvalds 
2841da177e4SLinus Torvalds extern void destroy_workqueue(struct workqueue_struct *wq);
2851da177e4SLinus Torvalds 
286b3c97528SHarvey Harrison extern int queue_work(struct workqueue_struct *wq, struct work_struct *work);
287c1a220e7SZhang Rui extern int queue_work_on(int cpu, struct workqueue_struct *wq,
288c1a220e7SZhang Rui 			struct work_struct *work);
289b3c97528SHarvey Harrison extern int queue_delayed_work(struct workqueue_struct *wq,
290b3c97528SHarvey Harrison 			struct delayed_work *work, unsigned long delay);
2917a6bc1cdSVenkatesh Pallipadi extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
29252bad64dSDavid Howells 			struct delayed_work *work, unsigned long delay);
29328e53bddSOleg Nesterov 
294b3c97528SHarvey Harrison extern void flush_workqueue(struct workqueue_struct *wq);
29528e53bddSOleg Nesterov extern void flush_scheduled_work(void);
29643046b60SLinus Torvalds extern void flush_delayed_work(struct delayed_work *work);
2971da177e4SLinus Torvalds 
298b3c97528SHarvey Harrison extern int schedule_work(struct work_struct *work);
299c1a220e7SZhang Rui extern int schedule_work_on(int cpu, struct work_struct *work);
300b3c97528SHarvey Harrison extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay);
30128e53bddSOleg Nesterov extern int schedule_delayed_work_on(int cpu, struct delayed_work *work,
30228e53bddSOleg Nesterov 					unsigned long delay);
30365f27f38SDavid Howells extern int schedule_on_each_cpu(work_func_t func);
3041da177e4SLinus Torvalds extern int keventd_up(void);
3051da177e4SLinus Torvalds 
3061da177e4SLinus Torvalds extern void init_workqueues(void);
30765f27f38SDavid Howells int execute_in_process_context(work_func_t fn, struct execute_work *);
3081da177e4SLinus Torvalds 
309db700897SOleg Nesterov extern int flush_work(struct work_struct *work);
310db700897SOleg Nesterov 
3111f1f642eSOleg Nesterov extern int cancel_work_sync(struct work_struct *work);
31228e53bddSOleg Nesterov 
3131da177e4SLinus Torvalds /*
3141da177e4SLinus Torvalds  * Kill off a pending schedule_delayed_work().  Note that the work callback
315071b6386SOleg Nesterov  * function may still be running on return from cancel_delayed_work(), unless
316071b6386SOleg Nesterov  * it returns 1 and the work doesn't re-arm itself. Run flush_workqueue() or
31728e53bddSOleg Nesterov  * cancel_work_sync() to wait on it.
3181da177e4SLinus Torvalds  */
31952bad64dSDavid Howells static inline int cancel_delayed_work(struct delayed_work *work)
3201da177e4SLinus Torvalds {
3211da177e4SLinus Torvalds 	int ret;
3221da177e4SLinus Torvalds 
323223a10a9SOleg Nesterov 	ret = del_timer_sync(&work->timer);
3241da177e4SLinus Torvalds 	if (ret)
32523b2e599SOleg Nesterov 		work_clear_pending(&work->work);
3261da177e4SLinus Torvalds 	return ret;
3271da177e4SLinus Torvalds }
3281da177e4SLinus Torvalds 
3294e49627bSOleg Nesterov /*
3304e49627bSOleg Nesterov  * Like above, but uses del_timer() instead of del_timer_sync(). This means,
3314e49627bSOleg Nesterov  * if it returns 0 the timer function may be running and the queueing is in
3324e49627bSOleg Nesterov  * progress.
3334e49627bSOleg Nesterov  */
3344e49627bSOleg Nesterov static inline int __cancel_delayed_work(struct delayed_work *work)
3354e49627bSOleg Nesterov {
3364e49627bSOleg Nesterov 	int ret;
3374e49627bSOleg Nesterov 
3384e49627bSOleg Nesterov 	ret = del_timer(&work->timer);
3394e49627bSOleg Nesterov 	if (ret)
3404e49627bSOleg Nesterov 		work_clear_pending(&work->work);
3414e49627bSOleg Nesterov 	return ret;
3424e49627bSOleg Nesterov }
3434e49627bSOleg Nesterov 
3441f1f642eSOleg Nesterov extern int cancel_delayed_work_sync(struct delayed_work *work);
3451634c48fSOleg Nesterov 
346f5a421a4SOleg Nesterov /* Obsolete. use cancel_delayed_work_sync() */
3471634c48fSOleg Nesterov static inline
3481634c48fSOleg Nesterov void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
3491634c48fSOleg Nesterov 					struct delayed_work *work)
3501634c48fSOleg Nesterov {
351f5a421a4SOleg Nesterov 	cancel_delayed_work_sync(work);
352f5a421a4SOleg Nesterov }
353f5a421a4SOleg Nesterov 
354f5a421a4SOleg Nesterov /* Obsolete. use cancel_delayed_work_sync() */
355f5a421a4SOleg Nesterov static inline
356f5a421a4SOleg Nesterov void cancel_rearming_delayed_work(struct delayed_work *work)
357f5a421a4SOleg Nesterov {
358f5a421a4SOleg Nesterov 	cancel_delayed_work_sync(work);
3591634c48fSOleg Nesterov }
3601634c48fSOleg Nesterov 
3612d3854a3SRusty Russell #ifndef CONFIG_SMP
3622d3854a3SRusty Russell static inline long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg)
3632d3854a3SRusty Russell {
3642d3854a3SRusty Russell 	return fn(arg);
3652d3854a3SRusty Russell }
3662d3854a3SRusty Russell #else
3672d3854a3SRusty Russell long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg);
3682d3854a3SRusty Russell #endif /* CONFIG_SMP */
369a0a1a5fdSTejun Heo 
370a0a1a5fdSTejun Heo #ifdef CONFIG_FREEZER
371a0a1a5fdSTejun Heo extern void freeze_workqueues_begin(void);
372a0a1a5fdSTejun Heo extern bool freeze_workqueues_busy(void);
373a0a1a5fdSTejun Heo extern void thaw_workqueues(void);
374a0a1a5fdSTejun Heo #endif /* CONFIG_FREEZER */
375a0a1a5fdSTejun Heo 
3761da177e4SLinus Torvalds #endif
377