linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] O13int for interactivity
@ 2003-08-04 16:07 Con Kolivas
  2003-08-04 18:24 ` Felipe Alfaro Solana
                   ` (3 more replies)
  0 siblings, 4 replies; 84+ messages in thread
From: Con Kolivas @ 2003-08-04 16:07 UTC (permalink / raw)
  To: linux kernel mailing list
  Cc: Andrew Morton, Ingo Molnar, Felipe Alfaro Solana

Changes:

Reverted the child penalty to 95 as new changes help this from hurting

Changed the logic behind loss of interactive credits to those that burn off 
all their sleep_avg

Now all tasks get proportionately more sleep as their relative bonus drops 
off. This has the effect of detecting a change from a cpu burner to an 
interactive task more rapidly as in O10. 

The _major_ change in this patch is that tasks on uninterruptible sleep do not 
earn any sleep avg during that sleep; it is not voluntary sleep so they should 
not get it. This has the effect of stopping cpu hogs from gaining dynamic 
priority during periods of heavy I/O. Very good for the jerks you may 
see in X or audio skips when you start a whole swag of disk intensive cpu hogs 
(eg make -j large number). I've simply dropped all their sleep_avg, but 
weighting it may be more appropriate. This has the side effect that pure
disk tasks (eg cp) have relatively low priority which is why weighting may
be better. We shall see.

Please test this one extensively. It should _not_ affect I/O throughput per 
se, but I'd like to see some of the I/O benchmarks on this. I do not want to 
have detrimental effects elsewhere.

patch-O12.3-O13int applies on top of 2.6.0-test2-mm4 that has been 
patched with O12.3int and is available on my site, and a full patch
against 2.6.0-test2 called patch-test2-O13int is here:

http://kernel.kolivas.org/2.5

patch-O12.3-O13int:

--- linux-2.6.0-test2-mm4-O12.3/kernel/sched.c	2003-08-05 01:30:27.000000000 +1000
+++ linux-2.6.0-test2-mm4-O13/kernel/sched.c	2003-08-05 01:36:20.000000000 +1000
@@ -78,7 +78,7 @@
 #define MAX_TIMESLICE		(200 * HZ / 1000)
 #define TIMESLICE_GRANULARITY	(HZ/40 ?: 1)
 #define ON_RUNQUEUE_WEIGHT	30
-#define CHILD_PENALTY		90
+#define CHILD_PENALTY		95
 #define PARENT_PENALTY		100
 #define EXIT_WEIGHT		3
 #define PRIO_BONUS_RATIO	25
