From: Hillf Danton <dhillf@gmail.com>
To: Mike Galbraith <efault@gmx.de>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Yong Zhang <yong.zhang0@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] sched: avoid overpull when pulling RT task
Date: Mon, 16 May 2011 21:14:56 +0800 [thread overview]
Message-ID: <BANLkTino730kar=fEDJGCy8bCSVUe52aOw@mail.gmail.com> (raw)
In-Reply-To: <1305441316.7460.40.camel@marge.simson.net>
On Sun, May 15, 2011 at 2:35 PM, Mike Galbraith <efault@gmx.de> wrote:
> On Sun, 2011-05-15 at 12:35 +0800, Hillf Danton wrote:
>> When pulling RT task for a given runqueue, pulling is continued even
>> after certain RT tasks get pulled, in case there are still higher
>> priority tasks on other runqueues, though it is low likelihood as the
>> comment says. The load of of this runqueue, on other hand, should also
>> be concerned. If it is overloaded, the low likelihood should be
>> abandoned to avoid overpull.
>>
>> Signed-off-by: Hillf Danton <dhillf@gmail.com>
>> ---
>> kernel/sched_rt.c | 5 +++++
>> 1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
>> index 14c764b..b425ca1 100644
>> --- a/kernel/sched_rt.c
>> +++ b/kernel/sched_rt.c
>> @@ -1508,6 +1508,11 @@ static int pull_rt_task(struct rq *this_rq)
>> }
>> skip:
>> double_unlock_balance(this_rq, src_rq);
>> +
>> + /* if pulled we have to also avoid overpull */
>> + if (ret == 1)
>> + if (likely(rt_overloaded(this_rq)))
>> + break;
>> }
>>
>> return ret;
>
> Hm.
>
> It looks to me like you should remove the rt_overloaded() test (and
> function) entirely instead. If you look at pull usage, the intent is
> that system wide, higher priority tasks run before lower.
>
> I don't think it matters much if we pull too much, since what we pull
> while traversing is ever increasing in priority _and waiting_ anyway.
> We may do a bit more work than strictly necessary on the way to the
> highest priority runnable task, but what matters most is that highest
> priority gets to the CPU first, which testing for overload can stymie.
>
> (seems pulling more than one could turn out either good or bad for any
> but the highest priority task though, lacking crystal ball)
>
Hi Mike
To win the crystal ball, I take another try.
In the following patch, pulling is played in two rounds. In the first round,
the highest priority task is determined with no pull operation. Pulling is
carried out in the second round, and if the highest priority task is pulled,
pulling could be stopped when overload detected, to relieve overpull.
Please review again, thanks.
Hillf
---
--- a/kernel/sched_rt.c 2011-04-27 11:48:50.000000000 +0800
+++ b/kernel/sched_rt.c 2011-05-16 20:42:18.000000000 +0800
@@ -1425,10 +1425,11 @@ static int pull_rt_task(struct rq *this_
int this_cpu = this_rq->cpu, ret = 0, cpu;
struct task_struct *p;
struct rq *src_rq;
+ int highest_prio = MAX_RT_PRIO;
+ int highest_pulled = 0;
+ int first_round = 1;
- if (likely(!rt_overloaded(this_rq)))
- return 0;
-
+again:
for_each_cpu(cpu, this_rq->rd->rto_mask) {
if (this_cpu == cpu)
continue;
@@ -1480,6 +1481,18 @@ static int pull_rt_task(struct rq *this_
if (p->prio < src_rq->curr->prio)
goto skip;
+ /*
+ * To avoid overpull, we play pulling in two rounds,and
+ * the highest task is determined in the first round.
+ */
+ if (first_round) {
+ if (p->prio < highest_prio)
+ highest_prio = p->prio;
+ goto skip;
+ }
+ if (p->prio <= highest_prio)
+ highest_pulled = 1;
+
ret = 1;
deactivate_task(src_rq, p, 0);
@@ -1494,6 +1507,15 @@ static int pull_rt_task(struct rq *this_
}
skip:
double_unlock_balance(this_rq, src_rq);
+
+ if (highest_pulled && rt_overloaded(this_rq))
+ break;
+ }
+
+ if (first_round && highest_prio != MAX_RT_PRIO) {
+ /* try to pull higher tasks on other RQs */
+ first_round = 0;
+ goto again;
}
return ret;
next prev parent reply other threads:[~2011-05-16 13:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-15 4:35 Hillf Danton
2011-05-15 6:35 ` Mike Galbraith
2011-05-15 11:18 ` Hillf Danton
2011-05-16 13:14 ` Hillf Danton [this message]
2011-05-16 14:11 ` Mike Galbraith
2011-05-17 14:25 ` Hillf Danton
2011-05-17 18:50 ` Mike Galbraith
2011-05-18 1:21 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTino730kar=fEDJGCy8bCSVUe52aOw@mail.gmail.com' \
--to=dhillf@gmail.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=yong.zhang0@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®