Skip to content

Commit 58629d4

Browse files
Lai Jiangshanhtejun
authored andcommitted
workqueue: Always queue work items to the newest PWQ for order workqueues
To ensure non-reentrancy, __queue_work() attempts to enqueue a work item to the pool of the currently executing worker. This is not only unnecessary for an ordered workqueue, where order inherently suggests non-reentrancy, but it could also disrupt the sequence if the item is not enqueued on the newest PWQ. Just queue it to the newest PWQ and let order management guarantees non-reentrancy. Signed-off-by: Lai Jiangshan <[email protected]> Fixes: 4c065db ("workqueue: Enable unbound cpumask update on ordered workqueues") Cc: [email protected] # v6.9+ Signed-off-by: Tejun Heo <[email protected]> (cherry picked from commit 74347be)
1 parent b2b1f93 commit 58629d4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/workqueue.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2274,9 +2274,13 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
22742274
* If @work was previously on a different pool, it might still be
22752275
* running there, in which case the work needs to be queued on that
22762276
* pool to guarantee non-reentrancy.
2277+
*
2278+
* For ordered workqueue, work items must be queued on the newest pwq
2279+
* for accurate order management. Guaranteed order also guarantees
2280+
* non-reentrancy. See the comments above unplug_oldest_pwq().
22772281
*/
22782282
last_pool = get_work_pool(work);
2279-
if (last_pool && last_pool != pool) {
2283+
if (last_pool && last_pool != pool && !(wq->flags & __WQ_ORDERED)) {
22802284
struct worker *worker;
22812285

22822286
raw_spin_lock(&last_pool->lock);

0 commit comments

Comments
 (0)