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 53bdbc5dd7STejun Heo /* special cpu IDs */ 54bdbc5dd7STejun Heo WORK_CPU_NONE = NR_CPUS, 55bdbc5dd7STejun Heo WORK_CPU_LAST = WORK_CPU_NONE, 56bdbc5dd7STejun Heo 5773f53c4aSTejun Heo /* 5873f53c4aSTejun Heo * Reserve 6 bits off of cwq pointer w/ debugobjects turned 5973f53c4aSTejun Heo * off. This makes cwqs aligned to 64 bytes which isn't too 6073f53c4aSTejun Heo * excessive while allowing 15 workqueue flush colors. 6173f53c4aSTejun Heo */ 6273f53c4aSTejun Heo WORK_STRUCT_FLAG_BITS = WORK_STRUCT_COLOR_SHIFT + 6373f53c4aSTejun Heo WORK_STRUCT_COLOR_BITS, 6473f53c4aSTejun Heo 650f900049STejun Heo WORK_STRUCT_FLAG_MASK = (1UL << WORK_STRUCT_FLAG_BITS) - 1, 6622df02bbSTejun Heo WORK_STRUCT_WQ_DATA_MASK = ~WORK_STRUCT_FLAG_MASK, 67bdbc5dd7STejun Heo WORK_STRUCT_NO_CPU = WORK_CPU_NONE << WORK_STRUCT_FLAG_BITS, 68dcd989cbSTejun Heo 69dcd989cbSTejun Heo /* bit mask for work_busy() return values */ 70dcd989cbSTejun Heo WORK_BUSY_PENDING = 1 << 0, 71dcd989cbSTejun Heo WORK_BUSY_RUNNING = 1 << 1, 7222df02bbSTejun Heo }; 7322df02bbSTejun Heo 741da177e4SLinus Torvalds struct work_struct { 75a08727baSLinus Torvalds atomic_long_t data; 761da177e4SLinus Torvalds struct list_head entry; 776bb49e59SDavid Howells work_func_t func; 784e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 794e6045f1SJohannes Berg struct lockdep_map lockdep_map; 804e6045f1SJohannes Berg #endif 8152bad64dSDavid Howells }; 8252bad64dSDavid Howells 837a22ad75STejun Heo #define WORK_DATA_INIT() ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU) 847a22ad75STejun Heo #define WORK_DATA_STATIC_INIT() \ 857a22ad75STejun Heo ATOMIC_LONG_INIT(WORK_STRUCT_NO_CPU | WORK_STRUCT_STATIC) 86a08727baSLinus Torvalds 8752bad64dSDavid Howells struct delayed_work { 8852bad64dSDavid Howells struct work_struct work; 891da177e4SLinus Torvalds struct timer_list timer; 901da177e4SLinus Torvalds }; 911da177e4SLinus Torvalds 92bf6aede7SJean Delvare static inline struct delayed_work *to_delayed_work(struct work_struct *work) 93bf6aede7SJean Delvare { 94bf6aede7SJean Delvare return container_of(work, struct delayed_work, work); 95bf6aede7SJean Delvare } 96bf6aede7SJean Delvare 971fa44ecaSJames Bottomley struct execute_work { 981fa44ecaSJames Bottomley struct work_struct work; 991fa44ecaSJames Bottomley }; 1001fa44ecaSJames Bottomley 1014e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 1024e6045f1SJohannes Berg /* 1034e6045f1SJohannes Berg * NB: because we have to copy the lockdep_map, setting _key 1044e6045f1SJohannes Berg * here is required, otherwise it could get initialised to the 1054e6045f1SJohannes Berg * copy of the lockdep_map! 1064e6045f1SJohannes Berg */ 1074e6045f1SJohannes Berg #define __WORK_INIT_LOCKDEP_MAP(n, k) \ 1084e6045f1SJohannes Berg .lockdep_map = STATIC_LOCKDEP_MAP_INIT(n, k), 1094e6045f1SJohannes Berg #else 1104e6045f1SJohannes Berg #define __WORK_INIT_LOCKDEP_MAP(n, k) 1114e6045f1SJohannes Berg #endif 1124e6045f1SJohannes Berg 11365f27f38SDavid Howells #define __WORK_INITIALIZER(n, f) { \ 114dc186ad7SThomas Gleixner .data = WORK_DATA_STATIC_INIT(), \ 11565f27f38SDavid Howells .entry = { &(n).entry, &(n).entry }, \ 11665f27f38SDavid Howells .func = (f), \ 1174e6045f1SJohannes Berg __WORK_INIT_LOCKDEP_MAP(#n, &(n)) \ 11865f27f38SDavid Howells } 11965f27f38SDavid Howells 12065f27f38SDavid Howells #define __DELAYED_WORK_INITIALIZER(n, f) { \ 12165f27f38SDavid Howells .work = __WORK_INITIALIZER((n).work, (f)), \ 1221da177e4SLinus Torvalds .timer = TIMER_INITIALIZER(NULL, 0, 0), \ 1231da177e4SLinus Torvalds } 1241da177e4SLinus Torvalds 12565f27f38SDavid Howells #define DECLARE_WORK(n, f) \ 12665f27f38SDavid Howells struct work_struct n = __WORK_INITIALIZER(n, f) 12765f27f38SDavid Howells 12865f27f38SDavid Howells #define DECLARE_DELAYED_WORK(n, f) \ 12965f27f38SDavid Howells struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f) 13065f27f38SDavid Howells 1311da177e4SLinus Torvalds /* 13265f27f38SDavid Howells * initialize a work item's function pointer 1331da177e4SLinus Torvalds */ 13465f27f38SDavid Howells #define PREPARE_WORK(_work, _func) \ 1351da177e4SLinus Torvalds do { \ 13652bad64dSDavid Howells (_work)->func = (_func); \ 1371da177e4SLinus Torvalds } while (0) 1381da177e4SLinus Torvalds 13965f27f38SDavid Howells #define PREPARE_DELAYED_WORK(_work, _func) \ 14065f27f38SDavid Howells PREPARE_WORK(&(_work)->work, (_func)) 14152bad64dSDavid Howells 142dc186ad7SThomas Gleixner #ifdef CONFIG_DEBUG_OBJECTS_WORK 143dc186ad7SThomas Gleixner extern void __init_work(struct work_struct *work, int onstack); 144dc186ad7SThomas Gleixner extern void destroy_work_on_stack(struct work_struct *work); 1454690c4abSTejun Heo static inline unsigned int work_static(struct work_struct *work) 1464690c4abSTejun Heo { 14722df02bbSTejun Heo return *work_data_bits(work) & WORK_STRUCT_STATIC; 1484690c4abSTejun Heo } 149dc186ad7SThomas Gleixner #else 150dc186ad7SThomas Gleixner static inline void __init_work(struct work_struct *work, int onstack) { } 151dc186ad7SThomas Gleixner static inline void destroy_work_on_stack(struct work_struct *work) { } 1524690c4abSTejun Heo static inline unsigned int work_static(struct work_struct *work) { return 0; } 153dc186ad7SThomas Gleixner #endif 154dc186ad7SThomas Gleixner 1551da177e4SLinus Torvalds /* 15652bad64dSDavid Howells * initialize all of a work item in one go 157a08727baSLinus Torvalds * 158b9049df5SDmitri Vorobiev * NOTE! No point in using "atomic_long_set()": using a direct 159a08727baSLinus Torvalds * assignment of the work data initializer allows the compiler 160a08727baSLinus Torvalds * to generate better code. 1611da177e4SLinus Torvalds */ 1624e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 163dc186ad7SThomas Gleixner #define __INIT_WORK(_work, _func, _onstack) \ 1644e6045f1SJohannes Berg do { \ 1654e6045f1SJohannes Berg static struct lock_class_key __key; \ 1664e6045f1SJohannes Berg \ 167dc186ad7SThomas Gleixner __init_work((_work), _onstack); \ 1684e6045f1SJohannes Berg (_work)->data = (atomic_long_t) WORK_DATA_INIT(); \ 1694e6045f1SJohannes Berg lockdep_init_map(&(_work)->lockdep_map, #_work, &__key, 0);\ 1704e6045f1SJohannes Berg INIT_LIST_HEAD(&(_work)->entry); \ 1714e6045f1SJohannes Berg PREPARE_WORK((_work), (_func)); \ 1724e6045f1SJohannes Berg } while (0) 1734e6045f1SJohannes Berg #else 174dc186ad7SThomas Gleixner #define __INIT_WORK(_work, _func, _onstack) \ 1751da177e4SLinus Torvalds do { \ 176dc186ad7SThomas Gleixner __init_work((_work), _onstack); \ 17723b2e599SOleg Nesterov (_work)->data = (atomic_long_t) WORK_DATA_INIT(); \ 17865f27f38SDavid Howells INIT_LIST_HEAD(&(_work)->entry); \ 17965f27f38SDavid Howells PREPARE_WORK((_work), (_func)); \ 18065f27f38SDavid Howells } while (0) 1814e6045f1SJohannes Berg #endif 18265f27f38SDavid Howells 183dc186ad7SThomas Gleixner #define INIT_WORK(_work, _func) \ 184dc186ad7SThomas Gleixner do { \ 185dc186ad7SThomas Gleixner __INIT_WORK((_work), (_func), 0); \ 186dc186ad7SThomas Gleixner } while (0) 187dc186ad7SThomas Gleixner 188dc186ad7SThomas Gleixner #define INIT_WORK_ON_STACK(_work, _func) \ 189dc186ad7SThomas Gleixner do { \ 190dc186ad7SThomas Gleixner __INIT_WORK((_work), (_func), 1); \ 191dc186ad7SThomas Gleixner } while (0) 192dc186ad7SThomas Gleixner 19365f27f38SDavid Howells #define INIT_DELAYED_WORK(_work, _func) \ 19465f27f38SDavid Howells do { \ 19565f27f38SDavid Howells INIT_WORK(&(_work)->work, (_func)); \ 19665f27f38SDavid Howells init_timer(&(_work)->timer); \ 19765f27f38SDavid Howells } while (0) 19865f27f38SDavid Howells 1996d612b0fSPeter Zijlstra #define INIT_DELAYED_WORK_ON_STACK(_work, _func) \ 2006d612b0fSPeter Zijlstra do { \ 201dc186ad7SThomas Gleixner INIT_WORK_ON_STACK(&(_work)->work, (_func)); \ 2026d612b0fSPeter Zijlstra init_timer_on_stack(&(_work)->timer); \ 2036d612b0fSPeter Zijlstra } while (0) 2046d612b0fSPeter Zijlstra 20528287033SVenki Pallipadi #define INIT_DELAYED_WORK_DEFERRABLE(_work, _func) \ 20628287033SVenki Pallipadi do { \ 20728287033SVenki Pallipadi INIT_WORK(&(_work)->work, (_func)); \ 20828287033SVenki Pallipadi init_timer_deferrable(&(_work)->timer); \ 20928287033SVenki Pallipadi } while (0) 21028287033SVenki Pallipadi 211365970a1SDavid Howells /** 212365970a1SDavid Howells * work_pending - Find out whether a work item is currently pending 213365970a1SDavid Howells * @work: The work item in question 214365970a1SDavid Howells */ 215365970a1SDavid Howells #define work_pending(work) \ 21622df02bbSTejun Heo test_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) 217365970a1SDavid Howells 218365970a1SDavid Howells /** 219365970a1SDavid Howells * delayed_work_pending - Find out whether a delayable work item is currently 220365970a1SDavid Howells * pending 221365970a1SDavid Howells * @work: The work item in question 222365970a1SDavid Howells */ 2230221872aSLinus Torvalds #define delayed_work_pending(w) \ 2240221872aSLinus Torvalds work_pending(&(w)->work) 225365970a1SDavid Howells 22665f27f38SDavid Howells /** 22723b2e599SOleg Nesterov * work_clear_pending - for internal use only, mark a work item as not pending 22823b2e599SOleg Nesterov * @work: The work item in question 22965f27f38SDavid Howells */ 23023b2e599SOleg Nesterov #define work_clear_pending(work) \ 23122df02bbSTejun Heo clear_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work)) 23265f27f38SDavid Howells 23397e37d7bSTejun Heo enum { 234bdbc5dd7STejun Heo WQ_NON_REENTRANT = 1 << 0, /* guarantee non-reentrance */ 235502ca9d8STejun Heo WQ_SINGLE_CPU = 1 << 1, /* only single cpu at a time */ 236bdbc5dd7STejun Heo WQ_FREEZEABLE = 1 << 2, /* freeze during suspend */ 237e22bee78STejun Heo WQ_RESCUER = 1 << 3, /* has an rescue worker */ 238649027d7STejun Heo WQ_HIGHPRI = 1 << 4, /* high priority */ 239fb0e7bebSTejun Heo WQ_CPU_INTENSIVE = 1 << 5, /* cpu instensive workqueue */ 240b71ab8c2STejun Heo 241b71ab8c2STejun Heo WQ_MAX_ACTIVE = 512, /* I like 512, better ideas? */ 242b71ab8c2STejun Heo WQ_DFL_ACTIVE = WQ_MAX_ACTIVE / 2, 24397e37d7bSTejun Heo }; 24452bad64dSDavid Howells 245d320c038STejun Heo /* 246d320c038STejun Heo * System-wide workqueues which are always present. 247d320c038STejun Heo * 248d320c038STejun Heo * system_wq is the one used by schedule[_delayed]_work[_on](). 249d320c038STejun Heo * Multi-CPU multi-threaded. There are users which expect relatively 250d320c038STejun Heo * short queue flush time. Don't queue works which can run for too 251d320c038STejun Heo * long. 252d320c038STejun Heo * 253d320c038STejun Heo * system_long_wq is similar to system_wq but may host long running 254d320c038STejun Heo * works. Queue flushing might take relatively long. 255d320c038STejun Heo * 256d320c038STejun Heo * system_nrt_wq is non-reentrant and guarantees that any given work 257d320c038STejun Heo * item is never executed in parallel by multiple CPUs. Queue 258d320c038STejun Heo * flushing might take relatively long. 259d320c038STejun Heo */ 260d320c038STejun Heo extern struct workqueue_struct *system_wq; 261d320c038STejun Heo extern struct workqueue_struct *system_long_wq; 262d320c038STejun Heo extern struct workqueue_struct *system_nrt_wq; 263d320c038STejun Heo 2644e6045f1SJohannes Berg extern struct workqueue_struct * 265d320c038STejun Heo __alloc_workqueue_key(const char *name, unsigned int flags, int max_active, 266c790bce0STejun Heo struct lock_class_key *key, const char *lock_name); 2674e6045f1SJohannes Berg 2684e6045f1SJohannes Berg #ifdef CONFIG_LOCKDEP 269d320c038STejun Heo #define alloc_workqueue(name, flags, max_active) \ 2704e6045f1SJohannes Berg ({ \ 2714e6045f1SJohannes Berg static struct lock_class_key __key; \ 272eb13ba87SJohannes Berg const char *__lock_name; \ 273eb13ba87SJohannes Berg \ 274eb13ba87SJohannes Berg if (__builtin_constant_p(name)) \ 275eb13ba87SJohannes Berg __lock_name = (name); \ 276eb13ba87SJohannes Berg else \ 277eb13ba87SJohannes Berg __lock_name = #name; \ 2784e6045f1SJohannes Berg \ 279d320c038STejun Heo __alloc_workqueue_key((name), (flags), (max_active), \ 2801e19ffc6STejun Heo &__key, __lock_name); \ 2814e6045f1SJohannes Berg }) 2824e6045f1SJohannes Berg #else 283d320c038STejun Heo #define alloc_workqueue(name, flags, max_active) \ 284d320c038STejun Heo __alloc_workqueue_key((name), (flags), (max_active), NULL, NULL) 2854e6045f1SJohannes Berg #endif 2864e6045f1SJohannes Berg 28797e37d7bSTejun Heo #define create_workqueue(name) \ 288d320c038STejun Heo alloc_workqueue((name), WQ_RESCUER, 1) 28997e37d7bSTejun Heo #define create_freezeable_workqueue(name) \ 290d320c038STejun Heo alloc_workqueue((name), WQ_FREEZEABLE | WQ_SINGLE_CPU | WQ_RESCUER, 1) 29197e37d7bSTejun Heo #define create_singlethread_workqueue(name) \ 292d320c038STejun Heo alloc_workqueue((name), WQ_SINGLE_CPU | WQ_RESCUER, 1) 2931da177e4SLinus Torvalds 2941da177e4SLinus Torvalds extern void destroy_workqueue(struct workqueue_struct *wq); 2951da177e4SLinus Torvalds 296b3c97528SHarvey Harrison extern int queue_work(struct workqueue_struct *wq, struct work_struct *work); 297c1a220e7SZhang Rui extern int queue_work_on(int cpu, struct workqueue_struct *wq, 298c1a220e7SZhang Rui struct work_struct *work); 299b3c97528SHarvey Harrison extern int queue_delayed_work(struct workqueue_struct *wq, 300b3c97528SHarvey Harrison struct delayed_work *work, unsigned long delay); 3017a6bc1cdSVenkatesh Pallipadi extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 30252bad64dSDavid Howells struct delayed_work *work, unsigned long delay); 30328e53bddSOleg Nesterov 304b3c97528SHarvey Harrison extern void flush_workqueue(struct workqueue_struct *wq); 30528e53bddSOleg Nesterov extern void flush_scheduled_work(void); 30643046b60SLinus Torvalds extern void flush_delayed_work(struct delayed_work *work); 3071da177e4SLinus Torvalds 308b3c97528SHarvey Harrison extern int schedule_work(struct work_struct *work); 309c1a220e7SZhang Rui extern int schedule_work_on(int cpu, struct work_struct *work); 310b3c97528SHarvey Harrison extern int schedule_delayed_work(struct delayed_work *work, unsigned long delay); 31128e53bddSOleg Nesterov extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, 31228e53bddSOleg Nesterov unsigned long delay); 31365f27f38SDavid Howells extern int schedule_on_each_cpu(work_func_t func); 3141da177e4SLinus Torvalds extern int keventd_up(void); 3151da177e4SLinus Torvalds 3161da177e4SLinus Torvalds extern void init_workqueues(void); 31765f27f38SDavid Howells int execute_in_process_context(work_func_t fn, struct execute_work *); 3181da177e4SLinus Torvalds 319db700897SOleg Nesterov extern int flush_work(struct work_struct *work); 3201f1f642eSOleg Nesterov extern int cancel_work_sync(struct work_struct *work); 32128e53bddSOleg Nesterov 322dcd989cbSTejun Heo extern void workqueue_set_max_active(struct workqueue_struct *wq, 323dcd989cbSTejun Heo int max_active); 324dcd989cbSTejun Heo extern bool workqueue_congested(unsigned int cpu, struct workqueue_struct *wq); 325dcd989cbSTejun Heo extern unsigned int work_cpu(struct work_struct *work); 326dcd989cbSTejun Heo extern unsigned int work_busy(struct work_struct *work); 327dcd989cbSTejun Heo 3281da177e4SLinus Torvalds /* 3291da177e4SLinus Torvalds * Kill off a pending schedule_delayed_work(). Note that the work callback 330071b6386SOleg Nesterov * function may still be running on return from cancel_delayed_work(), unless 331071b6386SOleg Nesterov * it returns 1 and the work doesn't re-arm itself. Run flush_workqueue() or 33228e53bddSOleg Nesterov * cancel_work_sync() to wait on it. 3331da177e4SLinus Torvalds */ 33452bad64dSDavid Howells static inline int cancel_delayed_work(struct delayed_work *work) 3351da177e4SLinus Torvalds { 3361da177e4SLinus Torvalds int ret; 3371da177e4SLinus Torvalds 338223a10a9SOleg Nesterov ret = del_timer_sync(&work->timer); 3391da177e4SLinus Torvalds if (ret) 34023b2e599SOleg Nesterov work_clear_pending(&work->work); 3411da177e4SLinus Torvalds return ret; 3421da177e4SLinus Torvalds } 3431da177e4SLinus Torvalds 3444e49627bSOleg Nesterov /* 3454e49627bSOleg Nesterov * Like above, but uses del_timer() instead of del_timer_sync(). This means, 3464e49627bSOleg Nesterov * if it returns 0 the timer function may be running and the queueing is in 3474e49627bSOleg Nesterov * progress. 3484e49627bSOleg Nesterov */ 3494e49627bSOleg Nesterov static inline int __cancel_delayed_work(struct delayed_work *work) 3504e49627bSOleg Nesterov { 3514e49627bSOleg Nesterov int ret; 3524e49627bSOleg Nesterov 3534e49627bSOleg Nesterov ret = del_timer(&work->timer); 3544e49627bSOleg Nesterov if (ret) 3554e49627bSOleg Nesterov work_clear_pending(&work->work); 3564e49627bSOleg Nesterov return ret; 3574e49627bSOleg Nesterov } 3584e49627bSOleg Nesterov 3591f1f642eSOleg Nesterov extern int cancel_delayed_work_sync(struct delayed_work *work); 3601634c48fSOleg Nesterov 361f5a421a4SOleg Nesterov /* Obsolete. use cancel_delayed_work_sync() */ 3621634c48fSOleg Nesterov static inline 3631634c48fSOleg Nesterov void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq, 3641634c48fSOleg Nesterov struct delayed_work *work) 3651634c48fSOleg Nesterov { 366f5a421a4SOleg Nesterov cancel_delayed_work_sync(work); 367f5a421a4SOleg Nesterov } 368f5a421a4SOleg Nesterov 369f5a421a4SOleg Nesterov /* Obsolete. use cancel_delayed_work_sync() */ 370f5a421a4SOleg Nesterov static inline 371f5a421a4SOleg Nesterov void cancel_rearming_delayed_work(struct delayed_work *work) 372f5a421a4SOleg Nesterov { 373f5a421a4SOleg Nesterov cancel_delayed_work_sync(work); 3741634c48fSOleg Nesterov } 3751634c48fSOleg Nesterov 3762d3854a3SRusty Russell #ifndef CONFIG_SMP 3772d3854a3SRusty Russell static inline long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg) 3782d3854a3SRusty Russell { 3792d3854a3SRusty Russell return fn(arg); 3802d3854a3SRusty Russell } 3812d3854a3SRusty Russell #else 3822d3854a3SRusty Russell long work_on_cpu(unsigned int cpu, long (*fn)(void *), void *arg); 3832d3854a3SRusty Russell #endif /* CONFIG_SMP */ 384a0a1a5fdSTejun Heo 385a0a1a5fdSTejun Heo #ifdef CONFIG_FREEZER 386a0a1a5fdSTejun Heo extern void freeze_workqueues_begin(void); 387a0a1a5fdSTejun Heo extern bool freeze_workqueues_busy(void); 388a0a1a5fdSTejun Heo extern void thaw_workqueues(void); 389a0a1a5fdSTejun Heo #endif /* CONFIG_FREEZER */ 390a0a1a5fdSTejun Heo 3911da177e4SLinus Torvalds #endif 392