public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: linux kernel mailing list <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>
Subject: [PATCH] O4int interactivity
Date: Thu, 10 Jul 2003 17:23:13 +1000	[thread overview]
Message-ID: <200307101723.24615.kernel@kolivas.org> (raw)

[-- 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)){

                 reply	other threads:[~2003-07-10  7:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200307101723.24615.kernel@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.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