rcu_read_lock_sched() is better than preempt_disable() if the code is
protected by RCU_SCHED.

Signed-off-by: Lai Jiangshan <[email protected]>
---
 kernel/workqueue.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index ad190cd..469269e 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3967,7 +3967,7 @@ 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);
@@ -3975,7 +3975,7 @@ bool workqueue_congested(int cpu, struct workqueue_struct 
*wq)
                pwq = first_pwq(wq);
 
        ret = !list_empty(&pwq->delayed_works);
-       preempt_enable();
+       rcu_read_unlock_sched();
 
        return ret;
 }
@@ -4361,16 +4361,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(&wqs_mutex);
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to