linux-kernel.vger.kernel.org archive mirror
 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>,
	Felipe Alfaro Solana <felipe_alfaro@linuxmail.org>,
	Voluspa <lista1@comhem.se>
Subject: [PATCH]O19int
Date: Fri, 29 Aug 2003 15:50:22 +1000	[thread overview]
Message-ID: <200308291550.28159.kernel@kolivas.org> (raw)

[-- Attachment #1: clearsigned data --]
[-- Type: Text/Plain, Size: 476 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Small error in the just interactive logic has been corrected.

Idle tasks get one higher priority than just interactive so they don't get 
swamped under heavy load.

Cosmetic cleanup.

Patch against 2.6.0-test4-mm2

Con
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/TumgZUg7+tp6mRURAtkkAJwJKjY1DmvuNR+eyphU07svVP7uWQCeMHgv
pcYhT1dX+iaFq6F1Son8pGc=
=rxj9
-----END PGP SIGNATURE-----

[-- Attachment #2: patch-O18.1-O19int --]
[-- Type: text/x-diff, Size: 2674 bytes --]

--- linux-2.6.0-test4-mm2/kernel/sched.c	2003-08-28 22:57:49.000000000 +1000
+++ linux-2.6.0-test4-mm2-O19/kernel/sched.c	2003-08-29 15:37:06.000000000 +1000
@@ -64,8 +64,8 @@
 /*
  * Some helpers for converting nanosecond timing to jiffy resolution
  */
-#define NS_TO_JIFFIES(TIME)	(TIME / (1000000000 / HZ))
-#define JIFFIES_TO_NS(TIME)	(TIME * (1000000000 / HZ))
+#define NS_TO_JIFFIES(TIME)	((TIME) / (1000000000 / HZ))
+#define JIFFIES_TO_NS(TIME)	((TIME) * (1000000000 / HZ))
 
 /*
  * These are the 'tuning knobs' of the scheduler:
@@ -132,7 +132,8 @@
 	((p)->prio <= (p)->static_prio - DELTA(p))
 
 #define JUST_INTERACTIVE_SLEEP(p) \
-	(MAX_SLEEP_AVG - (DELTA(p) * AVG_TIMESLICE))
+	(JIFFIES_TO_NS(MAX_SLEEP_AVG * \
+		(MAX_BONUS / 2 + DELTA((p)) + 1) / MAX_BONUS - 1))
 
 #define HIGH_CREDIT(p) \
 	((p)->interactive_credit > MAX_SLEEP_AVG)
@@ -382,10 +383,8 @@ static void recalc_task_prio(task_t *p, 
 		 * prevent them suddenly becoming cpu hogs and starving
 		 * other processes.
 		 */
-		if (p->mm && sleep_time >
-			JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p)))
-				p->sleep_avg =
-					JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p));
+		if (p->mm && sleep_time >JUST_INTERACTIVE_SLEEP(p))
+			p->sleep_avg = JUST_INTERACTIVE_SLEEP(p) + 1;
 		else {
 			/*
 			 * The lower the sleep avg a task has the more
@@ -405,16 +404,15 @@ static void recalc_task_prio(task_t *p, 
 			/*
 			 * Non high_credit tasks waking from uninterruptible
 			 * sleep are limited in their sleep_avg rise as they
-			 * are likely to be waiting on I/O
+			 * are likely to be cpu hogs waiting on I/O
 			 */
 			if (p->activated == -1 && !HIGH_CREDIT(p) && p->mm){
-				if (p->sleep_avg >=
-					JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p)))
-						sleep_time = 0;
+				if (p->sleep_avg >= JUST_INTERACTIVE_SLEEP(p))
+					sleep_time = 0;
 				else if (p->sleep_avg + sleep_time >=
-					JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p))){
+					JUST_INTERACTIVE_SLEEP(p)){
 						p->sleep_avg =
-							JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p));
+							JUST_INTERACTIVE_SLEEP(p);
 						sleep_time = 0;
 					}
 			}
@@ -431,7 +429,8 @@ static void recalc_task_prio(task_t *p, 
 
 			if (p->sleep_avg > NS_MAX_SLEEP_AVG){
 				p->sleep_avg = NS_MAX_SLEEP_AVG;
-				p->interactive_credit += !(HIGH_CREDIT(p));
+				if (!HIGH_CREDIT(p))
+					p->interactive_credit++;
 			}
 		}
 	}
@@ -1547,8 +1546,8 @@ switch_tasks:
 	prev->sleep_avg -= run_time;
 	if ((long)prev->sleep_avg <= 0){
 		prev->sleep_avg = 0;
-		prev->interactive_credit -=
-			!(HIGH_CREDIT(prev) || LOW_CREDIT(prev));
+		if (!(HIGH_CREDIT(prev) || LOW_CREDIT(prev)))
+			prev->interactive_credit--;
 	}
 	prev->timestamp = now;
 

             reply	other threads:[~2003-08-29  5:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-29  5:50 Con Kolivas [this message]
2003-08-29  7:39 ` [PATCH]O19int Voluspa
2003-08-29 12:01 ` [PATCH]O19int Felipe Alfaro Solana
2003-08-29 15:31 ` [PATCH]O19int Apurva Mehta
2003-08-29 16:29   ` [PATCH]O19int Rahul Karnik
2003-08-29 16:41     ` [PATCH]O19int Apurva Mehta
2003-08-29 17:42       ` [PATCH]O19int Rahul Karnik
2003-08-30 12:42         ` [PATCH]O19int Con Kolivas
2003-08-30 15:45         ` [PATCH]O19int Apurva Mehta
2003-08-29 17:39 ` [PATCH]O19int Maciej Soltysiak

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=200308291550.28159.kernel@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=akpm@osdl.org \
    --cc=felipe_alfaro@linuxmail.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lista1@comhem.se \
    /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;
as well as URLs for NNTP newsgroup(s).