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]O15int for interactivity
Date: Tue, 12 Aug 2003 22:26:11 +1000	[thread overview]
Message-ID: <200308122226.11557.kernel@kolivas.org> (raw)

This patch addresses the problem of tasks that preempt their children when 
they're forking, wasting cpu cycles until they get demoted to a priority where 
they no longer preempt their child. Although this has been said to be a design 
flaw in the applications, it can cause sustained periods of starvation due to 
this coding problem, and the more I looked, the more examples I found of this 
happening.

Tasks now cannot preempt their own children. This speeds up the startup of 
child applications (eg pgp signed email).

This change has allowed tasks to stay at higher priority for much longer so 
the sleep avg decay of high credit tasks has been changed to match the rate of 
rise during periods of sleep (which I wanted to do originally but was limited 
by the first problem). This makes for much more sustained interactivity at 
extreme loads, and much less X jerkiness.

Con

Patch against 2.6.0-test3-mm1:

--- linux-2.6.0-test3-mm1-O14.1/kernel/sched.c	2003-08-12 22:04:13.000000000 +1000
+++ linux-2.6.0-test3-mm1/kernel/sched.c	2003-08-12 22:03:47.000000000 +1000
@@ -620,8 +620,13 @@ repeat_lock_task:
 				__activate_task(p, rq);
 			else {
 				activate_task(p, rq);
-				if (TASK_PREEMPTS_CURR(p, rq))
-					resched_task(rq->curr);
+				/*
+				 * Parents are not allowed to preempt their
+				 * children
+				 */
+				if (TASK_PREEMPTS_CURR(p, rq) &&
+					p != rq->curr->parent)
+						resched_task(rq->curr);
 			}
 			success = 1;
 		}
@@ -1124,7 +1129,7 @@ static inline void pull_task(runqueue_t 
 	 * Note that idle threads have a prio of MAX_PRIO, for this test
 	 * to be always true for them.
 	 */
-	if (TASK_PREEMPTS_CURR(p, this_rq))
+	if (TASK_PREEMPTS_CURR(p, this_rq) && p != this_rq->curr->parent)
 		set_need_resched();
 }
 
@@ -1493,9 +1498,8 @@ need_resched:
 	 * priority bonus
 	 */
 	if (HIGH_CREDIT(prev))
-		run_time /= (MAX_BONUS + 1 -
-			(NS_TO_JIFFIES(prev->sleep_avg) * MAX_BONUS /
-			MAX_SLEEP_AVG));
+		run_time /= ((NS_TO_JIFFIES(prev->sleep_avg) * MAX_BONUS /
+				MAX_SLEEP_AVG) ? : 1);
 
 	spin_lock_irq(&rq->lock);
 


             reply	other threads:[~2003-08-12 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-12 12:26 Con Kolivas [this message]
2003-08-12 12:36 ` [PATCH]O15int for interactivity Måns Rullgård
2003-08-12 14:00   ` Felipe Alfaro Solana
2003-08-12 14:04   ` Con Kolivas
2003-08-14  2:44 ` Wes Janzen
2003-08-14  2:54   ` Con Kolivas
2003-08-16  4:10 ` Martin Schlemmer

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=200308122226.11557.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