[PATCH 4.14 34/68] workqueue: Move the position of debug_work_activate() in __queue_work()

From: Greg Kroah-Hartman
Date: Thu Apr 15 2021 - 11:06:51 EST


From: Zqiang <qiang.zhang@xxxxxxxxxxxxx>

[ Upstream commit 0687c66b5f666b5ad433f4e94251590d9bc9d10e ]

The debug_work_activate() is called on the premise that
the work can be inserted, because if wq be in WQ_DRAINING
status, insert work may be failed.

Fixes: e41e704bc4f4 ("workqueue: improve destroy_workqueue() debuggability")
Signed-off-by: Zqiang <qiang.zhang@xxxxxxxxxxxxx>
Reviewed-by: Lai Jiangshan <jiangshanlai@xxxxxxxxx>
Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
kernel/workqueue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 79fcec674485..bc32ed4a4cf3 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1379,7 +1379,6 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
*/
WARN_ON_ONCE(!irqs_disabled());

- debug_work_activate(work);

/* if draining, only works from the same workqueue are allowed */
if (unlikely(wq->flags & __WQ_DRAINING) &&
@@ -1462,6 +1461,7 @@ retry:
worklist = &pwq->delayed_works;
}

+ debug_work_activate(work);
insert_work(pwq, work, worklist, work_flags);

spin_unlock(&pwq->pool->lock);
--
2.30.2