From: Ingo Molnar <mingo@elte.hu>
To: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] scheduler: strange behavor with massive interactive processes
Date: Tue, 27 Mar 2007 21:14:20 +0200 [thread overview]
Message-ID: <20070327191420.GB29929@elte.hu> (raw)
In-Reply-To: <87r6rb1nbm.wl%takeuchi_satoru@jp.fujitsu.com>
* Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> wrote:
> Hi Ingo and all,
>
> When I was executing massive interactive processes, I found that some
> of them occupy CPU time and the others hardly run.
yeah.
> I also attach the test program which easily recreates this problem.
thanks, this is really helpful - does the patch below improve the
situation?
Ingo
---------------------->
Subject: [patch] sched: improve starvation prevention
From: Ingo Molnar <mingo@elte.hu>
improve starvation prevention by guaranteeing STARVATION_LIMIT. This
also simplifies the code a bit.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c
+++ linux/kernel/sched.c
@@ -235,7 +235,7 @@ struct rq {
*/
unsigned long nr_uninterruptible;
- unsigned long expired_timestamp;
+ unsigned long switch_timestamp;
/* Cached timestamp set by update_cpu_clock() */
unsigned long long most_recent_timestamp;
struct task_struct *curr, *idle;
@@ -3103,9 +3103,9 @@ static inline int expired_starving(struc
{
if (rq->curr->static_prio > rq->best_expired_prio)
return 1;
- if (!STARVATION_LIMIT || !rq->expired_timestamp)
+ if (!STARVATION_LIMIT)
return 0;
- if (jiffies - rq->expired_timestamp > STARVATION_LIMIT * rq->nr_running)
+ if (jiffies - rq->switch_timestamp > STARVATION_LIMIT)
return 1;
return 0;
}
@@ -3218,8 +3218,6 @@ static void task_running_tick(struct rq
p->time_slice = task_timeslice(p);
p->first_time_slice = 0;
- if (!rq->expired_timestamp)
- rq->expired_timestamp = jiffies;
if (!TASK_INTERACTIVE(p) || expired_starving(rq)) {
enqueue_task(p, rq->expired);
if (p->static_prio < rq->best_expired_prio)
@@ -3406,7 +3404,7 @@ need_resched_nonpreemptible:
idle_balance(cpu, rq);
if (!rq->nr_running) {
next = rq->idle;
- rq->expired_timestamp = 0;
+ rq->switch_timestamp = jiffies;
goto switch_tasks;
}
}
@@ -3420,7 +3418,7 @@ need_resched_nonpreemptible:
rq->active = rq->expired;
rq->expired = array;
array = rq->active;
- rq->expired_timestamp = 0;
+ rq->switch_timestamp = jiffies;
rq->best_expired_prio = MAX_PRIO;
}
next prev parent reply other threads:[~2007-03-27 19:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-27 1:34 [BUG] scheduler: strange behavor with massive interactive processes Satoru Takeuchi
2007-03-27 5:04 ` Mike Galbraith
2007-03-28 8:38 ` Mike Galbraith
2007-03-28 11:45 ` Ingo Molnar
2007-03-28 11:51 ` Mike Galbraith
2007-03-31 10:15 ` Satoru Takeuchi
2007-03-31 10:29 ` Mike Galbraith
2007-03-27 19:14 ` Ingo Molnar [this message]
2007-03-28 1:16 ` Satoru Takeuchi
2007-03-31 8:16 ` Satoru Takeuchi
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=20070327191420.GB29929@elte.hu \
--to=mingo@elte.hu \
--cc=linux-kernel@vger.kernel.org \
--cc=takeuchi_satoru@jp.fujitsu.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