@@ -365,6 +365,9 @@ static void recalc_task_prio(task_t *p, 
 	unsigned long long __sleep_time = now - p->timestamp;
 	unsigned long sleep_time;
 
+	if (!p->sleep_avg)
+		p->interactive_credit--;
+
 	if (__sleep_time > NS_MAX_SLEEP_AVG)
 		sleep_time = NS_MAX_SLEEP_AVG;
 	else
@@ -384,17 +387,19 @@ static void recalc_task_prio(task_t *p, 
 					JIFFIES_TO_NS(JUST_INTERACTIVE_SLEEP(p));
 		else {
 			/*
-			 * Tasks with interactive credits get boosted more
-			 * rapidly if their bonus has dropped off. Other
-			 * tasks are limited to one timeslice worth of
-			 * sleep avg.
+			 * 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.
 			 */
-			if (p->interactive_credit > 0)
-				sleep_time *= (MAX_BONUS + 1 -
+			sleep_time *= (MAX_BONUS + 1 -
 					(NS_TO_JIFFIES(p->sleep_avg) *
 					MAX_BONUS / MAX_SLEEP_AVG));
-			else if (sleep_time > JIFFIES_TO_NS(task_timeslice(p)))
-				sleep_time = JIFFIES_TO_NS(task_timeslice(p));
+
+			if (p->interactive_credit < 0 &&
+				sleep_time > JIFFIES_TO_NS(task_timeslice(p)))
+					sleep_time =
+						JIFFIES_TO_NS(task_timeslice(p));
 
 			/*
 			 * This code gives a bonus to interactive tasks.
@@ -435,20 +440,26 @@ static inline void activate_task(task_t 
 	recalc_task_prio(p, now);
 
 	/*
-	 * Tasks which were woken up by interrupts (ie. hw events)
-	 * are most likely of interactive nature. So we give them
-	 * the credit of extending their sleep time to the period
-	 * of time they spend on the runqueue, waiting for execution
-	 * on a CPU, first time around:
+	 * This checks to make sure it's not an uninterruptible task
+	 * that is now waking up.
 	 */
-	if (in_interrupt())
-		p->activated = 2;
-	else
-	/*
-	 * Normal first-time wakeups get a credit too for on-runqueue time,
-	 * but it will be weighted down:
-	 */
-		p->activated = 1;
+	if (!p->activated){
+		/*
+		 * Tasks which were woken up by interrupts (ie. hw events)
+		 * are most likely of interactive nature. So we give them
+		 * the credit of extending their sleep time to the period
+		 * of time they spend on the runqueue, waiting for execution
+		 * on a CPU, first time around:
+		 */
+		if (in_interrupt())
+			p->activated = 2;
+		else
+		/*
+		 * Normal first-time wakeups get a credit too for on-runqueue
+		 * time, but it will be weighted down:
+		 */
+			p->activated = 1;
+	}
 
 	p->timestamp = now;
 
@@ -572,8 +583,15 @@ repeat_lock_task:
 				task_rq_unlock(rq, &flags);
 				goto repeat_lock_task;
 			}
-			if (old_state == TASK_UNINTERRUPTIBLE)
+			if (old_state == TASK_UNINTERRUPTIBLE){
+				/*
+				 * Tasks on involuntary sleep don't earn
+				 * sleep_avg
+				 */
 				rq->nr_uninterruptible--;
+				p->timestamp = sched_clock();
+				p->activated = -1;
+			}
 			if (sync)
 				__activate_task(p, rq);
 			else {
@@ -1326,7 +1344,6 @@ void scheduler_tick(int user_ticks, int 
 		p->prio = effective_prio(p);
 		p->time_slice = task_timeslice(p);
 		p->first_time_slice = 0;
-		p->interactive_credit--;
 
 		if (!rq->expired_timestamp)
 			rq->expired_timestamp = jiffies;
@@ -1459,7 +1476,7 @@ pick_next_task:
 	queue = array->queue + idx;
 	next = list_entry(queue->next, task_t, run_list);
 
-	if (next->activated && next->interactive_credit > 0) {
+	if (next->activated > 0) {
 		unsigned long long delta = now - next->timestamp;
 
 		if (next->activated == 1)


^ permalink raw reply	[flat|nested] 84+ messages in thread
* Re: Interactivity improvements
@ 2003-08-07 14:26 Patrick McLean
  2003-08-07 15:24 ` Richard Curnow
                   ` (2 more replies)
  0 siblings, 3 replies; 84+ messages in thread
From: Patrick McLean @ 2003-08-07 14:26 UTC (permalink / raw)
  To: linux-kernel

I have a few ideas about the interactivity problem that I thought i 
would share.

First, the whole problem with interactive tasks turning into CPU hogs, 
and vice-versa. The current implementation is fairly good at estimating 
the interactivity of a new process isn't it? I assume it keeps some sort 
of statitistice on what a process has been doing in the past, so if a 
process starts to deviate from it's previous behavior quite a bit (say 
an interactive task starts finishing time slices, or a CPU hog starts 
sleeping a lot) couldn't we reset the priority, etc and let the 
interactivity estimator re-estimate the interactivity as if it was a new 
task. That way no task would get a real chance to starve others, while 
keeping interactive tasks interactive (interactive tasks that become CPU 
hogs for short peroids of time would have a pretty good chance to 
smarten up before they really get penalized).

Another point is compilers, they tend to do a lot of disk I/O then 
become major CPU hogs, could we have some sort or heuristic that reduces 
the bonuses for sleeping on block I/O rather than other kinds of I/O 
(say pipes and network I/O in the case of X). This would prevent tasks 
like compilers from getting real bonuses for reading alot of files at 
startup.

Finally, the interactivity estimator seems to be quite a bit of code, 
which certain people have no real useful (in servers for example) and I 
would imagine that it does reduce throughput, which is not a big deal in 
desktops, but in a server environment it's not good, so maybe a 
CONFIG_INTERACTIVE_ESTIMATOR or something similar would be an idea to 
keep the server people happy, just have an option to completely get rid 
of the extra overhead of having a really nice interactivity estimator. I 
could be an idiot though, and I imagine that I will be needing some 
asbestos for saying this, but I thought I would voice my opinion.


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

end of thread, other threads:[~2003-08-14 10:49 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-04 16:07 [PATCH] O13int for interactivity Con Kolivas
2003-08-04 18:24 ` Felipe Alfaro Solana
2003-08-04 19:15 ` Antonio Vargas
2003-08-04 21:32   ` Con Kolivas
2003-08-04 20:11 ` Mike Galbraith
2003-08-04 22:11   ` Con Kolivas
2003-08-05  7:10     ` Mike Galbraith
2003-08-05  2:11 ` Nick Piggin
2003-08-05  2:20   ` Con Kolivas
2003-08-05  2:21     ` Nick Piggin
2003-08-05  3:06       ` Con Kolivas
2003-08-05  3:17         ` Nick Piggin
2003-08-06 18:48           ` Interactivity improvements Timothy Miller
2003-08-06 19:01             ` Mike Fedyk
2003-08-06 20:09             ` Helge Hafting
2003-08-06 21:15             ` Con Kolivas
2003-08-05  3:18       ` [PATCH] O13int for interactivity Con Kolivas
2003-08-05  3:31         ` Nick Piggin
2003-08-05  5:04           ` Con Kolivas
2003-08-05  5:12             ` Nick Piggin
2003-08-05  5:16               ` Con Kolivas
2003-08-05  5:28                 ` Nick Piggin
2003-08-05 10:22                   ` Con Kolivas
2003-08-05 10:32                     ` Nick Piggin
2003-08-05 10:45                       ` Con Kolivas
2003-08-05 10:48                         ` Nick Piggin
2003-08-05 10:56                           ` Con Kolivas
2003-08-05 11:03                             ` Nick Piggin
2003-08-05 11:12                               ` Con Kolivas
2003-08-05 11:23                                 ` Nick Piggin
2003-08-05 11:34                                   ` Con Kolivas
2003-08-05 10:54                         ` Arjan van de Ven
2003-08-05 11:10                           ` Con Kolivas
2003-08-06 21:33                       ` Timothy Miller
2003-08-06 21:33                         ` Con Kolivas
2003-08-07  0:27                           ` Timothy Miller
2003-08-07  0:27                             ` Con Kolivas
2003-08-07  0:44                               ` Timothy Miller
2003-08-11  6:48                       ` Rob Landley
2003-08-11 15:47                         ` William Lee Irwin III
2003-08-12  2:51                         ` Nick Piggin
2003-08-12  6:16                           ` Mike Galbraith
2003-08-12  7:07                             ` Nick Piggin
2003-08-12  7:18                               ` Nick Piggin
2003-08-12  9:42                                 ` Mike Galbraith
2003-08-12 21:11                                   ` Mike Fedyk
2003-08-13  6:55                                     ` Mike Galbraith
2003-08-12  9:22                               ` Mike Galbraith
2003-08-12  9:37                                 ` Nick Piggin
2003-08-12  9:48                                   ` Mike Galbraith
2003-08-12 10:29                           ` Rob Landley
2003-08-12 11:08                             ` Nick Piggin
2003-08-12 11:35                               ` Rob Landley
2003-08-12 11:58                                 ` Nick Piggin
2003-08-13  2:08                                   ` jw schultz
2003-08-13  3:07                                     ` Gene Heskett
2003-08-13  3:24                                       ` Nick Piggin
2003-08-13  5:24                                         ` Gene Heskett
2003-08-13  5:43                                           ` Andrew McGregor
2003-08-13 12:33                                             ` Gene Heskett
2003-08-14  5:03                                               ` Andrew McGregor
2003-08-14 10:48                                                 ` Gene Heskett
2003-08-12 15:36                           ` Timothy Miller
2003-08-05  6:03             ` Andrew Morton
2003-08-05  7:26               ` Con Kolivas
2003-08-05  8:12                 ` Oliver Neukum
2003-08-05  8:20                   ` Con Kolivas
2003-08-05  8:27                     ` Mike Galbraith
2003-08-05  8:43                       ` Con Kolivas
2003-08-05  9:09                         ` Mike Galbraith
2003-08-05  9:19                           ` Con Kolivas
2003-08-05 10:04                   ` Nick Piggin
2003-08-11  6:57                 ` Rob Landley
2003-08-11 15:58                   ` William Lee Irwin III
2003-08-05  7:53               ` Mike Galbraith
2003-08-07 14:26 Interactivity improvements Patrick McLean
2003-08-07 15:24 ` Richard Curnow
2003-08-07 15:42   ` Patrick McLean
2003-08-07 18:33     ` Mike Fedyk
2003-08-07 20:48   ` William Lee Irwin III
2003-08-07 21:26     ` Bernd Eckenfels
2003-08-07 23:05       ` Timothy Miller
2003-08-07 15:31 ` Felipe Alfaro Solana
2003-08-07 17:41 ` Robert Love

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