diff options
Diffstat (limited to 'include/linux/workqueue.h')
| -rw-r--r-- | include/linux/workqueue.h | 95 |
1 files changed, 30 insertions, 65 deletions
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index f16ba1e0687d..d555f31c0746 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h | |||
| @@ -24,15 +24,13 @@ typedef void (*work_func_t)(struct work_struct *work); | |||
| 24 | struct work_struct { | 24 | struct work_struct { |
| 25 | atomic_long_t data; | 25 | atomic_long_t data; |
| 26 | #define WORK_STRUCT_PENDING 0 /* T if work item pending execution */ | 26 | #define WORK_STRUCT_PENDING 0 /* T if work item pending execution */ |
| 27 | #define WORK_STRUCT_NOAUTOREL 1 /* F if work item automatically released on exec */ | ||
| 28 | #define WORK_STRUCT_FLAG_MASK (3UL) | 27 | #define WORK_STRUCT_FLAG_MASK (3UL) |
| 29 | #define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK) | 28 | #define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK) |
| 30 | struct list_head entry; | 29 | struct list_head entry; |
| 31 | work_func_t func; | 30 | work_func_t func; |
| 32 | }; | 31 | }; |
| 33 | 32 | ||
| 34 | #define WORK_DATA_INIT(autorelease) \ | 33 | #define WORK_DATA_INIT() ATOMIC_LONG_INIT(0) |
| 35 | ATOMIC_LONG_INIT((autorelease) << WORK_STRUCT_NOAUTOREL) | ||
| 36 | 34 | ||
| 37 | struct delayed_work { | 35 | struct delayed_work { |
| 38 | struct work_struct work; | 36 | struct work_struct work; |
| @@ -44,14 +42,8 @@ struct execute_work { | |||
| 44 | }; | 42 | }; |
| 45 | 43 | ||
| 46 | #define __WORK_INITIALIZER(n, f) { \ | 44 | #define __WORK_INITIALIZER(n, f) { \ |
| 47 | .data = WORK_DATA_INIT(0), \ | 45 | .data = WORK_DATA_INIT(), \ |
| 48 | .entry = { &(n).entry, &(n).entry }, \ | 46 | .entry = { &(n).entry, &(n).entry }, \ |
| 49 | .func = (f), \ | ||
| 50 | } | ||
| 51 | |||
| 52 | #define __WORK_INITIALIZER_NAR(n, f) { \ | ||
| 53 | .data = WORK_DATA_INIT(1), \ | ||
| 54 | .entry = { &(n).entry, &(n).entry }, \ | ||
| 55 | .func = (f), \ | 47 | .func = (f), \ |
| 56 | } | 48 | } |
| 57 | 49 | ||
| @@ -60,23 +52,12 @@ struct execute_work { | |||
| 60 | .timer = TIMER_INITIALIZER(NULL, 0, 0), \ | 52 | .timer = TIMER_INITIALIZER(NULL, 0, 0), \ |
| 61 | } | 53 | } |
| 62 | 54 | ||
| 63 | #define __DELAYED_WORK_INITIALIZER_NAR(n, f) { \ | ||
| 64 | .work = __WORK_INITIALIZER_NAR((n).work, (f)), \ | ||
| 65 | .timer = TIMER_INITIALIZER(NULL, 0, 0), \ | ||
| 66 | } | ||
| 67 | |||
| 68 | #define DECLARE_WORK(n, f) \ | 55 | #define DECLARE_WORK(n, f) \ |
| 69 | struct work_struct n = __WORK_INITIALIZER(n, f) | 56 | struct work_struct n = __WORK_INITIALIZER(n, f) |
| 70 | 57 | ||
| 71 | #define DECLARE_WORK_NAR(n, f) \ | ||
| 72 | struct work_struct n = __WORK_INITIALIZER_NAR(n, f) | ||
| 73 | |||
| 74 | #define DECLARE_DELAYED_WORK(n, f) \ | 58 | #define DECLARE_DELAYED_WORK(n, f) \ |
| 75 | struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f) | 59 | struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f) |
| 76 | 60 | ||
| 77 | #define DECLARE_DELAYED_WORK_NAR(n, f) \ | ||
| 78 | struct dwork_struct n = __DELAYED_WORK_INITIALIZER_NAR(n, f) | ||
| 79 | |||
| 80 | /* | 61 | /* |
| 81 | * initialize a work item's function pointer | 62 | * initialize a work item's function pointer |
| 82 | */ | 63 | */ |
| @@ -95,16 +76,9 @@ struct execute_work { | |||
| 95 | * assignment of the work data initializer allows the compiler | 76 | * assignment of the work data initializer allows the compiler |
| 96 | * to generate better code. | 77 | * to generate better code. |
| 97 | */ | 78 | */ |
| 98 | #define INIT_WORK(_work, _func) \ | 79 | #define INIT_WORK(_work, _func) \ |
| 99 | do { \ | ||
| 100 | (_work)->data = (atomic_long_t) WORK_DATA_INIT(0); \ | ||
| 101 | INIT_LIST_HEAD(&(_work)->entry); \ | ||
| 102 | PREPARE_WORK((_work), (_func)); \ | ||
| 103 | } while (0) | ||
| 104 | |||
| 105 | #define INIT_WORK_NAR(_work, _func) \ | ||
| 106 | do { \ | 80 | do { \ |
| 107 | (_work)->data = (atomic_long_t) WORK_DATA_INIT(1); \ | 81 | (_work)->data = (atomic_long_t) WORK_DATA_INIT(); \ |
| 108 | INIT_LIST_HEAD(&(_work)->entry); \ | 82 | INIT_LIST_HEAD(&(_work)->entry); \ |
| 109 | PREPARE_WORK((_work), (_func)); \ | 83 | PREPARE_WORK((_work), (_func)); \ |
| 110 | } while (0) | 84 | } while (0) |
| @@ -115,12 +89,6 @@ struct execute_work { | |||
| 115 | init_timer(&(_work)->timer); \ | 89 | init_timer(&(_work)->timer); \ |
| 116 | } while (0) | 90 | } while (0) |
| 117 | 91 | ||
| 118 | #define INIT_DELAYED_WORK_NAR(_work, _func) \ | ||
| 119 | do { \ | ||
| 120 | INIT_WORK_NAR(&(_work)->work, (_func)); \ | ||
| 121 | init_timer(&(_work)->timer); \ | ||
| 122 | } while (0) | ||
| 123 | |||
| 124 | #define INIT_DELAYED_WORK_DEFERRABLE(_work, _func) \ | 92 | #define INIT_DELAYED_WORK_DEFERRABLE(_work, _func) \ |
| 125 | do { \ | 93 | do { \ |
| 126 | INIT_WORK(&(_work)->work, (_func)); \ | 94 | INIT_WORK(&(_work)->work, (_func)); \ |
| @@ -143,24 +111,10 @@ struct execute_work { | |||
| 143 | work_pending(&(w)->work) | 111 | work_pending(&(w)->work) |
| 144 | 112 | ||
| 145 | /** | 113 | /** |
| 146 | * work_release - Release a work item under execution | 114 | * work_clear_pending - for internal use only, mark a work item as not pending |
| 147 | * @work: The work item to release | 115 | * @work: The work item in question |
| 148 | * | ||
| 149 | * This is used to release a work item that has been initialised with automatic | ||
| 150 | * release mode disabled (WORK_STRUCT_NOAUTOREL is set). This gives the work | ||
| 151 | * function the opportunity to grab auxiliary data from the container of the | ||
| 152 | * work_struct before clearing the pending bit as the work_struct may be | ||
| 153 | * subject to deallocation the moment the pending bit is cleared. | ||
| 154 | * | ||
| 155 | * In such a case, this should be called in the work function after it has | ||
| 156 | * fetched any data it may require from the containter of the work_struct. | ||
| 157 | * After this function has been called, the work_struct may be scheduled for | ||
| 158 | * further execution or it may be deallocated unless other precautions are | ||
| 159 | * taken. | ||
| 160 | * | ||
| 161 | * This should also be used to release a delayed work item. | ||
| 162 | */ | 116 | */ |
| 163 | #define work_release(work) \ | 117 | #define work_clear_pending(work) \ |
| 164 | clear_bit(WORK_STRUCT_PENDING, work_data_bits(work)) | 118 | clear_bit(WORK_STRUCT_PENDING, work_data_bits(work)) |
| 165 | 119 | ||
| 166 | 120 | ||
| @@ -174,27 +128,28 @@ extern struct workqueue_struct *__create_workqueue(const char *name, | |||
| 174 | extern void destroy_workqueue(struct workqueue_struct *wq); | 128 | extern void destroy_workqueue(struct workqueue_struct *wq); |
| 175 | 129 | ||
| 176 | extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work)); | 130 | extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work)); |
| 177 | extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay)); | 131 | extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, |
| 132 | struct delayed_work *work, unsigned long delay)); | ||
| 178 | extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | 133 | extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, |
| 179 | struct delayed_work *work, unsigned long delay); | 134 | struct delayed_work *work, unsigned long delay); |
| 135 | |||
| 180 | extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq)); | 136 | extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq)); |
| 137 | extern void flush_scheduled_work(void); | ||
| 181 | 138 | ||
| 182 | extern int FASTCALL(schedule_work(struct work_struct *work)); | 139 | extern int FASTCALL(schedule_work(struct work_struct *work)); |
| 183 | extern int FASTCALL(run_scheduled_work(struct work_struct *work)); | 140 | extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, |
| 184 | extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay)); | 141 | unsigned long delay)); |
| 185 | 142 | extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, | |
| 186 | extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay); | 143 | unsigned long delay); |
| 187 | extern int schedule_on_each_cpu(work_func_t func); | 144 | extern int schedule_on_each_cpu(work_func_t func); |
| 188 | extern void flush_scheduled_work(void); | ||
| 189 | extern int current_is_keventd(void); | 145 | extern int current_is_keventd(void); |
| 190 | extern int keventd_up(void); | 146 | extern int keventd_up(void); |
| 191 | 147 | ||
| 192 | extern void init_workqueues(void); | 148 | extern void init_workqueues(void); |
| 193 | void cancel_rearming_delayed_work(struct delayed_work *work); | ||
| 194 | void cancel_rearming_delayed_workqueue(struct workqueue_struct *, | ||
| 195 | struct delayed_work *); | ||
| 196 | int execute_in_process_context(work_func_t fn, struct execute_work *); | 149 | int execute_in_process_context(work_func_t fn, struct execute_work *); |
| 197 | 150 | ||
| 151 | extern void cancel_work_sync(struct work_struct *work); | ||
| 152 | |||
| 198 | /* | 153 | /* |
| 199 | * Kill off a pending schedule_delayed_work(). Note that the work callback | 154 | * Kill off a pending schedule_delayed_work(). Note that the work callback |
| 200 | * function may still be running on return from cancel_delayed_work(), unless | 155 | * function may still be running on return from cancel_delayed_work(), unless |
| @@ -207,8 +162,18 @@ static inline int cancel_delayed_work(struct delayed_work *work) | |||
| 207 | 162 | ||
| 208 | ret = del_timer(&work->timer); | 163 | ret = del_timer(&work->timer); |
| 209 | if (ret) | 164 | if (ret) |
| 210 | work_release(&work->work); | 165 | work_clear_pending(&work->work); |
| 211 | return ret; | 166 | return ret; |
| 212 | } | 167 | } |
| 213 | 168 | ||
| 169 | extern void cancel_rearming_delayed_work(struct delayed_work *work); | ||
| 170 | |||
| 171 | /* Obsolete. use cancel_rearming_delayed_work() */ | ||
| 172 | static inline | ||
| 173 | void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq, | ||
| 174 | struct delayed_work *work) | ||
| 175 | { | ||
| 176 | cancel_rearming_delayed_work(work); | ||
| 177 | } | ||
| 178 | |||
| 214 | #endif | 179 | #endif |
