workqueue: annotate data-races around pwq->stats
PATCH 1/1 workqueue: annotate data-races around pwq->stats
Suppress warning by annotating these accesses using READ_ONCE() / WRITE_ONCE().
--- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -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 ]++; +WRITE_ONCE (pwq->stats[PWQ_STAT_COMPLETED ],READ_ONCE (pwq->stats[PWQ_STAT_COMPLETED ]) +1 );lock_map_release (&lockdep_map);if (!bh_draining)lock_map_release (pwq->wq->lockdep_map);
Signature · 1 line
2.47.1
Tejun Heo
maintainerQuoted 14 lines · Jiayuan Chen
Suppress warning by annotating these accesses using
READ_ONCE()/WRITE_ONCE().Reported-by [email protected]Signed-off-by Jiayuan Chen <[email protected]>--- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/workqueue.c +0
-0
kernel/workqueue.c __acquires(&pool->lock) · line 3244
Quoted 5 lines
kernel/workqueue.c +1
-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 ]++; +WRITE_ONCE (pwq->stats[PWQ_STAT_COMPLETED ],READ_ONCE (pwq->stats[PWQ_STAT_COMPLETED ]) +1 );
The function acquires pool->lock down below. Can you move it down inside the locked region instead of adding READ/WRITE_ONCE()?
Thanks.
Signature · 1 line
tejun
Quoted 40 lines · Tejun Heo
Quoted 37 lines · Jiayuan Chen
Suppress warning by annotating these accesses using
READ_ONCE()/WRITE_ONCE().Reported-by [email protected]Signed-off-by Jiayuan Chen <[email protected]>---
kernel/workqueue.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)diff --git
a/kernel/workqueue.cb/kernel/workqueue.cindex
cf6203282737..d78640b5d188100644---
a/kernel/workqueue.c+++
b/kernel/workqueue.c@@ -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]++;
Quoted 13 lines
Quoted 2 lines
+
WRITE_ONCE(pwq->stats[PWQ_STAT_COMPLETED], READ_ONCE(pwq->stats[PWQ_STAT_COMPLETED]) + 1);The function acquires
pool->lockdown below. Can you move it down inside thelocked region instead of adding READ/WRITE_ONCE()?
Thanks.
Signature · 1 line
tejun
Thanks, I can do that.
Previously, I thought it was for performance considerations that the metrics calculation is out of the lock's scope...