* [PATCH] O4int interactivity
@ 2003-07-10 7:23 Con Kolivas
0 siblings, 0 replies; only message in thread
From: Con Kolivas @ 2003-07-10 7:23 UTC (permalink / raw)
To: linux kernel mailing list; +Cc: Andrew Morton
[-- Attachment #1: clearsigned data --]
[-- Type: Text/Plain, Size: 1422 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here is a diff against the O3int patch in 2.5.74-mm3 trying to decrease audio
skips and improve X smoothness.
It is easier to become interactive with this one to try and decrease
application startup and wakeup time, while hopefully still preventing cpu
hogs from starving the machine.
Changes:
Child penalty increased to 95 as in early 2.5 O(1) implementations. This fixes
the "parent spinning madly waiting for child to spawn and in the process it
is the parent that starves the child"; 80 wasn't enough.
The sleep buffer has returned much smaller currently set at 50ms which
prevents fully interactive tasks from dropping down a priority for short
bursts of cpu activity (eg X).
Idle tasks now get a small priority boost so they "rest" at a dynamic priority
just below interactive. They now wake up to an interactive state more
rapidly, and spawn more interactive children.
The variable boost when a process has been running less than MAX_SLEEP_AVG has
been tweaked and consequently is more aggressive.
Slight code rearrangement to have one less if.. branch.
Also available for download here:
http://kernel.kolivas.org/2.5
Con
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/DRRhF6dfvkL3i1gRAgxQAJ9GAe3YSbu+WHO+G6axYVxhPAOfSwCglJFd
waidp26mha2+CwZ+oPOzuFI=
=q1rz
-----END PGP SIGNATURE-----
[-- Attachment #2: patch-O4int-0307101041 --]
[-- Type: text/x-diff, Size: 3031 bytes --]
--- linux-2.5.74-mm3/kernel/sched.c 2003-07-10 10:23:14.000000000 +1000
+++ linux-2.5.74-test/kernel/sched.c 2003-07-10 10:41:57.000000000 +1000
@@ -68,7 +68,7 @@
*/
#define MIN_TIMESLICE ( 10 * HZ / 1000)
#define MAX_TIMESLICE (200 * HZ / 1000)
-#define CHILD_PENALTY 80
+#define CHILD_PENALTY 95
#define PARENT_PENALTY 100
#define EXIT_WEIGHT 3
#define PRIO_BONUS_RATIO 25
@@ -76,6 +76,7 @@
#define MIN_SLEEP_AVG (HZ)
#define MAX_SLEEP_AVG (10*HZ)
#define STARVATION_LIMIT (10*HZ)
+#define SLEEP_BUFFER (HZ/20)
#define NODE_THRESHOLD 125
#define MAX_BONUS ((MAX_USER_PRIO - MAX_RT_PRIO) * PRIO_BONUS_RATIO / 100)
@@ -392,33 +393,42 @@ static inline void activate_task(task_t
unsigned long runtime = jiffies - p->avg_start;
/*
- * 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.
- */
- 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
+ * will get just under interactive status with a small runtime
+ * to allow them to become interactive or non-interactive rapidly
*/
if (sleep_time > MIN_SLEEP_AVG){
p->avg_start = jiffies - MIN_SLEEP_AVG;
- p->sleep_avg = MIN_SLEEP_AVG / 2;
+ p->sleep_avg = MIN_SLEEP_AVG * (MAX_BONUS - INTERACTIVE_DELTA - 1) /
+ MAX_BONUS;
+ } 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.
+ */
+ 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 - MIN_SLEEP_AVG) < MAX_SLEEP_AVG)
+ p->sleep_avg += (runtime - p->sleep_avg) *
+ (MAX_SLEEP_AVG + MIN_SLEEP_AVG - runtime) *
+ (MAX_BONUS - INTERACTIVE_DELTA) / MAX_BONUS / MAX_SLEEP_AVG;
+
+ /*
+ * Keep a small buffer of SLEEP_BUFFER sleep_avg to
+ * prevent fully interactive tasks from becoming
+ * lower priority with small bursts of cpu usage.
+ */
+ if (p->sleep_avg > (MAX_SLEEP_AVG + SLEEP_BUFFER))
+ p->sleep_avg = MAX_SLEEP_AVG + SLEEP_BUFFER;
}
if (unlikely(p->avg_start > jiffies)){
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-07-10 7:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-10 7:23 [PATCH] O4int interactivity Con Kolivas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox