* [PATCH] sched/rt: Document why has_pushable_tasks() isn't called with a runqueue lock
@ 2017-02-28 21:48 Steven Rostedt
2017-03-01 8:37 ` Peter Zijlstra
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2017-02-28 21:48 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, LKML, Andrew Morton
From: Steven Rostedt (VMware) <rostedt@goodmis.org>
While reviewing the RT scheduling IPI logic, I was thinking that it was
a bug that has_pushable_tasks(rq) was not called under the runqueue
lock. But then I realized that there isn't a case where a race would
cause a problem, as to update has_pushable_tasks() would trigger a
push_rt_task() call from the CPU doing the update.
This subtle logic deserves a comment.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 4101f9d..f39449b 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1976,6 +1976,16 @@ static void try_to_push_tasks(void *arg)
src_rq = rq_of_rt_rq(rt_rq);
again:
+ /*
+ * Normally, has_pushable_tasks() would be performed within the
+ * runqueue lock being held. But if it was not set when entering
+ * this hard interrupt handler function, then to have it set would
+ * require a wake up. A wake up of an RT task will either cause a
+ * schedule if the woken task is higher priority than the running
+ * task, or it would try to do a push from the CPU doing the wake
+ * up. Grabbing the runqueue lock in such a case would more likely
+ * just cause unnecessary contention.
+ */
if (has_pushable_tasks(rq)) {
raw_spin_lock(&rq->lock);
push_rt_task(rq);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/rt: Document why has_pushable_tasks() isn't called with a runqueue lock
2017-02-28 21:48 [PATCH] sched/rt: Document why has_pushable_tasks() isn't called with a runqueue lock Steven Rostedt
@ 2017-03-01 8:37 ` Peter Zijlstra
2017-03-02 20:38 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2017-03-01 8:37 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Ingo Molnar, LKML, Andrew Morton
On Tue, Feb 28, 2017 at 04:48:56PM -0500, Steven Rostedt wrote:
> + /*
> + * Normally, has_pushable_tasks() would be performed within the
> + * runqueue lock being held. But if it was not set when entering
"not set" what? I'm having trouble parsing this.
> + * this hard interrupt handler function, then to have it set would
> + * require a wake up. A wake up of an RT task will either cause a
> + * schedule if the woken task is higher priority than the running
> + * task, or it would try to do a push from the CPU doing the wake
> + * up. Grabbing the runqueue lock in such a case would more likely
> + * just cause unnecessary contention.
> + */
> if (has_pushable_tasks(rq)) {
> raw_spin_lock(&rq->lock);
> push_rt_task(rq);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched/rt: Document why has_pushable_tasks() isn't called with a runqueue lock
2017-03-01 8:37 ` Peter Zijlstra
@ 2017-03-02 20:38 ` Steven Rostedt
0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2017-03-02 20:38 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, LKML, Andrew Morton
On Wed, 1 Mar 2017 09:37:01 +0100
Peter Zijlstra <peterz@infradead.org> wrote:
> On Tue, Feb 28, 2017 at 04:48:56PM -0500, Steven Rostedt wrote:
>
> > + /*
> > + * Normally, has_pushable_tasks() would be performed within the
> > + * runqueue lock being held. But if it was not set when entering
>
> "not set" what? I'm having trouble parsing this.
I always forgot that with documentation, pronouns should be avoided.
"But if has_pushable_tasks is false when entering"
>
> > + * this hard interrupt handler function, then to have it set would
", then to have it set to true would"
> > + * require a wake up. A wake up of an RT task will either cause a
> > + * schedule if the woken task is higher priority than the running
> > + * task, or it would try to do a push from the CPU doing the wake
> > + * up. Grabbing the runqueue lock in such a case would more likely
> > + * just cause unnecessary contention.
> > + */
> > if (has_pushable_tasks(rq)) {
> > raw_spin_lock(&rq->lock);
> > push_rt_task(rq);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-02 20:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-28 21:48 [PATCH] sched/rt: Document why has_pushable_tasks() isn't called with a runqueue lock Steven Rostedt
2017-03-01 8:37 ` Peter Zijlstra
2017-03-02 20:38 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).