From: Con Kolivas <kernel@kolivas.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Felipe Alfaro Solana <felipe_alfaro@linuxmail.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: Ingo Molnar and Con Kolivas 2.6 scheduler patches
Date: Sun, 27 Jul 2003 20:19:48 +1000 [thread overview]
Message-ID: <200307272019.48429.kernel@kolivas.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0307271158390.10340-100000@localhost.localdomain>
On Sun, 27 Jul 2003 20:02, Ingo Molnar wrote:
> Con,
>
> would you mind to explain the reasoning behind the avg_start,
> MIN_SLEEP_AVG and normalise_sleep() logic in your patch?
>
> [for reference i've attached your patches in a single unified patch up to
> O8int, against 2.6.0-test1.]
Unfortunately that was my older approach so none of that work is valid, and
MIN_SLEEP_AVG and normalise_sleep() have been killed off. In essence
the most essential difference is the way the sleep avg is incremented.
p->sleep_avg = (p->sleep_avg * MAX_BONUS /
MAX_SLEEP_AVG + 1) *
MAX_SLEEP_AVG / MAX_BONUS;
where
#define MAX_BONUS (MAX_USER_PRIO * PRIO_BONUS_RATIO / 100)
...
basically any task that sleeps >= 2 milliseconds gets elevated by
one bonus each time, and the tuning to go with that to prevent starvation
and maintain fairness. I have some more tuning in the works as well.
Here is a full current O9int against 2.6.0-test1 for clarity.
--- linux-2.6.0-test1/kernel/sched.c 2003-07-23 21:03:43.000000000 +1000
+++ linux-2.6.0-test1-O9/kernel/sched.c 2003-07-27 12:19:30.000000000 +1000
@@ -68,14 +68,16 @@
*/
#define MIN_TIMESLICE ( 10 * HZ / 1000)
#define MAX_TIMESLICE (200 * HZ / 1000)
-#define CHILD_PENALTY 50
+#define TIMESLICE_GRANULARITY (HZ / 20 ?: 1)
+#define CHILD_PENALTY 90
#define PARENT_PENALTY 100
#define EXIT_WEIGHT 3
#define PRIO_BONUS_RATIO 25
#define INTERACTIVE_DELTA 2
-#define MAX_SLEEP_AVG (10*HZ)
-#define STARVATION_LIMIT (10*HZ)
+#define MAX_SLEEP_AVG (HZ)
+#define STARVATION_LIMIT (HZ)
#define NODE_THRESHOLD 125
+#define MAX_BONUS (MAX_USER_PRIO * PRIO_BONUS_RATIO / 100)
/*
* If a task is 'interactive' then we reinsert it in the active
@@ -347,34 +349,38 @@ static inline void __activate_task(task_
*/
static inline void activate_task(task_t *p, runqueue_t *rq)
{
- long sleep_time = jiffies - p->last_run - 1;
+ if (likely(p->last_run)){
+ long sleep_time = jiffies - p->last_run - 1;
- if (sleep_time > 0) {
- int sleep_avg;
+ if (sleep_time > 0) {
+ /*
+ * User tasks that sleep a long time are categorised as
+ * idle and will get just under interactive status to
+ * prevent them suddenly becoming cpu hogs and starving
+ * other processes.
+ */
+ if (p->mm && sleep_time > HZ)
+ p->sleep_avg = MAX_SLEEP_AVG *
+ (MAX_BONUS - 1) / MAX_BONUS - 1;
+ else {
- /*
- * This code gives a bonus to interactive tasks.
- *
- * The boost works by updating the 'average sleep time'
- * value here, based on ->last_run. The more time a task
- * spends sleeping, the higher the average gets - and the
- * higher the priority boost gets as well.
- */
- sleep_avg = p->sleep_avg + sleep_time;
+ /*
+ * Processes that sleep get pushed to one higher
+ * priority each time they sleep greater than
+ * one tick. -ck
+ */
+ p->sleep_avg = (p->sleep_avg * MAX_BONUS /
+ MAX_SLEEP_AVG + 1) *
+ MAX_SLEEP_AVG / MAX_BONUS;
- /*
- * 'Overflow' bonus ticks go to the waker as well, so the
- * ticks are not lost. This has the effect of further
- * boosting tasks that are related to maximum-interactive
- * tasks.
- */
- if (sleep_avg > MAX_SLEEP_AVG)
- sleep_avg = MAX_SLEEP_AVG;
- if (p->sleep_avg != sleep_avg) {
- p->sleep_avg = sleep_avg;
- p->prio = effective_prio(p);
+ if (p->sleep_avg > MAX_SLEEP_AVG)
+ p->sleep_avg = MAX_SLEEP_AVG;
+ }
}
- }
+ } else
+ p->last_run = jiffies;
+
+ p->prio = effective_prio(p);
__activate_task(p, rq);
}
@@ -553,6 +559,7 @@ void wake_up_forked_process(task_t * p)
current->sleep_avg = current->sleep_avg * PARENT_PENALTY / 100;
p->sleep_avg = p->sleep_avg * CHILD_PENALTY / 100;
p->prio = effective_prio(p);
+ p->last_run = 0;
set_task_cpu(p, smp_processor_id());
if (unlikely(!current->array))
@@ -1244,6 +1251,16 @@ void scheduler_tick(int user_ticks, int
enqueue_task(p, rq->expired);
} else
enqueue_task(p, rq->active);
+ } else if (!((task_timeslice(p) - p->time_slice) %
+ TIMESLICE_GRANULARITY) && (p->time_slice > MIN_TIMESLICE)) {
+ /*
+ * Running user tasks get requeued with their remaining
+ * timeslice after TIMESLICE_GRANULARITY provided they have at
+ * least MIN_TIMESLICE to go.
+ */
+ dequeue_task(p, rq->active);
+ set_tsk_need_resched(p);
+ enqueue_task(p, rq->active);
}
out_unlock:
spin_unlock(&rq->lock);
next prev parent reply other threads:[~2003-07-27 10:00 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-26 9:30 Ingo Molnar and Con Kolivas 2.6 scheduler patches Felipe Alfaro Solana
2003-07-26 9:46 ` Marc-Christian Petersen
2003-07-26 10:02 ` Ismael Valladolid Torres
2003-07-26 10:10 ` Eugene Teo
2003-07-26 11:24 ` Ed Sweetman
2003-07-26 17:00 ` Rahul Karnik
2003-07-27 15:46 ` Daniel Phillips
2003-07-26 16:52 ` Diego Calleja García
2003-07-26 18:35 ` Andrew Morton
2003-07-26 23:01 ` Diego Calleja García
2003-07-28 9:38 ` Felipe Alfaro Solana
2003-07-28 10:37 ` Måns Rullgård
2003-07-28 17:06 ` Diego Calleja García
2003-07-27 2:38 ` Con Kolivas
2003-07-27 7:39 ` Willy Tarreau
2003-07-27 9:12 ` Ingo Molnar
2003-07-27 11:54 ` Con Kolivas
2003-07-27 20:18 ` Daniel Phillips
2003-07-26 22:05 ` Ed Sweetman
2003-08-01 15:38 ` Daniel Phillips
2003-07-31 23:02 ` Ed Sweetman
2003-07-27 2:39 ` Ed Sweetman
2003-07-29 13:56 ` Timothy Miller
2003-07-29 13:57 ` Con Kolivas
2003-07-29 15:30 ` Timothy Miller
2003-07-29 15:52 ` Helge Hafting
2003-07-29 16:26 ` Timothy Miller
2003-07-30 14:46 ` Daniel Phillips
2003-07-29 15:40 ` Timothy Miller
2003-07-30 16:17 ` Daniel Phillips
2003-08-08 21:09 ` Bill Huey
2003-08-06 21:28 ` Rob Landley
2003-08-07 9:34 ` Helge Hafting
2003-08-07 15:42 ` Daniel Phillips
2003-08-07 20:45 ` William Lee Irwin III
2003-08-07 20:51 ` Rob Landley
2003-08-07 21:40 ` Ed Sweetman
2003-08-07 22:17 ` William Lee Irwin III
2003-08-08 0:01 ` Rob Landley
2003-08-09 20:52 ` George Anzinger
2003-08-14 0:24 ` Rob Landley
2003-08-14 8:01 ` George Anzinger
2003-08-16 9:10 ` Rob Landley
2003-08-16 14:29 ` APM and 2.5.75 not resuming properly Jamie Lokier
2003-08-16 15:03 ` Stephen Rothwell
2003-08-16 16:12 ` Jamie Lokier
2003-08-16 20:43 ` Rob Landley
2003-08-13 3:38 ` Ingo Molnar and Con Kolivas 2.6 scheduler patches George Anzinger
2003-08-08 6:08 ` Daniel Phillips
2003-07-26 12:08 ` Ismael Valladolid Torres
2003-07-26 14:54 ` Con Kolivas
2003-07-26 14:49 ` Con Kolivas
2003-07-26 14:47 ` Con Kolivas
2003-07-26 16:42 ` Lou Langholtz
2003-07-26 16:40 ` Jens Axboe
2003-07-26 18:19 ` William Lee Irwin III
2003-07-26 18:31 ` Felipe Alfaro Solana
2003-07-26 19:20 ` William Lee Irwin III
2003-07-26 19:47 ` William Lee Irwin III
2003-07-27 9:24 ` Ingo Molnar
2003-07-27 9:57 ` Con Kolivas
2003-07-27 10:02 ` Ingo Molnar
2003-07-27 10:19 ` Con Kolivas [this message]
2003-07-28 22:44 ` Timothy Miller
-- strict thread matches above, loose matches on Subject: below --
2003-07-26 14:44 Downing, Thomas
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=200307272019.48429.kernel@kolivas.org \
--to=kernel@kolivas.org \
--cc=felipe_alfaro@linuxmail.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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