linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]O14int
@ 2003-08-08 15:49 Con Kolivas
  2003-08-08 17:57 ` [PATCH]O14int Timothy Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: Con Kolivas @ 2003-08-08 15:49 UTC (permalink / raw)
  To: linux kernel mailing list
  Cc: Andrew Morton, Felipe Alfaro Solana, Cliff White

More duck tape interactivity tweaks

Changes

Put some bounds on the interactive_credit and specified a size beyond which a 
task is considered highly interactive or not.

Moved the uninterruptible sleep limiting to within recalc_task_prio removing 
one call of the sched_clock() and being more careful about the limits.

Wli pointed out an error in the nanosecond to jiffy conversion which may have 
been causing too easy to migrate tasks on smp (? performance change).

Put greater limitation on the requeuing code; now it only requeues interactive 
tasks thereby letting cpu hogs run their full timeslice unabated which should 
improve cpu intensive task performance.

Made highly interactive tasks earn all their waiting time on the runqueue
during requeuing as sleep_avg.

Patch applies onto 2.6.0-test2-mm5

http://kernel.kolivas.org/2.5
has the patch and a full patch against 2.6.0-test2

Patch O13.1-O14int:

--- linux-2.6.0-test2-mm5-O13.1/kernel/sched.c	2003-08-08 22:47:08.000000000 +1000
+++ linux-2.6.0-test2-mm5/kernel/sched.c	2003-08-09 01:27:47.000000000 +1000
@@ -130,6 +130,15 @@
 #define JUST_INTERACTIVE_SLEEP(p) \
 	(MAX_SLEEP_AVG - (DELTA(p) * AVG_TIMESLICE))
 
+#define HIGH_CREDIT(p) \
+	((p)->interactive_credit > MAX_SLEEP_AVG)
+
+#define LOW_CREDIT(p) \
+	((p)->interactive_credit < -MAX_SLEEP_AVG)
+
+#define VARYING_CREDIT(p) \
+	(!(HIGH_CREDIT(p) || LOW_CREDIT(p)))
+
 #define TASK_PREEMPTS_CURR(p, rq) \
 	((p)->prio < (rq)->curr->prio || \
 		((p)->prio == (rq)->curr->prio && \
@@ -364,7 +373,7 @@ static void recalc_task_prio(task_t *p, 
 	unsigned long long __sleep_time = now - p->timestamp;
 	unsigned long sleep_time;
 
-	if (!p->sleep_avg)
+	if (!p->sleep_avg && VARYING_CREDIT(p))
 		p->interactive_credit--;
 
 	if (__sleep_time > NS_MAX_SLEEP_AVG)
@@ -373,7 +382,6 @@ static void recalc_task_prio(task_t *p, 
 		sleep_time = (unsigned long)__sleep_time;
 
 	if (likely(sleep_time > 0)) {
-
 		/*
 		 * User tasks that sleep a long time are categorised as
 		 * idle and will get just interactive status to stay active &
@@ -387,20 +395,38 @@ static void recalc_task_prio(task_t *p, 
 		else {
 			/*
 			 * The lower the sleep avg a task has the more
-			 * rapidly it will rise with sleep time. Tasks
-			 * without interactive_credit are limited to
-			 * one timeslice worth of sleep avg bonus.
+			 * rapidly it will rise with sleep time.
 			 */
 			sleep_time *= (MAX_BONUS + 1 -
 					(NS_TO_JIFFIES(p->sleep_avg) *
 					MAX_BONUS / MAX_SLEEP_AVG));
 
-			if (p->interactive_credit < 0 &&
+			/*
+			 * Tasks with low interactive_credit are limited to
+			 * one timeslice worth of sleep avg bonus.
+			 */
+			if (LOW_CREDIT(p) &&
 				sleep_time > JIFFIES_TO_NS(task_timeslice(p)))
 					sleep_time =
 						JIFFIES_TO_NS(task_timeslice(p));
 
 			/*
+			 * Non high_credit tasks waking from uninterruptible
+			 * sleep are limited in their sleep_avg rise
+			 */
+			if (!HIGH_CREDIT(p) && p->activated == -1){
+				if (p->sleep_avg >=
+					JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p)))
+						sleep_time = 0;
+				else if (p->sleep_avg + sleep_time >=
+					JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p))){
+						p->sleep_avg =
+							JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p));
+						sleep_time = 0;
+					}
+			}
+
+			/*
 			 * This code gives a bonus to interactive tasks.
 			 *
 			 * The boost works by updating the 'average sleep time'
@@ -418,7 +444,7 @@ 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++;
+				p->interactive_credit += VARYING_CREDIT(p);
 			}
 		}
 	}
@@ -588,11 +614,7 @@ repeat_lock_task:
 				 * Tasks on involuntary sleep don't earn
 				 * sleep_avg beyond just interactive state.
 				 */
-				if (NS_TO_JIFFIES(p->sleep_avg) >=
-					JUST_INTERACTIVE_SLEEP(p)){
-						p->timestamp = sched_clock();
-						p->activated = -1;
-				}
+				p->activated = -1;
 			}
 			if (sync)
 				__activate_task(p, rq);
@@ -1156,9 +1178,9 @@ skip_queue:
 	 * 3) are cache-hot on their current CPU.
 	 */
 
-#define CAN_MIGRATE_TASK(p,rq,this_cpu)					\
-	((!idle || (((now - (p)->timestamp)>>10) > cache_decay_ticks)) &&\
-		!task_running(rq, p) &&					\
+#define CAN_MIGRATE_TASK(p,rq,this_cpu)	\
+	((!idle || (NS_TO_JIFFIES(now - (p)->timestamp) > \
+		cache_decay_ticks)) && !task_running(rq, p) && \
 			cpu_isset(this_cpu, (p)->cpus_allowed))
 
 	curr = curr->prev;
@@ -1366,13 +1388,23 @@ void scheduler_tick(int user_ticks, int 
 		 * requeue this task to the end of the list on this priority
 		 * level, which is in essence a round-robin of tasks with
 		 * equal priority.
+		 *
+		 * This only applies to user tasks in the interactive
+		 * delta range with at least MIN_TIMESLICE left.
 		 */
-		if (p->mm && !((task_timeslice(p) - p->time_slice) %
-			TIMESLICE_GRANULARITY) && (p->time_slice > MIN_TIMESLICE) &&
+		if (p->mm && TASK_INTERACTIVE(p) && !((task_timeslice(p) -
+			p->time_slice) % TIMESLICE_GRANULARITY) &&
+			(p->time_slice > MIN_TIMESLICE) &&
 			(p->array == rq->active)) {
 
 			dequeue_task(p, rq->active);
 			set_tsk_need_resched(p);
+			/*
+			 * Tasks with interactive credit get all their
+			 * time waiting on the run queue credited as sleep
+			 */
+			if (HIGH_CREDIT(p))
+				p->activated = 2;
 			enqueue_task(p, rq->active);
 		}
 	}
@@ -1426,7 +1458,7 @@ need_resched:
 	 * as their sleep_avg decreases to slow them losing their
 	 * priority bonus
 	 */
-	if (prev->interactive_credit > 0)
+	if (HIGH_CREDIT(prev))
 		run_time /= (MAX_BONUS + 1 -
 			(NS_TO_JIFFIES(prev->sleep_avg) * MAX_BONUS /
 			MAX_SLEEP_AVG));
@@ -1484,12 +1516,12 @@ pick_next_task:
 		if (next->activated == 1)
 			delta = delta * (ON_RUNQUEUE_WEIGHT * 128 / 100) / 128;
 
-		next->activated = 0;
 		array = next->array;
 		dequeue_task(next, array);
 		recalc_task_prio(next, next->timestamp + delta);
 		enqueue_task(next, array);
 	}
+	next->activated = 0;
 switch_tasks:
 	prefetch(next);
 	clear_tsk_need_resched(prev);


^ permalink raw reply	[flat|nested] 33+ messages in thread
* Re: [PATCH]O14int
@ 2003-08-08 20:08 Voluspa
  2003-08-09  0:36 ` [PATCH]O14int Con Kolivas
  0 siblings, 1 reply; 33+ messages in thread
