workqueue: Remove rcu_read_lock/unlock() in workqueue_congested()
PATCH 1/1 workqueue: Remove rcu_read_lock/unlock() in workqueue_congested()
From: Zqiang <[email protected]>
The RCU read critical area already by preempt_disable/enable() (equivalent to rcu_read_lock_sched/unlock_sched()) mark, so remove rcu_read_lock/unlock().
--- kernel/workqueue.c | 2 -- 1 file changed, 2 deletions(-)
kernel/workqueue.c +0 -2
@@ -4540,7 +4540,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)struct pool_workqueue *pwq;bool ret; -rcu_read_lock ();preempt_disable ();if (cpu ==WORK_CPU_UNBOUND )
@@ -4553,7 +4552,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) ret = !list_empty (&pwq->delayed_works);preempt_enable (); -rcu_read_unlock ();return ret; }
Signature · 1 line
2.25.1
Lai Jiangshan
reviewer+CC Paul
Quoted 6 lines · On Wed, Feb 17, 2021 at 7:58 PM <[email protected]> wrote:
From: Zqiang <[email protected]>
The RCU read critical area already by preempt_disable/enable() (equivalent to rcu_read_lock_sched/unlock_sched()) mark, so remove rcu_read_lock/unlock().
I think we can leave it which acks like document, especially workqueue_congested() is not performance crucial. Either way is Ok for me.
If it needs to be changed, please also do the same for rcu_read_lock() in wq_watchdog_timer_fn().
And __queue_work() and try_to_grab_pending() also use local_irq_save() and rcu_read_lock() at the same time, but I don't know will these local_irq_save() be changed to raw_local_irq_save() in PREEMPT_RT.
Quoted 29 lines
Signed-off-by Zqiang <[email protected]>--- kernel/workqueue.c | 2 -- 1 file changed, 2 deletions(-)kernel/workqueue.c +0
-3@@ -4540,7 +4540,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)struct pool_workqueue *pwq;bool ret; -rcu_read_lock ();preempt_disable ();if (cpu ==WORK_CPU_UNBOUND )@@ -4553,7 +4552,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) ret = !list_empty (&pwq->delayed_works);preempt_enable (); -rcu_read_unlock ();return ret; } --2.25.1
Quoted 7 lines · Lai Jiangshan
+CC Paul
Quoted 3 lines · On Wed, Feb 17, 2021 at 7:58 PM <[email protected]> wrote:
From: Zqiang <[email protected]>
Quoted 7 lines
Quoted 3 lines
The RCU read critical area already by preempt_disable/enable() (equivalent to rcu_read_lock_sched/unlock_sched()) mark, so remove rcu_read_lock/unlock().
I think we can leave it which acks like document, especially
workqueue_congested()is not performance crucial. Either way is Ok for me.
If the rcu_read_lock() is removed, should there be a comment saying that it interacts with synchronize_rcu()? Just in case one of the real-time guys figures out a way to get the job done without disabling preemption...
Thanx, Paul
Quoted 37 lines
If it needs to be changed, please also do the same for
rcu_read_lock()inwq_watchdog_timer_fn().And
__queue_work()andtry_to_grab_pending()also uselocal_irq_save()andrcu_read_lock()at the same time, but I don't know will theselocal_irq_save()be changed toraw_local_irq_save()inPREEMPT_RT.Quoted 29 lines
Signed-off-by Zqiang <[email protected]>--- kernel/workqueue.c | 2 -- 1 file changed, 2 deletions(-)kernel/workqueue.c +0
-3@@ -4540,7 +4540,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)struct pool_workqueue *pwq;bool ret; -rcu_read_lock ();preempt_disable ();if (cpu ==WORK_CPU_UNBOUND )@@ -4553,7 +4552,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) ret = !list_empty (&pwq->delayed_works);preempt_enable (); -rcu_read_unlock ();return ret; } --2.25.1
________________________________________
发件人: Paul E. McKenney <[email protected]>
发送时间: 2021年2月18日 23:17
收件人: Lai Jiangshan
抄送: Zhang, Qiang; Tejun Heo; Tejun Heo; LKML
主题: Re: [PATCH] workqueue: Remove rcu_read_lock/unlock() in workqueue_congested()
[Please note: This e-mail is from an EXTERNAL e-mail address]
Quoted 21 lines · Lai Jiangshan
+CC Paul
Quoted 6 lines · On Wed, Feb 17, 2021 at 7:58 PM <[email protected]> wrote:
From: Zqiang <[email protected]>
The RCU read critical area already by preempt_disable/enable() (equivalent to rcu_read_lock_sched/unlock_sched()) mark, so remove rcu_read_lock/unlock().
I think we can leave it which acks like document, especially
workqueue_congested()is not performance crucial. Either way is Ok for me.If the
rcu_read_lock()is removed, should there be a comment saying >that it interacts withsynchronize_rcu()? Just in case one of the real-time guys figures out a way to get the job done without disabling >preemption...Thanx, Paul
Quoted 7 lines
If it needs to be changed, please also do the same for
rcu_read_lock()inwq_watchdog_timer_fn().And
__queue_work()andtry_to_grab_pending()also uselocal_irq_save()andrcu_read_lock()at the same time, but I don't know will theselocal_irq_save()be changed toraw_local_irq_save()inPREEMPT_RT.
The local_irq_save function is not change in PREEMPT_RT system.
Thanks
Qiang
Quoted 31 lines
Quoted 31 lines
Signed-off-by Zqiang <[email protected]>--- kernel/workqueue.c | 2 -- 1 file changed, 2 deletions(-)kernel/workqueue.c +0
-3@@ -4540,7 +4540,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq)struct pool_workqueue *pwq;bool ret; -rcu_read_lock ();preempt_disable ();if (cpu ==WORK_CPU_UNBOUND )@@ -4553,7 +4552,6 @@ bool workqueue_congested(int cpu, struct workqueue_struct *wq) ret = !list_empty (&pwq->delayed_works);preempt_enable (); -rcu_read_unlock ();return ret; } --2.25.1