diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2013-03-19 15:28:10 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-03-20 14:00:57 -0400 |
commit | 881094532e2a27406a5f06f839087bd152a8a494 (patch) | |
tree | 993b36c51374695056781f6bb01f258aea3e71cc /kernel/workqueue.c | |
parent | 951a078a5285ad31bc22e190616ad54b78fac992 (diff) |
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: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 79d1d347e690..b6c5a524d7c4 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -3962,7 +3962,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) | |||
3962 | struct pool_workqueue *pwq; | 3962 | struct pool_workqueue *pwq; |
3963 | bool ret; | 3963 | bool ret; |
3964 | 3964 | ||
3965 | preempt_disable(); | 3965 | rcu_read_lock_sched(); |
3966 | 3966 | ||
3967 | if (!(wq->flags & WQ_UNBOUND)) | 3967 | if (!(wq->flags & WQ_UNBOUND)) |
3968 | pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); | 3968 | pwq = per_cpu_ptr(wq->cpu_pwqs, cpu); |
@@ -3970,7 +3970,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) | |||
3970 | pwq = first_pwq(wq); | 3970 | pwq = first_pwq(wq); |
3971 | 3971 | ||
3972 | ret = !list_empty(&pwq->delayed_works); | 3972 | ret = !list_empty(&pwq->delayed_works); |
3973 | preempt_enable(); | 3973 | rcu_read_unlock_sched(); |
3974 | 3974 | ||
3975 | return ret; | 3975 | return ret; |
3976 | } | 3976 | } |
@@ -4354,16 +4354,16 @@ bool freeze_workqueues_busy(void) | |||
4354 | * nr_active is monotonically decreasing. It's safe | 4354 | * nr_active is monotonically decreasing. It's safe |
4355 | * to peek without lock. | 4355 | * to peek without lock. |
4356 | */ | 4356 | */ |
4357 | preempt_disable(); | 4357 | rcu_read_lock_sched(); |
4358 | for_each_pwq(pwq, wq) { | 4358 | for_each_pwq(pwq, wq) { |
4359 | WARN_ON_ONCE(pwq->nr_active < 0); | 4359 | WARN_ON_ONCE(pwq->nr_active < 0); |
4360 | if (pwq->nr_active) { | 4360 | if (pwq->nr_active) { |
4361 | busy = true; | 4361 | busy = true; |
4362 | preempt_enable(); | 4362 | rcu_read_unlock_sched(); |
4363 | goto out_unlock; | 4363 | goto out_unlock; |
4364 | } | 4364 | } |
4365 | } | 4365 | } |
4366 | preempt_enable(); | 4366 | rcu_read_unlock_sched(); |
4367 | } | 4367 | } |
4368 | out_unlock: | 4368 | out_unlock: |
4369 | mutex_unlock(&wq_mutex); | 4369 | mutex_unlock(&wq_mutex); |