Commit 88109453 authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Tejun Heo

workqueue: use rcu_read_lock_sched() instead for accessing pwq in RCU

rcu_read_lock_sched() is better than preempt_disable() if the code is
protected by RCU_SCHED.
Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 951a078a
...@@ -3962,7 +3962,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) ...@@ -3962,7 +3962,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)
struct pool_workqueue *pwq; struct pool_workqueue *pwq;
bool ret; bool ret;
preempt_disable(); rcu_read_lock_sched();
if (!(wq->flags & WQ_UNBOUND)) if (!(wq->flags & WQ_UNBOUND))
pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
...@@ -3970,7 +3970,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) ...@@ -3970,7 +3970,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)
pwq = first_pwq(wq); pwq = first_pwq(wq);
ret = !list_empty(&pwq->delayed_works); ret = !list_empty(&pwq->delayed_works);
preempt_enable(); rcu_read_unlock_sched();
return ret; return ret;
} }
...@@ -4354,16 +4354,16 @@ bool freeze_workqueues_busy(void) ...@@ -4354,16 +4354,16 @@ bool freeze_workqueues_busy(void)
* nr_active is monotonically decreasing. It's safe * nr_active is monotonically decreasing. It's safe
* to peek without lock. * to peek without lock.
*/ */
preempt_disable(); rcu_read_lock_sched();
for_each_pwq(pwq, wq) { for_each_pwq(pwq, wq) {
WARN_ON_ONCE(pwq->nr_active < 0); WARN_ON_ONCE(pwq->nr_active < 0);
if (pwq->nr_active) { if (pwq->nr_active) {
busy = true; busy = true;
preempt_enable(); rcu_read_unlock_sched();
goto out_unlock; goto out_unlock;
} }
} }
preempt_enable(); rcu_read_unlock_sched();
} }
out_unlock: out_unlock:
mutex_unlock(&wq_mutex); mutex_unlock(&wq_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment