Using a helper instead of open code makes thaw_workqueues() clearer. The helper will also be used by the next patch. tj: Slight update to comment and description.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -3366,6 +3366,26 @@ void destroy_workqueue(struct workqueue_struct *wq) · 3365 unmodified lines | ||
| 3366 | 3366 | } |
| 3367 | 3367 | EXPORT_SYMBOL_GPL(destroy_workqueue); |
| 3368 | 3368 | |
| 3369 | +/** | |
| 3370 | + * cwq_set_max_active - adjust max_active of a cwq | |
| 3371 | + * @cwq: target cpu_workqueue_struct | |
| 3372 | + * @max_active: new max_active value. | |
| 3373 | + * | |
| 3374 | + * Set @cwq->max_active to @max_active and activate delayed works if | |
| 3375 | + * increased. | |
| 3376 | + * | |
| 3377 | + * CONTEXT: | |
| 3378 | + * spin_lock_irq(gcwq->lock). | |
| 3379 | + */ | |
| 3380 | +static void cwq_set_max_active(struct cpu_workqueue_struct *cwq, int max_active) | |
| 3381 | +{ | |
| 3382 | + cwq->max_active = max_active; | |
| 3383 | + | |
| 3384 | + while (!list_empty(&cwq->delayed_works) && | |
| 3385 | + cwq->nr_active < cwq->max_active) | |
| 3386 | + cwq_activate_first_delayed(cwq); | |
| 3387 | +} | |
| 3388 | + | |
| 3369 | 3389 | /** |
| 3370 | 3390 | * workqueue_set_max_active - adjust max_active of a workqueue |
| 3371 | 3391 | * @wq: target workqueue |
| @@ -3792,11 +3812,7 @@ void thaw_workqueues(void) · 420 unmodified lines | ||
| 3792 | 3812 | continue; |
| 3793 | 3813 | |
| 3794 | 3814 | /* restore max_active and repopulate worklist */ |
| 3795 | − cwq->max_active = wq->saved_max_active; | |
| 3796 | − | |
| 3797 | − while (!list_empty(&cwq->delayed_works) && | |
| 3798 | − cwq->nr_active < cwq->max_active) | |
| 3799 | − cwq_activate_first_delayed(cwq); | |
| 3815 | + cwq_set_max_active(cwq, wq->saved_max_active); | |
| 3800 | 3816 | } |
| 3801 | 3817 | |
| 3802 | 3818 | for_each_worker_pool(pool, gcwq) |