From: Guillaume Chazarain <gfc@altern.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Interactivity bits
Date: Thu, 10 Jul 2003 09:14:57 +0200 [thread overview]
Message-ID: <86JEQO767187204DB6082KETIGUR.3f0d1271@monpc> (raw)
In-Reply-To: <JFNL84UTSKFOJFDFD9D8GBF2WICKG.3f0b25af@monpc>
[-- Attachment #1: Type: text/plain, Size: 3185 bytes --]
Hello,
here is the latest version of my simple patch.
I increased INTERACTIVE_DELTA to 4 as told me
Mike Galbraith, he also explained to me why
the p->state == TASK_INTERRUPTIBLE test was a bad thing.
The previous patch against -mm3 was an accident, it
messed my tweaks with Con's work and it was... cough
not tested...
I'd appreciate any feedback.
Thanks.
Guillaume
--- linux-2.5.74-bk7/kernel/sched.c.old 2003-07-09 10:08:01.000000000 +0200
+++ linux-2.5.74-bk7/kernel/sched.c 2003-07-10 00:35:59.000000000 +0200
@@ -68,11 +68,11 @@
*/
#define MIN_TIMESLICE ( 10 * HZ / 1000)
#define MAX_TIMESLICE (200 * HZ / 1000)
-#define CHILD_PENALTY 50
-#define PARENT_PENALTY 100
+#define CHILD_PENALTY 80
+#define PARENT_PENALTY 90
#define EXIT_WEIGHT 3
-#define PRIO_BONUS_RATIO 25
-#define INTERACTIVE_DELTA 2
+#define PRIO_BONUS_RATIO 45
+#define INTERACTIVE_DELTA 4
#define MAX_SLEEP_AVG (10*HZ)
#define STARVATION_LIMIT (10*HZ)
#define NODE_THRESHOLD 125
@@ -88,13 +88,13 @@
* We scale it linearly, offset by the INTERACTIVE_DELTA delta.
* Here are a few examples of different nice levels:
*
- * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,0,0]
- * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,0,0,0,0]
- * TASK_INTERACTIVE( 0): [1,1,1,1,0,0,0,0,0,0,0]
- * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0]
- * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0]
+ * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE( 0): [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
*
- * (the X axis represents the possible -5 ... 0 ... +5 dynamic
+ * (the X axis represents the possible -9 ... 0 ... +9 dynamic
* priority range a task can explore, a value of '1' means the
* task is rated interactive.)
*
@@ -303,9 +303,9 @@
* priority but is modified by bonuses/penalties.
*
* We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
- * into the -5 ... 0 ... +5 bonus/penalty range.
+ * into the -9 ... 0 ... +9 bonus/penalty range.
*
- * We use 25% of the full 0...39 priority range so that:
+ * We use 50% of the full 0...39 priority range so that:
*
* 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
* 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
@@ -347,9 +347,9 @@
*/
static inline void activate_task(task_t *p, runqueue_t *rq)
{
- long sleep_time = jiffies - p->last_run - 1;
+ long sleep_time = jiffies - p->last_run;
- if (sleep_time > 0) {
+ if (sleep_time) {
int sleep_avg;
/*
@@ -361,15 +361,9 @@
* higher the priority boost gets as well.
*/
sleep_avg = p->sleep_avg + sleep_time;
-
- /*
- * '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);
[-- Attachment #2: patch.-mm3 --]
[-- Type: application/octet-stream, Size: 5807 bytes --]
--- linux-2.5.74-mm3/kernel/sched.c.old 2003-07-09 16:44:31.000000000 +0200
+++ linux-2.5.74-mm3/kernel/sched.c 2003-07-10 00:34:27.000000000 +0200
@@ -69,15 +69,13 @@
#define MIN_TIMESLICE ( 10 * HZ / 1000)
#define MAX_TIMESLICE (200 * HZ / 1000)
#define CHILD_PENALTY 80
-#define PARENT_PENALTY 100
+#define PARENT_PENALTY 90
#define EXIT_WEIGHT 3
-#define PRIO_BONUS_RATIO 25
-#define INTERACTIVE_DELTA 2
-#define MIN_SLEEP_AVG (HZ)
+#define PRIO_BONUS_RATIO 45
+#define INTERACTIVE_DELTA 4
#define MAX_SLEEP_AVG (10*HZ)
#define STARVATION_LIMIT (10*HZ)
#define NODE_THRESHOLD 125
-#define MAX_BONUS ((MAX_USER_PRIO - MAX_RT_PRIO) * PRIO_BONUS_RATIO / 100)
/*
* If a task is 'interactive' then we reinsert it in the active
@@ -90,13 +88,13 @@
* We scale it linearly, offset by the INTERACTIVE_DELTA delta.
* Here are a few examples of different nice levels:
*
- * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,0,0]
- * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,0,0,0,0]
- * TASK_INTERACTIVE( 0): [1,1,1,1,0,0,0,0,0,0,0]
- * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0]
- * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE(-20): [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0]
+ * TASK_INTERACTIVE(-10): [1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE( 0): [1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE( 10): [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
+ * TASK_INTERACTIVE( 19): [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
*
- * (the X axis represents the possible -5 ... 0 ... +5 dynamic
+ * (the X axis represents the possible -9 ... 0 ... +9 dynamic
* priority range a task can explore, a value of '1' means the
* task is rated interactive.)
*
@@ -299,35 +297,15 @@
array->nr_active++;
p->array = array;
}
-/*
- * normalise_sleep converts a task's sleep_avg to
- * an appropriate proportion of MIN_SLEEP_AVG.
- */
-static inline void normalise_sleep(task_t *p)
-{
- unsigned long old_avg_time = jiffies - p->avg_start;
-
- if (unlikely(old_avg_time < MIN_SLEEP_AVG))
- return;
-
- if (p->sleep_avg > MAX_SLEEP_AVG)
- p->sleep_avg = MAX_SLEEP_AVG;
-
- if (old_avg_time > MAX_SLEEP_AVG)
- old_avg_time = MAX_SLEEP_AVG;
-
- p->sleep_avg = p->sleep_avg * MIN_SLEEP_AVG / old_avg_time;
- p->avg_start = jiffies - MIN_SLEEP_AVG;
-}
/*
* effective_prio - return the priority that is based on the static
* priority but is modified by bonuses/penalties.
*
* We scale the actual sleep average [0 .... MAX_SLEEP_AVG]
- * into the -5 ... 0 ... +5 bonus/penalty range.
+ * into the -9 ... 0 ... +9 bonus/penalty range.
*
- * We use 25% of the full 0...39 priority range so that:
+ * We use 50% of the full 0...39 priority range so that:
*
* 1) nice +19 interactive tasks do not preempt nice 0 CPU hogs.
* 2) nice -20 CPU hogs do not get preempted by nice 0 tasks.
@@ -337,28 +315,11 @@
static int effective_prio(task_t *p)
{
int bonus, prio;
- unsigned long sleep_period;
if (rt_task(p))
return p->prio;
- sleep_period = jiffies - p->avg_start;
-
- if (unlikely(!sleep_period))
- return p->static_prio;
-
- if (sleep_period > MAX_SLEEP_AVG)
- sleep_period = MAX_SLEEP_AVG;
-
- if (p->sleep_avg > sleep_period)
- sleep_period = p->sleep_avg;
-
- /*
- * The bonus is determined according to the accumulated
- * sleep avg over the duration the task has been running
- * until it reaches MAX_SLEEP_AVG. -ck
- */
- bonus = MAX_USER_PRIO*PRIO_BONUS_RATIO*p->sleep_avg/sleep_period/100 -
+ bonus = MAX_USER_PRIO*PRIO_BONUS_RATIO*p->sleep_avg/MAX_SLEEP_AVG/100 -
MAX_USER_PRIO*PRIO_BONUS_RATIO/100/2;
prio = p->static_prio - bonus;
@@ -386,10 +347,10 @@
*/
static inline void activate_task(task_t *p, runqueue_t *rq)
{
- long sleep_time = jiffies - p->last_run - 1;
+ long sleep_time = jiffies - p->last_run;
- if (sleep_time > 0) {
- unsigned long runtime = jiffies - p->avg_start;
+ if (sleep_time) {
+ int sleep_avg;
/*
* This code gives a bonus to interactive tasks.
@@ -399,34 +360,15 @@
* spends sleeping, the higher the average gets - and the
* higher the priority boost gets as well.
*/
- p->sleep_avg += sleep_time;
- /*
- * Give a bonus to tasks that wake early on to prevent
- * the problem of the denominator in the bonus equation
- * from continually getting larger.
- */
- if (runtime < MAX_SLEEP_AVG)
- p->sleep_avg += (runtime - p->sleep_avg) * (MAX_SLEEP_AVG - runtime) *
- (MAX_BONUS - INTERACTIVE_DELTA) / MAX_BONUS / MAX_SLEEP_AVG;
-
- if (p->sleep_avg > MAX_SLEEP_AVG)
- p->sleep_avg = MAX_SLEEP_AVG;
-
- /*
- * Tasks that sleep a long time are categorised as idle and
- * get their static priority only
- */
- if (sleep_time > MIN_SLEEP_AVG){
- p->avg_start = jiffies - MIN_SLEEP_AVG;
- p->sleep_avg = MIN_SLEEP_AVG / 2;
- }
-
- if (unlikely(p->avg_start > jiffies)){
- p->avg_start = jiffies;
- p->sleep_avg = 0;
+ sleep_avg = p->sleep_avg + sleep_time;
+ 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);
}
}
- p->prio = effective_prio(p);
__activate_task(p, rq);
}
@@ -603,7 +545,6 @@
* from forking tasks that are max-interactive.
*/
current->sleep_avg = current->sleep_avg * PARENT_PENALTY / 100;
- normalise_sleep(p);
p->sleep_avg = p->sleep_avg * CHILD_PENALTY / 100;
p->prio = effective_prio(p);
set_task_cpu(p, smp_processor_id());
@@ -644,8 +585,6 @@
* If the child was a (relative-) CPU hog then decrease
* the sleep_avg of the parent as well.
*/
- normalise_sleep(p);
- normalise_sleep(p->parent);
if (p->sleep_avg < p->parent->sleep_avg)
p->parent->sleep_avg = (p->parent->sleep_avg * EXIT_WEIGHT +
p->sleep_avg) / (EXIT_WEIGHT + 1);
next prev parent reply other threads:[~2003-07-10 6:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-08 20:12 Guillaume Chazarain
2003-07-08 21:13 ` Davide Libenzi
2003-07-10 7:14 ` Guillaume Chazarain [this message]
2003-07-09 9:49 Guillaume Chazarain
2003-07-09 10:59 ` Marc-Christian Petersen
2003-07-09 15:59 ` Roberto Orenstein
[not found] <WQ98NJGC3OMJH0887GC84IHIE856FA.3f0c5488@monpc>
2003-07-09 18:44 ` Roberto Orenstein
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=86JEQO767187204DB6082KETIGUR.3f0d1271@monpc \
--to=gfc@altern.org \
--cc=linux-kernel@vger.kernel.org \
/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®