Skip to content

Commit

Permalink
workqueue: use rcu_read_lock_sched() instead for accessing pwq in RCU
Browse files Browse the repository at this point in the history
rcu_read_lock_sched() is better than preempt_disable() if the code is
protected by RCU_SCHED.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Lai Jiangshan authored and Tejun Heo committed Mar 20, 2013
1 parent 951a078 commit 8810945
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -3962,15 +3962,15 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)
struct pool_workqueue *pwq;
bool ret;

preempt_disable();
rcu_read_lock_sched();

if (!(wq->flags & WQ_UNBOUND))
pwq = per_cpu_ptr(wq->cpu_pwqs, cpu);
else
pwq = first_pwq(wq);

ret = !list_empty(&pwq->delayed_works);
preempt_enable();
rcu_read_unlock_sched();

return ret;
}
Expand Down Expand Up @@ -4354,16 +4354,16 @@ bool freeze_workqueues_busy(void)
* nr_active is monotonically decreasing. It's safe
* to peek without lock.
*/
preempt_disable();
rcu_read_lock_sched();
for_each_pwq(pwq, wq) {
WARN_ON_ONCE(pwq->nr_active < 0);
if (pwq->nr_active) {
busy = true;
preempt_enable();
rcu_read_unlock_sched();
goto out_unlock;
}
}
preempt_enable();
rcu_read_unlock_sched();
}
out_unlock:
mutex_unlock(&wq_mutex);
Expand Down

0 comments on commit 8810945

Please sign in to comment.