workqueue: add RCU quiescent state between items
Subsystems (2)
v2 cover workqueue: add RCU quiescent state between items
v2 - split into two patches: the first inlines the cond_resched_rcu_qs macro suitable for stable backport, the second converts to using cond_resched_rcu_qs.
Joe Lawrence (2):
workqueue: add quiescent state between work items
workqueue: use cond_resched_rcu_qs macro
kernel/workqueue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v2 1/2 workqueue: add quiescent state between work items
Similar to the stop_machine deadlock scenario on !PREEMPT kernels addressed in b22ce2785d97 "workqueue: cond_resched() after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. The cond_resched call introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.
--- kernel/workqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/workqueue.c +3 -1
@@ -2043,8 +2043,10 @@ __acquires(&pool->lock)* kernels, where a requeueing work item waiting for something to * happen could deadlock with stop_machine as such work item could * indefinitely requeue itself while all other CPUs are trapped in -* stop_machine. +* stop_machine. At the same time, report a quiescent RCU state so +* the same condition doesn't freeze RCU. */ +rcu_note_voluntary_context_switch (current);cond_resched ();spin_lock_irq (&pool->lock);
Signature · 1 line
1.7.10.4
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 7 lines · Joe Lawrence
Similar to the
stop_machinedeadlock scenario on !PREEMPT kernels addressed inb22ce2785d97"workqueue:cond_resched()after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. Thecond_reschedcall introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.
Quoted 5 lines
Signed-off-by Joe Lawrence <[email protected]>Fixes b22ce2785d97 ("workqueue: cond_resched() after processing each work item")Cc <[email protected]>
Applied to wq/for-3.17-fixes. If 3.17 comes out before this gets merged, I'll send it as for-3.18.
Thanks.
Signature · 1 line
tejun
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 8 lines · Tejun Heo
Quoted 7 lines · Joe Lawrence
Similar to the
stop_machinedeadlock scenario on !PREEMPT kernels addressed inb22ce2785d97"workqueue:cond_resched()after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. Thecond_reschedcall introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Joe Lawrence <[email protected]>Fixes b22ce2785d97 ("workqueue: cond_resched() after processing each work item")Cc <[email protected]>Applied to wq/for-3.17-fixes. If 3.17 comes out before this gets merged, I'll send it as for-3.18.
Oops, the rcu calls aren't in mainline yet. I think it'd be best to route these through the RCU tree. Paul, can you please route these two patches?
Thanks.
Signature · 1 line
tejun
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 15 lines · Tejun Heo
Quoted 14 lines · Tejun Heo
Quoted 12 lines · Joe Lawrence
Similar to the
stop_machinedeadlock scenario on !PREEMPT kernels addressed inb22ce2785d97"workqueue:cond_resched()after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. Thecond_reschedcall introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.Signed-off-by Joe Lawrence <[email protected]>Fixes b22ce2785d97 ("workqueue: cond_resched() after processing each work item")Cc <[email protected]>
Quoted 8 lines
Quoted 2 lines
Applied to wq/for-3.17-fixes. If 3.17 comes out before this gets merged, I'll send it as for-3.18.
Oops, the rcu calls aren't in mainline yet. I think it'd be best to route these through the RCU tree. Paul, can you please route these two patches?
Acked-by Tejun Heo <[email protected]>
Will do!
I will try 3.17, failing that, 3.18.
Thanx, Paul
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 23 lines · Mon, Oct 06, 2014 at 06:21:58AM CEST, [email protected] wrote:
Quoted 22 lines · Tejun Heo
Quoted 8 lines · Tejun Heo
Quoted 7 lines · Joe Lawrence
Similar to the
stop_machinedeadlock scenario on !PREEMPT kernels addressed inb22ce2785d97"workqueue:cond_resched()after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. Thecond_reschedcall introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.Quoted 8 lines
Quoted 5 lines
Signed-off-by Joe Lawrence <[email protected]>Fixes b22ce2785d97 ("workqueue: cond_resched() after processing each work item")Cc <[email protected]>Applied to wq/for-3.17-fixes. If 3.17 comes out before this gets merged, I'll send it as for-3.18.
Oops, the rcu calls aren't in mainline yet. I think it'd be best to route these through the RCU tree. Paul, can you please route these two patches?
Quoted 5 lines
Quoted 1 line
Acked-by Tejun Heo <[email protected]>Will do!
I will try 3.17, failing that, 3.18.
Paul, Tehun, how do you propose to fix this on older kernels which do not have rcu_note_voluntary_context_switch? I'm particullary interested in 3.10.
Thanks.
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 26 lines · Jiri Pirko
Quoted 25 lines · Mon, Oct 06, 2014 at 06:21:58AM CEST, [email protected] wrote:
Quoted 23 lines · Tejun Heo
Quoted 8 lines · Tejun Heo
Quoted 7 lines · Joe Lawrence
Similar to the
stop_machinedeadlock scenario on !PREEMPT kernels addressed inb22ce2785d97"workqueue:cond_resched()after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. Thecond_reschedcall introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.Quoted 8 lines
Quoted 5 lines
Signed-off-by Joe Lawrence <[email protected]>Fixes b22ce2785d97 ("workqueue: cond_resched() after processing each work item")Cc <[email protected]>Applied to wq/for-3.17-fixes. If 3.17 comes out before this gets merged, I'll send it as for-3.18.
Oops, the rcu calls aren't in mainline yet. I think it'd be best to route these through the RCU tree. Paul, can you please route these two patches?
Acked-by Tejun Heo <[email protected]>
Quoted 8 lines
Quoted 3 lines
Will do!
I will try 3.17, failing that, 3.18.
Paul, Tehun, how do you propose to fix this on older kernels which do not have
rcu_note_voluntary_context_switch? I'm particullary interested in 3.10.
Hello, Jiri,
Older kernels can instead use rcu_note_context_switch().
Thanx, Paul
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 1 line · On Tue, 7 Oct 2014 06:43:29 -0700 "Paul E. McKenney"…
On Tue, Oct 07, 2014 at 09:29:42AM +0200, Jiri Pirko wrote:
[ ... snip ... ]
Quoted 8 lines
Quoted 4 lines
Paul, Tehun, how do you propose to fix this on older kernels which do not have
rcu_note_voluntary_context_switch? I'm particullary interested in 3.10.Hello, Jiri,
Older kernels can instead use
rcu_note_context_switch().
Hi Paul,
Does 4a81e8328d37 ("rcu: Reduce overhead of cond_resched() checks for RCU") affect a backport to 3.10?
I noticed that rcu_note_context_switch added a call to rcu_momentary_dyntick_idle in that change, which is only present in v3.16+.
Would rcu_note_context_switch be effective by itself on a 3.10 kernel?
Thanks,
-- Joe
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 16 lines · Joe Lawrence
Quoted 1 line · On Tue, 7 Oct 2014 06:43:29 -0700 "Paul E. McKenney"…
On Tue, Oct 07, 2014 at 09:29:42AM +0200, Jiri Pirko wrote:
[ ... snip ... ]
Quoted 8 lines
Quoted 4 lines
Paul, Tehun, how do you propose to fix this on older kernels which do not have
rcu_note_voluntary_context_switch? I'm particullary interested in 3.10.Hello, Jiri,
Older kernels can instead use
rcu_note_context_switch().Hi Paul,
Quoted 8 lines
Does
4a81e8328d37("rcu: Reduce overhead ofcond_resched()checks for RCU") affect a backport to 3.10?I noticed that
rcu_note_context_switchadded a call torcu_momentary_dyntick_idlein that change, which is only present in v3.16+.Would
rcu_note_context_switchbe effective by itself on a 3.10 kernel?
Should be fine. There is more overhead than current mainline, but that should not be in the noise compared to executing a work-queue item.
Thanx, Paul
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 24 lines · Wed, Oct 08, 2014 at 05:24:11AM CEST, [email protected] wrote:
Quoted 23 lines · Joe Lawrence
Quoted 1 line · On Tue, 7 Oct 2014 06:43:29 -0700 "Paul E. McKenney"…
On Tue, Oct 07, 2014 at 09:29:42AM +0200, Jiri Pirko wrote:
[ ... snip ... ]
Quoted 8 lines
Quoted 4 lines
Paul, Tehun, how do you propose to fix this on older kernels which do not have
rcu_note_voluntary_context_switch? I'm particullary interested in 3.10.Hello, Jiri,
Older kernels can instead use
rcu_note_context_switch().Hi Paul,
Does
4a81e8328d37("rcu: Reduce overhead ofcond_resched()checks for RCU") affect a backport to 3.10?I noticed that
rcu_note_context_switchadded a call torcu_momentary_dyntick_idlein that change, which is only present in v3.16+.
Quoted 7 lines
Quoted 1 line
Would
rcu_note_context_switchbe effective by itself on a 3.10 kernel?Should be fine. There is more overhead than current mainline, but that should not be in the noise compared to executing a work-queue item.
Thanx, Paul
I cooked up following patch. Please tell me if it is fine or not. I can also send it oficially so it can be included into stable trees:
Subject: workqueue: Add quiescent state between work items
Similar to the stop_machine deadlock scenario on !PREEMPT kernels addressed in b22ce2785d97 "workqueue: cond_resched() after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. The cond_resched call introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.
--- kernel/workqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/workqueue.c +3 -1
@@ -2196,8 +2196,10 @@ __acquires(&pool->lock)* kernels, where a requeueing work item waiting for something to * happen could deadlock with stop_machine as such work item could * indefinitely requeue itself while all other CPUs are trapped in -* stop_machine. +* stop_machine. At the same time, report a quiescent RCU state so +* the same condition doesn't freeze RCU. */ +rcu_note_context_switch (raw_smp_processor_id ());cond_resched ();spin_lock_irq (&pool->lock);
Signature · 1 line
1.9.3
Re: [PATCH v2 1/2] workqueue: add quiescent state between work items
Quoted 27 lines · Jiri Pirko
Quoted 26 lines · Wed, Oct 08, 2014 at 05:24:11AM CEST, [email protected] wrote:
Quoted 24 lines · Joe Lawrence
Quoted 1 line · On Tue, 7 Oct 2014 06:43:29 -0700 "Paul E. McKenney"…
On Tue, Oct 07, 2014 at 09:29:42AM +0200, Jiri Pirko wrote:
[ ... snip ... ]
Quoted 8 lines
Quoted 4 lines
Paul, Tehun, how do you propose to fix this on older kernels which do not have
rcu_note_voluntary_context_switch? I'm particullary interested in 3.10.Hello, Jiri,
Older kernels can instead use
rcu_note_context_switch().Hi Paul,
Does
4a81e8328d37("rcu: Reduce overhead ofcond_resched()checks for RCU") affect a backport to 3.10?I noticed that
rcu_note_context_switchadded a call torcu_momentary_dyntick_idlein that change, which is only present in v3.16+.Would
rcu_note_context_switchbe effective by itself on a 3.10 kernel?
Quoted 8 lines
Quoted 5 lines
Should be fine. There is more overhead than current mainline, but that should not be in the noise compared to executing a work-queue item.
Thanx, Paul
I cooked up following patch. Please tell me if it is fine or not. I can also send it oficially so it can be included into stable trees:
Looks good!
Thanx, Paul
Quoted 34 lines
Subject: workqueue: Add quiescent state between work items
Similar to the
stop_machinedeadlock scenario on !PREEMPT kernels addressed inb22ce2785d97"workqueue:cond_resched()after processing each work item", kworker threads requeueing back-to-back with zero jiffy delay can stall RCU. Thecond_reschedcall introduced in that fix will yield only iff there are other higher priority tasks to run, so force a quiescent RCU state between work items.Signed-off-by Jiri Pirko <[email protected]>--- kernel/workqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)kernel/workqueue.c +3
-1@@ -2196,8 +2196,10 @@ __acquires(&pool->lock)* kernels, where a requeueing work item waiting for something to * happen could deadlock with stop_machine as such work item could * indefinitely requeue itself while all other CPUs are trapped in -* stop_machine. +* stop_machine. At the same time, report a quiescent RCU state so +* the same condition doesn't freeze RCU. */ +rcu_note_context_switch (raw_smp_processor_id ());cond_resched ();spin_lock_irq (&pool->lock);Signature · 1 line
1.9.3
PATCH v2 2/2 workqueue: use cond_resched_rcu_qs macro
In reply to Joe LawrenceTidy up and use cond_resched_rcu_qs when calling cond_resched and reporting potential quiescent state to RCU.
--- kernel/workqueue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/workqueue.c +1 -2
@@ -2046,8 +2046,7 @@ __acquires(&pool->lock)* stop_machine. At the same time, report a quiescent RCU state so * the same condition doesn't freeze RCU. */ -rcu_note_voluntary_context_switch (current); -cond_resched (); +cond_resched_rcu_qs ();spin_lock_irq (&pool->lock);
Signature · 1 line
1.7.10.4
Re: [PATCH v2 2/2] workqueue: use cond_resched_rcu_qs macro
Quoted 4 lines · Joe Lawrence
Tidy up and use
cond_resched_rcu_qswhen callingcond_reschedand reporting potential quiescent state to RCU.Signed-off-by Joe Lawrence <[email protected]>
Quoted 21 lines
--- kernel/workqueue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)kernel/workqueue.c +1
-2@@ -2046,8 +2046,7 @@ __acquires(&pool->lock)* stop_machine. At the same time, report a quiescent RCU state so * the same condition doesn't freeze RCU. */ -rcu_note_voluntary_context_switch (current); -cond_resched (); +cond_resched_rcu_qs ();spin_lock_irq (&pool->lock);Signature · 1 line
1.7.10.4
Re: [PATCH v2 2/2] workqueue: use cond_resched_rcu_qs macro
In reply to Joe LawrenceQuoted 4 lines · Joe Lawrence
Tidy up and use
cond_resched_rcu_qswhen callingcond_reschedand reporting potential quiescent state to RCU.Signed-off-by Joe Lawrence <[email protected]>
Please route through the rcu tree.
Thanks!
Signature · 1 line
tejun