Skip to content

Commit 5a64466

Browse files
joelagnelpaulmckrcu
authored andcommitted
workqueue: Convert for_each_wq to use built-in list check
Because list_for_each_entry_rcu() can now check for holding a lock as well as for being in an RCU read-side critical section, this commit replaces the workqueue_sysfs_unregister() function's use of assert_rcu_or_wq_mutex() and list_for_each_entry_rcu() with list_for_each_entry_rcu() augmented with a lockdep_is_held() optional argument. Acked-by: Tejun Heo <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 1d24dd4 commit 5a64466

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

kernel/workqueue.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,6 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
364364
!lockdep_is_held(&wq_pool_mutex), \
365365
"RCU or wq_pool_mutex should be held")
366366

367-
#define assert_rcu_or_wq_mutex(wq) \
368-
RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
369-
!lockdep_is_held(&wq->mutex), \
370-
"RCU or wq->mutex should be held")
371-
372367
#define assert_rcu_or_wq_mutex_or_pool_mutex(wq) \
373368
RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
374369
!lockdep_is_held(&wq->mutex) && \
@@ -425,9 +420,8 @@ static void workqueue_sysfs_unregister(struct workqueue_struct *wq);
425420
* ignored.
426421
*/
427422
#define for_each_pwq(pwq, wq) \
428-
list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node) \
429-
if (({ assert_rcu_or_wq_mutex(wq); false; })) { } \
430-
else
423+
list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, \
424+
lockdep_is_held(&(wq->mutex)))
431425

432426
#ifdef CONFIG_DEBUG_OBJECTS_WORK
433427

0 commit comments

Comments
 (0)