workqueue: Fix race condition in wq->stats incrementation
PATCH v2 1/1 workqueue: Fix race condition in wq->stats incrementation
Fixed a race condition in incrementing wq->stats[PWQ_STAT_COMPLETED] by moving the operation under pool->lock.
Reported-by [email protected]
Signed-off-by Jiayuan Chen <[email protected]>
--- kernel/workqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/workqueue.c +3 -1
@@ -3241,7 +3241,7 @@ __acquires(&pool->lock)* point will only record its address. */ trace_workqueue_execute_end (work, worker->current_func); - pwq->stats[PWQ_STAT_COMPLETED ]++; +lock_map_release (&lockdep_map);if (!bh_draining)lock_map_release (pwq->wq->lockdep_map);
@@ -3272,6 +3272,8 @@ __acquires(&pool->lock)raw_spin_lock_irq (&pool->lock); + pwq->stats[PWQ_STAT_COMPLETED ]++; +/* * In addition to %WQ_CPU_INTENSIVE, @worker may also have been marked * CPU intensive by wq_worker_tick() if @work hogged CPU longer than
Signature · 1 line
2.47.1
Quoted 5 lines · Jiayuan Chen
Fixed a race condition in incrementing wq->stats[PWQ_STAT_COMPLETED] by moving the operation under
pool->lock.Reported-by [email protected]Signed-off-by Jiayuan Chen <[email protected]>
Applied to wq/for-6.16.
Thanks.
Signature · 1 line
tejun