Skip to content

Commit 703ccb6

Browse files
mbrost05htejun
authored andcommitted
workqueue: Add pool_workqueue to pending_pwqs list when unplugging multiple inactive works
In unplug_oldest_pwq(), the first inactive work item on the pool_workqueue is activated correctly. However, if multiple inactive works exist on the same pool_workqueue, subsequent works fail to activate because wq_node_nr_active.pending_pwqs is empty — the list insertion is skipped when the pool_workqueue is plugged. Fix this by checking for additional inactive works in unplug_oldest_pwq() and updating wq_node_nr_active.pending_pwqs accordingly. Fixes: 4c065db ("workqueue: Enable unbound cpumask update on ordered workqueues") Cc: [email protected] Cc: Carlos Santa <[email protected]> Cc: Ryan Neph <[email protected]> Cc: Lai Jiangshan <[email protected]> Cc: Waiman Long <[email protected]> Cc: [email protected] Signed-off-by: Matthew Brost <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Acked-by: Waiman Long <[email protected]>
1 parent e398978 commit 703ccb6

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

kernel/workqueue.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,8 +1849,20 @@ static void unplug_oldest_pwq(struct workqueue_struct *wq)
18491849
raw_spin_lock_irq(&pwq->pool->lock);
18501850
if (pwq->plugged) {
18511851
pwq->plugged = false;
1852-
if (pwq_activate_first_inactive(pwq, true))
1852+
if (pwq_activate_first_inactive(pwq, true)) {
1853+
/*
1854+
* While plugged, queueing skips activation which
1855+
* includes bumping the nr_active count and adding the
1856+
* pwq to nna->pending_pwqs if the count can't be
1857+
* obtained. We need to restore both for the pwq being
1858+
* unplugged. The first call activates the first
1859+
* inactive work item and the second, if there are more
1860+
* inactive, puts the pwq on pending_pwqs.
1861+
*/
1862+
pwq_activate_first_inactive(pwq, false);
1863+
18531864
kick_pool(pwq->pool);
1865+
}
18541866
}
18551867
raw_spin_unlock_irq(&pwq->pool->lock);
18561868
}

0 commit comments

Comments
 (0)