Skip to contentSkip to conversation

workqueue: Add RCU annotation for pwq list walk

PATCH Applied Sebastian Andrzej Siewior 2 participants 2 messages Nov 15, 2019 Workqueue

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 workqueue: Add RCU annotation for pwq list walk

An additional check has been recently added to ensure that a RCU related lock is held while the RCU list is iterated.
The `pwqs' are sometimes iterated without a RCU lock but with the &wq->mutex acquired leading to a warning.

Teach list_for_each_entry_rcu() that the RCU usage is okay if &wq->mutex is acquired during the list traversal.

Fixes 28875945ba98d ("rcu: Add support for consolidated-RCU reader checking")
---
 kernel/workqueue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/workqueue.c +2 -1
index bc2e09a8ea61d..0a1d2f4289178 100644
@@ -425,7 +425,8 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
  * ignored.
  */
 #define for_each_pwq(pwq, wq)						\
-	list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node)		\
+	list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node,		\
+				lockdep_is_held(&wq->mutex))		\
 		if (({ assert_rcu_or_wq_mutex(wq); false; })) { }	\
 		else
 
Signature · 1 line
2.24.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Sebastian Andrzej Siewior

An additional check has been recently added to ensure that a RCU related lock is held while the RCU list is iterated.
The `pwqs' are sometimes iterated without a RCU lock but with the &wq->mutex acquired leading to a warning.

Teach list_for_each_entry_rcu() that the RCU usage is okay if &wq->mutex is acquired during the list traversal.

Fixes 28875945ba98d ("rcu: Add support for consolidated-RCU reader checking")

Applied to wq/for-5.5.

Thanks.

Signature · 1 line
tejun