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, 64dcd989cbSTejun Heo 65dcd989cbSTejun Heo /* bit mask for work_busy() return values */ 66dcd989cbSTejun Heo WORK_BUSY_PENDING = 1 << 0, 67dcd989cbSTejun Heo WORK_BUSY_RUNNING = 1 << 1, 6822df02bbSTejun Heo }; 6922df02bbSTejun Heo 701da177e4SLinus Torvalds struct work_struct { 71a08727baSLinus Torvalds atomic_long_t data; 721da177e4SLinus Torvalds struct list_head entry; 736bb49e59SDavid Howells work_func_t func; 744e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 754e6045f1SJohannes Berg struct lockdep_map lockdep_map; 764e6045f1SJohannes Berg #endif 7752bad64dSDavid Howells }; 7852bad64dSDavid Howells 797a22ad75STejun Heo #define WORK_DATA_INIT() ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU) 807a22ad75STejun Heo #define WORK_DATA_STATIC_INIT() \ 817a22ad75STejun Heo ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU | WORK_STRUCT_STATIC) 82a08727baSLinus Torvalds 8352bad64dSDavid Howells struct delayed_work { 8452bad64dSDavid Howells struct work_struct work; 851da177e4SLinus Torvalds struct timer_list timer; 861da177e4SLinus Torvalds }; 871da177e4SLinus Torvalds 88bf6aede7SJean Delvare static inline struct delayed_work *to_delayed_work(struct work_struct *work) 89bf6aede7SJean Delvare { 90bf6aede7SJean Delvare return container_of(work, struct delayed_work, work); 91bf6aede7SJean Delvare } 92bf6aede7SJean Delvare 931fa44ecaSJames Bottomley struct execute_work { 941fa44ecaSJames Bottomley struct work_struct work; 951fa44ecaSJames Bottomley }; 961fa44ecaSJames Bottomley 974e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 984e6045f1SJohannes Berg /* 994e6045f1SJohannes Berg * NB: because we have to copy the lockdep_map, setting _key 1004e6045f1SJohannes Berg * here is required, otherwise it could get initialised to the 1014e6045f1SJohannes Berg * copy of the lockdep_map! 1024e6045f1SJohannes Berg */ 1034e6045f1SJohannes Berg #define __WORK_INIT_LOCKDEP_MAP(n, k) \ 1044e6045f1SJohannes Berg .lockdep_map = STATIC_LOCKDEP_MAP_INIT(n, k), 1054e6045f1SJohannes Berg #else 1064e6045f1SJohannes Berg #define __WORK_INIT_LOCKDEP_MAP(n, k) 1074e6045f1SJohannes Berg #endif 1084e6045f1SJohannes Berg 10965f27f38SDavid Howells #define __WORK_INITIALIZER(n, f) { \ 110dc186ad7SThomas Gleixner .data = WORK_DATA_STATIC_INIT(), \ 11165f27f38SDavid Howells .entry = { &(n).entry, &(n).entry }, \ 11265f27f38SDavid Howells .func = (f), \ 1134e6045f1SJohannes Berg __WORK_INIT_LOCKDEP_MAP(#n, &(n)) \ 11465f27f38SDavid Howells } 11565f27f38SDavid Howells 11665f27f38SDavid Howells #define __DELAYED_WORK_INITIALIZER(n, f) { \ 11765f27f38SDavid Howells .work = __WORK_INITIALIZER((n).work, (f)), \ 1181da177e4SLinus Torvalds .timer = TIMER_INITIALIZER(NULL, 0, 0), \ 1191da177e4SLinus Torvalds } 1201da177e4SLinus Torvalds 12165f27f38SDavid Howells #define DECLARE_WORK(n, f) \ 12265f27f38SDavid Howells struct work_struct n = __WORK_INITIALIZER(n, f) 12365f27f38SDavid Howells 12465f27f38SDavid Howells #define DECLARE_DELAYED_WORK(n, f) \ 12565f27f38SDavid Howells struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f) 12665f27f38SDavid Howells 1271da177e4SLinus Torvalds /* 12865f27f38SDavid Howells * initialize a work item's function pointer 1291da177e4SLinus Torvalds */ 13065f27f38SDavid Howells #define PREPARE_WORK(_work, _func) \ 1311da177e4SLinus Torvalds do { \ 13252bad64dSDavid Howells (_work)->func = (_func); \ 1331da177e4SLinus Torvalds } while (0) 1341da177e4SLinus Torvalds 13565f27f38SDavid Howells #define PREPARE_DELAYED_WORK(_work, _func) \ 13665f27f38SDavid Howells PREPARE_WORK(&(_work)->work, (_func)) 13752bad64dSDavid Howells 138dc186ad7SThomas Gleixner #ifdef CONFIG_DEBUG_OBJECTS_WORK 139dc186ad7SThomas Gleixner extern void __init_work(struct work_struct *work, int onstack); 140dc186ad7SThomas Gleixner extern void destroy_work_on_stack(struct work_struct *work); 1414690c4abSTejun Heo static inline unsigned int work_static(struct work_struct *work) 1424690c4abSTejun Heo { 14322df02bbSTejun Heo return *work_data_bits(work) & WORK_STRUCT_STATIC; 1444690c4abSTejun Heo } 145dc186ad7SThomas Gleixner #else 146dc186ad7SThomas Gleixner static inline void __init_work(struct work_struct *work, int onstack) { } 147dc186ad7SThomas Gleixner static inline void destroy_work_on_stack(struct work_struct *work) { } 1484690c4abSTejun Heo static inline unsigned int work_static(struct work_struct *work) { return 0; } 149dc186ad7SThomas Gleixner #endif 150dc186ad7SThomas Gleixner 1511da177e4SLinus Torvalds /* 15252bad64dSDavid Howells * initialize all of a work item in one go 153a08727baSLinus Torvalds * 154b9049df5SDmitri Vorobiev * NOTE! No point in using "atomic_long_set()": using a direct 155a08727baSLinus Torvalds * assignment of the work data initializer allows the compiler 156a08727baSLinus Torvalds * to generate better code. 1571da177e4SLinus Torvalds */ 1584e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 159dc186ad7SThomas Gleixner #define __INIT_WORK(_work, _func, _onstack) \ 1604e6045f1SJohannes Berg do { \ 1614e6045f1SJohannes Berg static struct lock_class_key __key; \ 1624e6045f1SJohannes Berg \ 163dc186ad7SThomas Gleixner __init_work((_work), _onstack); \ 1644e6045f1SJohannes Berg (_work)->data = (atomic_long_t) WORK_DATA_INIT(); \ 1654e6045f1SJohannes Berg lockdep_init_map(&(_work)->lockdep_map, #_work, &__key, 0);\ 1664e6045f1SJohannes Berg INIT_LIST_HEAD(&(_work)->entry); \ 1674e6045f1SJohannes Berg PREPARE_WORK((_work), (_func)); \ 1684e6045f1SJohannes Berg } while (0) 1694e6045f1SJohannes Berg #else 170dc186ad7SThomas Gleixner #define __INIT_WORK(_work, _func, _onstack) \ 1711da177e4SLinus Torvalds do { \ 172dc186ad7SThomas Gleixner __init_work((_work), _onstack); \ 17323b2e599SOleg Nesterov (_work)->data = (atomic_long_t) WORK_DATA_INIT(); \ 17465f27f38SDavid Howells INIT_LIST_HEAD(&(_work)->entry); \ 17565f27f38SDavid Howells PREPARE_WORK((_work), (_func)); \ 17665f27f38SDavid Howells } while (0) 1774e6045f1SJohannes Berg #endif 17865f27f38SDavid Howells 179dc186ad7SThomas Gleixner #define INIT_WORK(_work, _func) \ 180dc186ad7SThomas Gleixner do { \ 181dc186ad7SThomas Gleixner __INIT_WORK((_work), (_func), 0); \ 182dc186ad7SThomas Gleixner } while (0) 183dc186ad7SThomas Gleixner 184dc186ad7SThomas Gleixner #define INIT_WORK_ON_STACK(_work, _func) \ 185dc186ad7SThomas Gleixner do { \ 186dc186ad7SThomas Gleixner __INIT_WORK((_work), (_func), 1); \ 187dc186ad7SThomas Gleixner } while (0) 188dc186ad7SThomas Gleixner 18965f27f38SDavid Howells #define INIT_DELAYED_WORK(_work, _func) \ 19065f27f38SDavid Howells do { \ 19165f27f38SDavid Howells INIT_WORK(&(_work)->work, (_func)); \ 19265f27f38SDavid Howells init_timer(&(_work)->timer); \ 19365f27f38SDavid Howells } while (0) 19465f27f38SDavid Howells 1956d612b0fSPeter Zijlstra #define INIT_DELAYED_WORK_ON_STACK(_work, _func) \ 1966d612b0fSPeter Zijlstra do { \ 197dc186ad7SThomas Gleixner INIT_WORK_ON_STACK(&(_work)->work, (_func)); \ 1986d612b0fSPeter Zijlstra init_timer_on_stack(&(_work)->timer); \ 1996d612b0fSPeter Zijlstra } while (0) 2006d612b0fSPeter Zijlstra 20128287033SVenki Pallipadi #define INIT_DELAYED_WORK_DEFERRABLE(_work, _func) \ 20228287033SVenki Pallipadi do { \ 20328287033SVenki Pallipadi INIT_WORK(&(_work)->work, (_func)); \ 20428287033SVenki Pallipadi init_timer_deferrable(&(_work)->timer); \ 20528287033SVenki Pallipadi } while (0) 20628287033SVenki Pallipadi 207365970a1SDavid Howells /** 208365970a1SDavid Howells * work_pending - Find out whether a work item is currently pending 209365970a1SDavid Howells * @work: The work item in question 210365970a1SDavid Howells */ 211365970a1SDavid Howells #define work_pending(work) \ 21222df02bbSTejun Heo test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) 213365970a1SDavid Howells 214365970a1SDavid Howells /** 215365970a1SDavid Howells * delayed_work_pending - Find out whether a delayable work item is currently 216365970a1SDavid Howells * pending 217365970a1SDavid Howells * @work: The work item in question 218365970a1SDavid Howells */ 2190221872aSLinus Torvalds #define delayed_work_pending(w) \ 2200221872aSLinus Torvalds work_pending(&(w)->work) 221365970a1SDavid Howells 22265f27f38SDavid Howells /** 22323b2e599SOleg Nesterov * work_clear_pending - for internal use only, mark a work item as not pending 22423b2e599SOleg Nesterov * @work: The work item in question 22565f27f38SDavid Howells */ 22623b2e599SOleg Nesterov #define work_clear_pending(work) \ 22722df02bbSTejun Heo clear_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) 22865f27f38SDavid Howells 22997e37d7bSTejun Heo enum { 23097e37d7bSTejun Heo WQ_FREEZEABLE = 1 << 0, /* freeze during suspend */ 231502ca9d8STejun Heo WQ_SINGLE_CPU = 1 << 1, /* only single cpu at a time */ 23218aa9effSTejun Heo WQ_NON_REENTRANT = 1 << 2, /* guarantee non-reentrance */ 233e22bee78STejun Heo WQ_RESCUER = 1 << 3, /* has an rescue worker */ 234b71ab8c2STejun Heo 235b71ab8c2STejun Heo WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ 236b71ab8c2STejun Heo WQ_DFL_ACTIVE = WQ_MAX_ACTIVE / 2, 23797e37d7bSTejun Heo }; 23852bad64dSDavid Howells 239d320c038STejun Heo /* 240d320c038STejun Heo * System-wide workqueues which are always present. 241d320c038STejun Heo * 242d320c038STejun Heo * system_wq is the one used by schedule[_delayed]_work[_on](). 243d320c038STejun Heo * Multi-CPU multi-threaded. There are users which expect relatively 244d320c038STejun Heo * short queue flush time. Don't queue works which can run for too 245d320c038STejun Heo * long. 246d320c038STejun Heo * 247d320c038STejun Heo * system_long_wq is similar to system_wq but may host long running 248d320c038STejun Heo * works. Queue flushing might take relatively long. 249d320c038STejun Heo * 250d320c038STejun Heo * system_nrt_wq is non-reentrant and guarantees that any given work 251d320c038STejun Heo * item is never executed in parallel by multiple CPUs. Queue 252d320c038STejun Heo * flushing might take relatively long. 253d320c038STejun Heo */ 254d320c038STejun Heo extern struct workqueue_struct *system_wq; 255d320c038STejun Heo extern struct workqueue_struct *system_long_wq; 256d320c038STejun Heo extern struct workqueue_struct *system_nrt_wq; 257d320c038STejun Heo 2584e6045f1SJohannes Berg extern struct workqueue_struct * 259d320c038STejun Heo __alloc_workqueue_key(const char *name, unsigned int flags, int max_active, 260c790bce0STejun Heo struct lock_class_key *key, const char *lock_name); 2614e6045f1SJohannes Berg 2624e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 263d320c038STejun Heo #define alloc_workqueue(name, flags, max_active) \ 2644e6045f1SJohannes Berg ({ \ 2654e6045f1SJohannes Berg static struct lock_class_key __key; \ 266eb13ba87SJohannes Berg const char *__lock_name; \ 267eb13ba87SJohannes Berg \ 268eb13ba87SJohannes Berg if (__builtin_constant_p(name)) \ 269eb13ba87SJohannes Berg __lock_name = (name); \ 270eb13ba87SJohannes Berg else \ 271eb13ba87SJohannes Berg __lock_name = #name; \ 2724e6045f1SJohannes Berg \ 273d320c038STejun Heo __alloc_workqueue_key((name), (flags), (max_active), \ 2741e19ffc6STejun Heo &__key, __lock_name); \ 2754e6045f1SJohannes Berg }) 2764e6045f1SJohannes Berg #else 277d320c038STejun Heo #define alloc_workqueue(name, flags, max_active) \ 278d320c038STejun Heo __alloc_workqueue_key((name), (flags), (max_active), NULL, NULL) 2794e6045f1SJohannes Berg #endif 2804e6045f1SJohannes Berg 28197e37d7bSTejun Heo #define create_workqueue(name) \ 282d320c038STejun Heo alloc_workqueue((name), WQ_RESCUER, 1) 28397e37d7bSTejun Heo #define create_freezeable_workqueue(name) \ 284d320c038STejun Heo alloc_workqueue((name), WQ_FREEZEABLE | WQ_SINGLE_CPU | WQ_RESCUER, 1) 28597e37d7bSTejun Heo #define create_singlethread_workqueue(name) \ 286d320c038STejun Heo alloc_workqueue((name), WQ_SINGLE_CPU | WQ_RESCUER, 1) 2871da177e4SLinus Torvalds 2881da177e4SLinus Torvalds extern void destroy_workqueue(struct workqueue_struct *wq); 2891da177e4SLinus Torvalds 290b3c97528SHarvey Harrison extern int queue_work(struct workqueue_struct *wq, struct work_struct *work); 291c1a220e7SZhang Rui extern int queue_work_on(int cpu, struct workqueue_struct *wq, 292c1a220e7SZhang Rui struct work_struct *work); 293b3c97528SHarvey Harrison extern int queue_delayed_work(struct workqueue_struct *wq, 294b3c97528SHarvey Harrison struct delayed_work *work, unsigned long delay); 2957a6bc1cdSVenkatesh Pallipadi extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 29652bad64dSDavid Howells struct delayed_work *work, unsigned long delay); 29728e53bddSOleg Nesterov 298b3c97528SHarvey Harrison extern void flush_workqueue(struct workqueue_struct *wq); 29928e53bddSOleg Nesterov extern void flush_scheduled_work(void); 30043046b60SLinus Torvalds extern void flush_delayed_work(struct delayed_work *work); 3011da177e4SLinus Torvalds 302b3c97528SHarvey Harrison extern int schedule_work(struct work_struct *work); 303c1a220e7SZhang Rui extern int schedule_work_on(int cpu, struct work_struct *work); 304b3c97528SHarvey Harrison extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay); 30528e53bddSOleg Nesterov extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, 30628e53bddSOleg Nesterov unsigned long delay); 30765f27f38SDavid Howells extern int schedule_on_each_cpu(work_func_t func); 3081da177e4SLinus Torvalds extern int keventd_up(void); 3091da177e4SLinus Torvalds 3101da177e4SLinus Torvalds extern void init_workqueues(void); 31165f27f38SDavid Howells int execute_in_process_context(work_func_t fn, struct execute_work *); 3121da177e4SLinus Torvalds 313db700897SOleg Nesterov extern int flush_work(struct work_struct *work); 3141f1f642eSOleg Nesterov extern int cancel_work_sync(struct work_struct *work); 31528e53bddSOleg Nesterov 316dcd989cbSTejun Heo extern void workqueue_set_max_active(struct workqueue_struct *wq, 317dcd989cbSTejun Heo int max_active); 318dcd989cbSTejun Heo extern bool workqueue_congested(unsigned int cpu, struct workqueue_struct *wq); 319dcd989cbSTejun Heo extern unsigned int work_cpu(struct work_struct *work); 320dcd989cbSTejun Heo extern unsigned int work_busy(struct work_struct *work); 321dcd989cbSTejun Heo 3221da177e4SLinus Torvalds /* 3231da177e4SLinus Torvalds * Kill off a pending schedule_delayed_work(). Note that the work callback 324071b6386SOleg Nesterov * function may still be running on return from cancel_delayed_work(), unless 325071b6386SOleg Nesterov * it returns 1 and the work doesn't re-arm itself. Run flush_workqueue() or 32628e53bddSOleg Nesterov * cancel_work_sync() to wait on it. 3271da177e4SLinus Torvalds */ 32852bad64dSDavid Howells static inline int cancel_delayed_work(struct delayed_work *work) 3291da177e4SLinus Torvalds { 3301da177e4SLinus Torvalds int ret; 3311da177e4SLinus Torvalds 332223a10a9SOleg Nesterov ret = del_timer_sync(&work->timer); 3331da177e4SLinus Torvalds if (ret) 33423b2e599SOleg Nesterov work_clear_pending(&work->work); 3351da177e4SLinus Torvalds return ret; 3361da177e4SLinus Torvalds } 3371da177e4SLinus Torvalds 3384e49627bSOleg Nesterov /* 3394e49627bSOleg Nesterov * Like above, but uses del_timer() instead of del_timer_sync(). This means, 3404e49627bSOleg Nesterov * if it returns 0 the timer function may be running and the queueing is in 3414e49627bSOleg Nesterov * progress. 3424e49627bSOleg Nesterov */ 3434e49627bSOleg Nesterov static inline int __cancel_delayed_work(struct delayed_work *work) 3444e49627bSOleg Nesterov { 3454e49627bSOleg Nesterov int ret; 3464e49627bSOleg Nesterov 3474e49627bSOleg Nesterov ret = del_timer(&work->timer); 3484e49627bSOleg Nesterov if (ret) 3494e49627bSOleg Nesterov work_clear_pending(&work->work); 3504e49627bSOleg Nesterov return ret; 3514e49627bSOleg Nesterov } 3524e49627bSOleg Nesterov 3531f1f642eSOleg Nesterov extern int cancel_delayed_work_sync(struct delayed_work *work); 3541634c48fSOleg Nesterov 355f5a421a4SOleg Nesterov /* Obsolete. use cancel_delayed_work_sync() */ 3561634c48fSOleg Nesterov static inline 3571634c48fSOleg Nesterov void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq, 3581634c48fSOleg Nesterov struct delayed_work *work) 3591634c48fSOleg Nesterov { 360f5a421a4SOleg Nesterov cancel_delayed_work_sync(work); 361f5a421a4SOleg Nesterov } 362f5a421a4SOleg Nesterov 363f5a421a4SOleg Nesterov /* Obsolete. use cancel_delayed_work_sync() */ 364f5a421a4SOleg Nesterov static inline 365f5a421a4SOleg Nesterov void cancel_rearming_delayed_work(struct delayed_work *work) 366f5a421a4SOleg Nesterov { 367f5a421a4SOleg Nesterov cancel_delayed_work_sync(work); 3681634c48fSOleg Nesterov } 3691634c48fSOleg Nesterov 3702d3854a3SRusty Russell #ifndef CONFIG_SMP 3712d3854a3SRusty Russell static inline long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) 3722d3854a3SRusty Russell { 3732d3854a3SRusty Russell return fn(arg); 3742d3854a3SRusty Russell } 3752d3854a3SRusty Russell #else 3762d3854a3SRusty Russell long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg); 3772d3854a3SRusty Russell #endif /* CONFIG_SMP */ 378a0a1a5fdSTejun Heo 379a0a1a5fdSTejun Heo #ifdef CONFIG_FREEZER 380a0a1a5fdSTejun Heo extern void freeze_workqueues_begin(void); 381a0a1a5fdSTejun Heo extern bool freeze_workqueues_busy(void); 382a0a1a5fdSTejun Heo extern void thaw_workqueues(void); 383a0a1a5fdSTejun Heo #endif /* CONFIG_FREEZER */ 384a0a1a5fdSTejun Heo 3851da177e4SLinus Torvalds #endif 386