From: Voluspa @ 2003-08-08 20:08 UTC (permalink / raw)
  To: linux-kernel


On 2003-08-08 15:49:25 Con Kolivas wrote:

> More duck tape interactivity tweaks

Do you have a premonition... Game-test goes down in flames. Volatile to
the extent where I can't catch head or tail. It can behave like in
A3-O12.2 or as an unpatched 2.6.0-test2. Trigger badness by switching to
a text console. Sometimes it recovers, sometimes not. Sometimes fast,
sometimes slowly (when it does recover).

I'll withdraw under my rock now. Won't come forth until everything
smells of roses. Getting stressed by being a bringer of bad news only.
Please speak up, all you other testers. Divide the burden. Even out the
scores.

Greetings,
Mats Johannesson

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2003-08-17  2:19 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-08 15:49 [PATCH]O14int Con Kolivas
2003-08-08 17:57 ` [PATCH]O14int Timothy Miller
2003-08-09  0:44   ` [PATCH]O14int Con Kolivas
2003-08-08 19:31 ` [PATCH]O14int Felipe Alfaro Solana
2003-08-09  9:04 ` [PATCH]O14int Con Kolivas
2003-08-11  5:44   ` [PATCH]O14int Martin Schlemmer
2003-08-11  6:08     ` [PATCH]O14int Con Kolivas
2003-08-11  8:35       ` [PATCH]O14int Martin Schlemmer
2003-08-11  8:37         ` [PATCH]O14int Zwane Mwaikambo
2003-08-11  9:07           ` [PATCH]O14int Con Kolivas
2003-08-11  9:15       ` [PATCH]O14int Nick Piggin
2003-08-11  9:43         ` [PATCH]O14int Con Kolivas
2003-08-11  9:44           ` [PATCH]O14int Nick Piggin
2003-08-11 14:04             ` [PATCH]O14int Martin Schlemmer
2003-08-11 14:33               ` [PATCH]O14int Con Kolivas
2003-08-11 15:19                 ` [PATCH]O14int Martin Schlemmer
2003-08-13  6:48                   ` [PATCH]O14int Con Kolivas
2003-08-14  6:19                     ` [PATCH]O14int William Lee Irwin III
2003-08-15 23:40                       ` [PATCH]O14int Paul Dickson
2003-08-17  2:20                         ` [PATCH]O14int William Lee Irwin III
2003-08-11 16:31                 ` [PATCH]O14int Mike Galbraith
2003-08-11 23:54               ` [PATCH]O14int Timothy Miller
2003-08-11 13:58           ` [PATCH]O14int Martin Schlemmer
2003-08-11 17:55     ` [PATCH]O14int William Lee Irwin III
2003-08-08 20:08 [PATCH]O14int Voluspa
2003-08-09  0:36 ` [PATCH]O14int Con Kolivas
2003-08-10  8:48   ` [PATCH]O14int Simon Kirby
2003-08-10  9:06     ` [PATCH]O14int Con Kolivas
2003-08-12 17:56       ` [PATCH]O14int Simon Kirby
2003-08-12 21:21         ` [PATCH]O14int Con Kolivas
2003-08-10 10:08     ` [PATCH]O14int William Lee Irwin III
2003-08-12 18:36       ` [PATCH]O14int Simon Kirby
2003-08-10 11:17     ` [PATCH]O14int Mike Galbraith

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).