Skip to contentSkip to conversation

workqueue: fix detecting reentrance

RFC In review Hillf Danton 2 participants 2 messages Dec 12, 2019 – Dec 16, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 workqueue: fix detecting reentrance

If we can find a valid worker that is serving the specified work at the moment then the worker itself is enough to ensure reentrance and workqueue doesn't matter here because it is permitted for a work to requeue itself either on different cpu or numa node or even on another workqueue.

Fixes c9178087acd7 ("workqueue: perform non-reentrancy test when queueing to unbound workqueues too")
Fixes 18aa9effad4a ("workqueue: implement WQ_NON_REENTRANT")

---

kernel/workqueue.c +1 -1
@@ -1433,7 +1433,7 @@ retry:
 
 		worker = find_worker_executing_work(last_pool, work);
 
-		if (worker && worker->current_pwq->wq == wq) {
+		if (worker) {
 			pwq = worker->current_pwq;
 		} else {
 			/* meh... not running there, queue here */
#1 lore raw

Cc maintainers.

Quoted 6 lines · Hillf Danton

If we can find a valid worker that is serving the specified work at the moment then the worker itself is enough to ensure reentrance and workqueue doesn't matter here because it is permitted for a work to requeue itself either on different cpu or numa node or even on another workqueue.

I do not follow what is the actual problem you are trying to fix here.

Quoted 17 lines
Fixes c9178087acd7 ("workqueue: perform non-reentrancy test when queueing to unbound workqueues too")
Fixes 18aa9effad4a ("workqueue: implement WQ_NON_REENTRANT")

---

kernel/workqueue.c +1 -1
@@ -1433,7 +1433,7 @@ retry:
 
 		worker = find_worker_executing_work(last_pool, work);
 
-		if (worker && worker->current_pwq->wq == wq) {
+		if (worker) {
 			pwq = worker->current_pwq;
 		} else {
 			/* meh... not running there, queue here */
Signature · 2 lines
Michal Hocko
SUSE Labs