Add queue_delayed_work_on() interface for workqueues.
Showing the changes to kernel/workqueue.c (1 of 2 files). Show all
Unified · Split
| @@ -148,6 +148,27 @@ int fastcall queue_delayed_work(struct workqueue_struct *wq, · 147 unmodified lines | ||
| 148 | 148 | return ret; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | +int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, | |
| 152 | + struct work_struct *work, unsigned long delay) | |
| 153 | +{ | |
| 154 | + int ret = 0; | |
| 155 | + struct timer_list *timer = &work->timer; | |
| 156 | + | |
| 157 | + if (!test_and_set_bit(0, &work->pending)) { | |
| 158 | + BUG_ON(timer_pending(timer)); | |
| 159 | + BUG_ON(!list_empty(&work->entry)); | |
| 160 | + | |
| 161 | + /* This stores wq for the moment, for the timer_fn */ | |
| 162 | + work->wq_data = wq; | |
| 163 | + timer->expires = jiffies + delay; | |
| 164 | + timer->data = (unsigned long)work; | |
| 165 | + timer->function = delayed_work_timer_fn; | |
| 166 | + add_timer_on(timer, cpu); | |
| 167 | + ret = 1; | |
| 168 | + } | |
| 169 | + return ret; | |
| 170 | +} | |
| 171 | + | |
| 151 | 172 | static void run_workqueue(struct cpu_workqueue_struct *cwq) |
| 152 | 173 | { |
| 153 | 174 | unsigned long flags; |
| @@ -411,21 +432,7 @@ int fastcall schedule_delayed_work(struct work_struct *work, unsigned long delay · 257 unmodified lines | ||
| 411 | 432 | int schedule_delayed_work_on(int cpu, |
| 412 | 433 | struct work_struct *work, unsigned long delay) |
| 413 | 434 | { |
| 414 | − int ret = 0; | |
| 415 | − struct timer_list *timer = &work->timer; | |
| 416 | − | |
| 417 | − if (!test_and_set_bit(0, &work->pending)) { | |
| 418 | − BUG_ON(timer_pending(timer)); | |
| 419 | − BUG_ON(!list_empty(&work->entry)); | |
| 420 | − /* This stores keventd_wq for the moment, for the timer_fn */ | |
| 421 | − work->wq_data = keventd_wq; | |
| 422 | − timer->expires = jiffies + delay; | |
| 423 | − timer->data = (unsigned long)work; | |
| 424 | − timer->function = delayed_work_timer_fn; | |
| 425 | − add_timer_on(timer, cpu); | |
| 426 | − ret = 1; | |
| 427 | − } | |
| 428 | − return ret; | |
| 435 | + return queue_delayed_work_on(cpu, keventd_wq, work, delay); | |
| 429 | 436 | } |
| 430 | 437 | |
| 431 | 438 | /** |
| @@ -622,6 +629,7 @@ void init_workqueues(void) · 190 unmodified lines | ||
| 622 | 629 | EXPORT_SYMBOL_GPL(__create_workqueue); |
| 623 | 630 | EXPORT_SYMBOL_GPL(queue_work); |
| 624 | 631 | EXPORT_SYMBOL_GPL(queue_delayed_work); |
| 632 | +EXPORT_SYMBOL_GPL(queue_delayed_work_on); | |
| 625 | 633 | EXPORT_SYMBOL_GPL(flush_workqueue); |
| 626 | 634 | EXPORT_SYMBOL_GPL(destroy_workqueue); |
| 627 | 635 | |