Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

workqueue: Factor out pwq_is_empty()

"!pwq->nr_active && list_empty(&pwq->inactive_works)" test is repeated
multiple times. Let's factor it out into pwq_is_empty().

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>

+9 -4
+9 -4
kernel/workqueue.c
··· 1460 1460 } 1461 1461 } 1462 1462 1463 + static bool pwq_is_empty(struct pool_workqueue *pwq) 1464 + { 1465 + return !pwq->nr_active && list_empty(&pwq->inactive_works); 1466 + } 1467 + 1463 1468 static void pwq_activate_inactive_work(struct work_struct *work) 1464 1469 { 1465 1470 struct pool_workqueue *pwq = get_work_pwq(work); ··· 3334 3329 bool drained; 3335 3330 3336 3331 raw_spin_lock_irq(&pwq->pool->lock); 3337 - drained = !pwq->nr_active && list_empty(&pwq->inactive_works); 3332 + drained = pwq_is_empty(pwq); 3338 3333 raw_spin_unlock_irq(&pwq->pool->lock); 3339 3334 3340 3335 if (drained) ··· 4784 4779 4785 4780 if ((pwq != pwq->wq->dfl_pwq) && (pwq->refcnt > 1)) 4786 4781 return true; 4787 - if (pwq->nr_active || !list_empty(&pwq->inactive_works)) 4782 + if (!pwq_is_empty(pwq)) 4788 4783 return true; 4789 4784 4790 4785 return false; ··· 5222 5217 unsigned long flags; 5223 5218 5224 5219 for_each_pwq(pwq, wq) { 5225 - if (pwq->nr_active || !list_empty(&pwq->inactive_works)) { 5220 + if (!pwq_is_empty(pwq)) { 5226 5221 idle = false; 5227 5222 break; 5228 5223 } ··· 5234 5229 5235 5230 for_each_pwq(pwq, wq) { 5236 5231 raw_spin_lock_irqsave(&pwq->pool->lock, flags); 5237 - if (pwq->nr_active || !list_empty(&pwq->inactive_works)) { 5232 + if (!pwq_is_empty(pwq)) { 5238 5233 /* 5239 5234 * Defer printing to avoid deadlocks in console 5240 5235 * drivers that queue work while holding locks