* Reproducible terrible interactivity since 2.5.64bk2
@ 2003-03-26 11:51 Michal Schmidt
2003-03-26 14:08 ` Andrew Ebling
0 siblings, 1 reply; 10+ messages in thread
From: Michal Schmidt @ 2003-03-26 11:51 UTC (permalink / raw)
To: linux-kernel
(Please CC me your answers, thank you)
I'm seeing serious interactivity problems in 2.5.65, 2.5.66, 2.5.65-mm4
and 2.5.64-bk2.
I couldn't reproduce it on 2.5.64, 2.5.64-bk1.
I noticed that when I was archiving a directory with some CD ISO images
with tar & bzip2. After a while (~5 minutes) many programs took a long
time to respond, XMMS paused for several seconds, starting simple
programs (mc, ps, ls) took sometimes even 40s. Disk is idle most of the
time.
To reproduce I wrote a simple script:
#!/bin/sh
cat cedo.iso | bzip2 > /tmp/cedo.iso.bz2 &
for i in `seq 1 20`; do
sleep 30
date
ps x
date
echo -----
done
... where cedo.iso is a 700MB CD ISO image.
When run on 2.5.64-bk2 (and no X running) I've got this output:
Wed Mar 26 10:47:50 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 R 0:00 /bin/sh ./test-interactivity.sh
714 tty2 R 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 0:33 bzip2
720 tty2 R 0:00 ps x
Wed Mar 26 10:47:50 CET 2003
-----
Wed Mar 26 10:48:22 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 1:05 bzip2
724 tty2 R 0:00 ps x
Wed Mar 26 10:48:23 CET 2003
-----
Wed Mar 26 10:48:55 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 1:38 bzip2
728 tty2 R 0:00 ps x
Wed Mar 26 10:48:55 CET 2003
-----
Wed Mar 26 10:49:28 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 R 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 2:10 bzip2
732 tty2 R 0:00 ps x
Wed Mar 26 10:49:28 CET 2003
-----
Wed Mar 26 10:50:01 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 2:42 bzip2
736 tty2 R 0:00 ps x
Wed Mar 26 10:50:01 CET 2003
-----
Wed Mar 26 10:50:34 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 3:15 bzip2
740 tty2 R 0:00 ps x
Wed Mar 26 10:50:34 CET 2003
-----
Wed Mar 26 10:51:06 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 R 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 3:47 bzip2
744 tty2 R 0:00 ps x
Wed Mar 26 10:51:06 CET 2003
-----
Wed Mar 26 10:51:39 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:00 cat cedo.iso
716 tty2 R 4:19 bzip2
748 tty2 R 0:00 ps x
Wed Mar 26 10:51:39 CET 2003
-----
Wed Mar 26 10:52:12 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:01 cat cedo.iso
716 tty2 R 4:52 bzip2
752 tty2 R 0:00 ps x
Wed Mar 26 10:52:12 CET 2003
-----
Wed Mar 26 10:52:45 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 R 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:01 cat cedo.iso
716 tty2 R 5:24 bzip2
756 tty2 R 0:00 ps x
Wed Mar 26 10:52:45 CET 2003
-----
Wed Mar 26 10:53:17 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:01 cat cedo.iso
716 tty2 R 5:57 bzip2
760 tty2 R 0:00 ps x
Wed Mar 26 10:53:17 CET 2003
-----
Wed Mar 26 10:53:50 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:01 cat cedo.iso
716 tty2 R 6:29 bzip2
764 tty2 R 0:00 ps x
Wed Mar 26 10:53:50 CET 2003
-----
Wed Mar 26 10:54:23 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 R 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:01 cat cedo.iso
716 tty2 R 7:01 bzip2
768 tty2 R 0:00 ps x
Wed Mar 26 10:54:23 CET 2003
-----
Wed Mar 26 10:54:56 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 D 0:01 cat cedo.iso
716 tty2 S 7:41 bzip2
772 tty2 R 0:00 ps x
Wed Mar 26 10:55:03 CET 2003
-----
Wed Mar 26 10:55:45 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 D 0:01 cat cedo.iso
716 tty2 S 8:50 bzip2
776 tty2 R 0:00 ps x
Wed Mar 26 10:56:13 CET 2003
-----
Wed Mar 26 10:56:50 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 R 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 S 0:01 cat cedo.iso
716 tty2 R 9:27 bzip2
780 tty2 R 0:00 ps x
Wed Mar 26 10:56:50 CET 2003
-----
Wed Mar 26 10:57:23 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 D 0:02 cat cedo.iso
716 tty2 S 10:23 bzip2
784 tty2 R 0:00 ps x
Wed Mar 26 10:57:47 CET 2003
-----
Wed Mar 26 10:58:29 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 D 0:02 cat cedo.iso
716 tty2 S 11:09 bzip2
788 tty2 R 0:00 ps x
Wed Mar 26 10:58:33 CET 2003
-----
Wed Mar 26 10:59:19 CET 2003
PID TTY STAT TIME COMMAND
325 tty2 S 0:00 -bash
713 tty2 S 0:00 /bin/sh ./test-interactivity.sh
714 tty2 S 0:00 tee inter-2.5.64bk2.log
715 tty2 D 0:02 cat cedo.iso
716 tty2 S 11:59 bzip2
792 tty2 R 0:00 ps x
Wed Mar 26 10:59:24 CET 2003
-----
(I interrupted the script here)
You can see that after less then 8 minutes running date, ps, and date
again takes a very long time. When this happens, ps shows cat process in
D-state and bzip2 in S-state.
I use Debian Woody on UP Athlon 800MHz, Asus A7V, 384MB RAM, disk WDC
WD800JB-00CRA1 connected to on-board Promise 20265, nVidia Geforce2 MX,
Realtek RTL-8139C, SB Live.
GCC is 2.95.4.
Let me know if you want me to provide more information/testing.
Michal Schmidt.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-26 11:51 Reproducible terrible interactivity since 2.5.64bk2 Michal Schmidt
@ 2003-03-26 14:08 ` Andrew Ebling
2003-03-26 14:16 ` Michal Schmidt
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Andrew Ebling @ 2003-03-26 14:08 UTC (permalink / raw)
To: Michal Schmidt; +Cc: linux-kernel
On Wed, 2003-03-26 at 11:51, Michal Schmidt wrote:
> I'm seeing serious interactivity problems in 2.5.65, 2.5.66, 2.5.65-mm4
> and 2.5.64-bk2.
> I couldn't reproduce it on 2.5.64, 2.5.64-bk1.
I'm seeing similar on 2.5.66; xmms pauses when doing disk intensive
tasks.
> I use Debian Woody on UP Athlon 800MHz, Asus A7V, 384MB RAM, disk WDC
> WD800JB-00CRA1 connected to on-board Promise 20265, nVidia Geforce2 MX,
> Realtek RTL-8139C, SB Live.
> GCC is 2.95.4.
My system details: Gentoo Linux 1.2, PIII 1Ghz, 256MB RAM, Ati Rage128,
tulip nic, es1371 based sound card, gcc 2.95.3.
I'd be prepared to test any proposed fixes.
thanks,
Andy
The contents of this e-mail and any attachments are confidential and may
be legally privileged. If you have received this e-mail and you are not
a named addressee, please inform us as soon as possible on
+44 118 901 2999 and then delete the e-mail from your system. If you are
not a named addressee you must not copy, use, disclose, distribute,
print or rely on this e-mail. Any views expressed in this e-mail or any
attachments may not necessarily reflect those of Tao's management.
Although we routinely screen for viruses, addressees should scan this
e-mail and any attachments for viruses. Tao makes no representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that for the protection of our business, we may monitor and
read e-mails sent to and from our server(s).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-26 14:08 ` Andrew Ebling
@ 2003-03-26 14:16 ` Michal Schmidt
2003-03-26 14:40 ` Andrew Ebling
2003-03-28 17:50 ` Mike Galbraith
2003-03-26 18:25 ` Felipe Alfaro Solana
2003-03-26 18:41 ` Bill Davidsen
2 siblings, 2 replies; 10+ messages in thread
From: Michal Schmidt @ 2003-03-26 14:16 UTC (permalink / raw)
To: Andrew Ebling; +Cc: linux-kernel
Andrew Ebling wrote:
>
>
> I'm seeing similar on 2.5.66; xmms pauses when doing disk intensive
> tasks.
>
This may be a different problem. My test is not very disk intensive. It
is more CPU intensive (bzip2 compression). The disk is only slightly
used when running my testing script.
Michal Schmidt.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-26 14:16 ` Michal Schmidt
@ 2003-03-26 14:40 ` Andrew Ebling
2003-03-28 17:50 ` Mike Galbraith
1 sibling, 0 replies; 10+ messages in thread
From: Andrew Ebling @ 2003-03-26 14:40 UTC (permalink / raw)
To: Michal Schmidt; +Cc: linux-kernel
On Wed, 2003-03-26 at 14:16, Michal Schmidt wrote:
> Andrew Ebling wrote:
> > I'm seeing similar on 2.5.66; xmms pauses when doing disk intensive
> > tasks.
> This may be a different problem. My test is not very disk intensive. It
> is more CPU intensive (bzip2 compression). The disk is only slightly
> used when running my testing script.
I just experienced the problem very badly when tarring/bzipping hundreds
of MB of source files - almost certainly CPU bound on that occasion ;-).
I could do this on 2.4.2x with no problem.
btw. xmms is playing via ALSA, but other apps are also being starved of
CPU time - 30 second screen redraws :-/.
Andy
The contents of this e-mail and any attachments are confidential and may
be legally privileged. If you have received this e-mail and you are not
a named addressee, please inform us as soon as possible on
+44 118 901 2999 and then delete the e-mail from your system. If you are
not a named addressee you must not copy, use, disclose, distribute,
print or rely on this e-mail. Any views expressed in this e-mail or any
attachments may not necessarily reflect those of Tao's management.
Although we routinely screen for viruses, addressees should scan this
e-mail and any attachments for viruses. Tao makes no representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that for the protection of our business, we may monitor and
read e-mails sent to and from our server(s).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-26 14:08 ` Andrew Ebling
2003-03-26 14:16 ` Michal Schmidt
@ 2003-03-26 18:25 ` Felipe Alfaro Solana
2003-03-26 18:41 ` Bill Davidsen
2 siblings, 0 replies; 10+ messages in thread
From: Felipe Alfaro Solana @ 2003-03-26 18:25 UTC (permalink / raw)
To: Andrew Ebling; +Cc: Michal Schmidt, LKML
On Wed, 2003-03-26 at 15:08, Andrew Ebling wrote:
> I'm seeing similar on 2.5.66; xmms pauses when doing disk intensive
> tasks.
Just out of curiosity, do mpg123 (or mpg321) and ogg123 behave in the
same manner? I have found that XMMS is prone to skips, pauses and hangs,
but not so ogg123.
________________________________________________________________________
Felipe Alfaro Solana
Linux Registered User #287198
http://counter.li.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-26 14:08 ` Andrew Ebling
2003-03-26 14:16 ` Michal Schmidt
2003-03-26 18:25 ` Felipe Alfaro Solana
@ 2003-03-26 18:41 ` Bill Davidsen
2 siblings, 0 replies; 10+ messages in thread
From: Bill Davidsen @ 2003-03-26 18:41 UTC (permalink / raw)
To: Andrew Ebling; +Cc: Linux Kernel Mailing List
On 26 Mar 2003, Andrew Ebling wrote:
> On Wed, 2003-03-26 at 11:51, Michal Schmidt wrote:
>
> > I'm seeing serious interactivity problems in 2.5.65, 2.5.66, 2.5.65-mm4
> > and 2.5.64-bk2.
> > I couldn't reproduce it on 2.5.64, 2.5.64-bk1.
>
> I'm seeing similar on 2.5.66; xmms pauses when doing disk intensive
> tasks.
The only problem I see with X under 2.5.66 is that if you stop using it
long enough to have the screensaver kick in you can never unlock it. This
is in 2.5.6[56] and not in 2.5.59.
Having the screen locked certainly does hurt interactivity;-)
--
bill davidsen <davidsen@tmr.com>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-26 14:16 ` Michal Schmidt
2003-03-26 14:40 ` Andrew Ebling
@ 2003-03-28 17:50 ` Mike Galbraith
2003-03-28 19:54 ` Mike Galbraith
2003-03-30 22:51 ` Michal Schmidt
1 sibling, 2 replies; 10+ messages in thread
From: Mike Galbraith @ 2003-03-28 17:50 UTC (permalink / raw)
To: Michal Schmidt; +Cc: Andrew Ebling, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]
At 03:16 PM 3/26/2003 +0100, Michal Schmidt wrote:
>Andrew Ebling wrote:
>>
>>I'm seeing similar on 2.5.66; xmms pauses when doing disk intensive
>>tasks.
>
>This may be a different problem. My test is not very disk intensive. It is
>more CPU intensive (bzip2 compression). The disk is only slightly used
>when running my testing script.
Greetings potential victims :)
Care to see if the attached cures your woes?
This is a mixture of Ingo's last posted plus the scheduler tuning knobs
patch (/proc/sys/sched/*). I added three new knobs to watch the effect on
different loads. max_accel_slices limits the amount of sleep_time you may
add in one activation. retard_prct_slices is a percentage of a slice to
deduct from sleep_time each activation (negative feedback for heavy context
switchers.. dang irman process_load). force_switch is there because I'm
playing :) I didn't do much to the scheduler itself, only made it switch
arrays in something closer to a square wave. With the settings as in the
patch, and running a kernel build, top and irman, irman reports worst case
response times of 150ms for NULL load, 316ms for memory_load, 414 for
io_load, and 504ms for process_load.
Anyway, it's attached if you want to play with it ;-)
-Mike
Oh, it's against virgin 2.5.66.
[-- Attachment #2: twiddle.diff --]
[-- Type: application/octet-stream, Size: 11032 bytes --]
--- linux-2.5.66.virgin/kernel/sched.c Thu Mar 27 14:23:58 2003
+++ linux-2.5.66.twiddle/kernel/sched.c Fri Mar 28 18:35:29 2003
@@ -63,17 +63,40 @@
* Minimum timeslice is 10 msecs, default timeslice is 100 msecs,
* maximum timeslice is 200 msecs. Timeslices get refilled after
* they expire.
+ *
+ * They are configurable via /proc/sys/sched
*/
-#define MIN_TIMESLICE ( 10 * HZ / 1000)
-#define MAX_TIMESLICE (200 * HZ / 1000)
-#define CHILD_PENALTY 50
-#define PARENT_PENALTY 100
-#define EXIT_WEIGHT 3
-#define PRIO_BONUS_RATIO 25
-#define INTERACTIVE_DELTA 2
-#define MAX_SLEEP_AVG (10*HZ)
-#define STARVATION_LIMIT (10*HZ)
-#define NODE_THRESHOLD 125
+
+int min_timeslice = (5 * HZ) / 1000;
+int max_timeslice = (200 * HZ) / 1000;
+int child_penalty = 50;
+int parent_penalty = 100;
+int exit_weight = 3;
+int prio_bonus_ratio = 25;
+int interactive_delta = 2;
+int max_sleep_avg = 10 * HZ;
+int starvation_limit = 1 * HZ;
+int node_threshold = 125;
+int max_accel_slices = 5; /* Max bonus per activation in slices. */
+int retard_prct_slice = 10; /* Percent of a slice to deduct. */
+int force_switch = 1;
+
+#define MIN_TIMESLICE (min_timeslice)
+#define MAX_TIMESLICE (max_timeslice)
+#define CHILD_PENALTY (child_penalty)
+#define PARENT_PENALTY (parent_penalty)
+#define EXIT_WEIGHT (exit_weight)
+#define PRIO_BONUS_RATIO (prio_bonus_ratio)
+#define INTERACTIVE_DELTA (interactive_delta)
+#define MAX_SLEEP_AVG (max_sleep_avg)
+#define STARVATION_LIMIT (starvation_limit)
+#define NODE_THRESHOLD (node_threshold)
+#define TIMESLICE_GRANULARITY (HZ/20 ?: 1)
+#define MAX_ACCELERATION(slice) \
+ (max_accel_slices ? max_accel_slices * (slice) : max_sleep_avg)
+#define NEGATIVE_FEEDBACK(slice) \
+ (retard_prct_slice ? retard_prct_slice * (slice) / 100 : 0)
+#define FORCE_SWITCH (force_switch)
/*
* If a task is 'interactive' then we reinsert it in the active
@@ -124,12 +147,17 @@
* task_timeslice() is the interface that is used by the scheduler.
*/
-#define BASE_TIMESLICE(p) (MIN_TIMESLICE + \
- ((MAX_TIMESLICE - MIN_TIMESLICE) * (MAX_PRIO-1-(p)->static_prio)/(MAX_USER_PRIO - 1)))
+#define BASE_TIMESLICE(p) \
+ (MAX_TIMESLICE * (MAX_PRIO-(p)->static_prio)/MAX_USER_PRIO)
static inline unsigned int task_timeslice(task_t *p)
{
- return BASE_TIMESLICE(p);
+ unsigned int time_slice = BASE_TIMESLICE(p);
+
+ if (time_slice < MIN_TIMESLICE)
+ time_slice = MIN_TIMESLICE;
+
+ return time_slice;
}
/*
@@ -347,6 +375,7 @@
if (sleep_time > 0) {
int sleep_avg;
+ int slice = task_timeslice(p);
/*
* This code gives a bonus to interactive tasks.
@@ -355,8 +384,15 @@
* 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.
+ *
+ * Prevent tasks with an extremely high context switch
+ * rate from becoming CPU hogs by steadily inflating their
+ * sleep_avg until they starve legitimate sleepers.
*/
- sleep_avg = p->sleep_avg + sleep_time;
+ if (p->sleep_avg > MAX_SLEEP_AVG / 2)
+ p->sleep_avg -= NEGATIVE_FEEDBACK(slice);
+ sleep_time %= MAX_ACCELERATION(slice);
+ sleep_avg = sleep_time + p->sleep_avg;
/*
* 'Overflow' bonus ticks go to the waker as well, so the
@@ -1176,10 +1212,8 @@
* load-dependent, as the frequency of array switched decreases with
* increasing number of running tasks:
*/
-#define EXPIRED_STARVING(rq) \
- (STARVATION_LIMIT && ((rq)->expired_timestamp && \
- (jiffies - (rq)->expired_timestamp >= \
- STARVATION_LIMIT * ((rq)->nr_running) + 1)))
+#define EXPIRED_STARVING(rq) ((rq)->expired_timestamp && \
+ time_after_eq(jiffies, (rq)->expired_timestamp+STARVATION_LIMIT))
/*
* This function gets called by the timer code, with HZ frequency.
@@ -1193,6 +1227,10 @@
int cpu = smp_processor_id();
runqueue_t *rq = this_rq();
task_t *p = current;
+ int array_switch = EXPIRED_STARVING(rq);
+
+ if (FORCE_SWITCH && !rq->expired_timestamp)
+ rq->expired_timestamp = jiffies - (STARVATION_LIMIT / 2);
if (rcu_pending(cpu))
rcu_check_callbacks(cpu, user_ticks);
@@ -1242,23 +1280,52 @@
/* put it at the end of the queue: */
dequeue_task(p, rq->active);
- enqueue_task(p, rq->active);
+ enqueue_task(p, array_switch ? rq->expired : rq->active);
+ } else if (array_switch) {
+ if (!rq->expired_timestamp)
+ rq->expired_timestamp = jiffies;
+ dequeue_task(p, rq->active);
+ enqueue_task(p, rq->expired);
}
goto out;
}
- if (!--p->time_slice) {
+ if (unlikely(!--p->time_slice)) {
dequeue_task(p, rq->active);
set_tsk_need_resched(p);
p->prio = effective_prio(p);
p->time_slice = task_timeslice(p);
p->first_time_slice = 0;
- if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
+ if (!TASK_INTERACTIVE(p) || array_switch) {
if (!rq->expired_timestamp)
rq->expired_timestamp = jiffies;
enqueue_task(p, rq->expired);
} else
enqueue_task(p, rq->active);
+ goto out;
+ }
+ /*
+ * Prevent a too long timeslice allowing a task to monopolize
+ * the CPU. We do this by splitting up the timeslice into
+ * smaller pieces.
+ *
+ * Note: this does not mean the task's timeslices expire or
+ * get lost in any way, they just might be preempted by
+ * another task of equal priority. (one with higher
+ * priority would have preempted this task already.) We
+ * 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.
+ *
+ * If expired tasks are starving, switch arrays ASAP.
+ */
+ if (!(p->time_slice % TIMESLICE_GRANULARITY) || array_switch) {
+ dequeue_task(p, rq->active);
+ set_tsk_need_resched(p);
+ p->prio = effective_prio(p);
+ enqueue_task(p, array_switch ? rq->expired : rq->active);
+ if (array_switch && !rq->expired_timestamp)
+ rq->expired_timestamp = jiffies;
}
out:
spin_unlock(&rq->lock);
@@ -1297,8 +1364,13 @@
rq = this_rq();
release_kernel_lock(prev);
+#if 0 // MIKEDIDIT
prev->last_run = jiffies;
+#endif
spin_lock_irq(&rq->lock);
+#if 1 // MIKEDIDIT
+ prev->last_run = jiffies;
+#endif
/*
* if entering off of a kernel preemption go straight
@@ -1680,7 +1752,7 @@
*/
int task_prio(task_t *p)
{
- return p->prio - MAX_USER_RT_PRIO;
+ return p->prio - MAX_RT_PRIO;
}
/**
--- linux-2.5.66.virgin/kernel/sysctl.c Thu Mar 27 14:23:58 2003
+++ linux-2.5.66.twiddle/kernel/sysctl.c Fri Mar 28 13:51:31 2003
@@ -57,6 +57,19 @@
extern int cad_pid;
extern int pid_max;
extern int sysctl_lower_zone_protection;
+extern int min_timeslice;
+extern int max_timeslice;
+extern int child_penalty;
+extern int parent_penalty;
+extern int exit_weight;
+extern int prio_bonus_ratio;
+extern int interactive_delta;
+extern int max_sleep_avg;
+extern int starvation_limit;
+extern int node_threshold;
+extern int max_accel_slices;
+extern int retard_prct_slice;
+extern int force_switch;
/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
static int maxolduid = 65535;
@@ -114,6 +127,7 @@
static ctl_table kern_table[];
static ctl_table vm_table[];
+static ctl_table sched_table[];
#ifdef CONFIG_NET
extern ctl_table net_table[];
#endif
@@ -158,6 +172,7 @@
{CTL_FS, "fs", NULL, 0, 0555, fs_table},
{CTL_DEBUG, "debug", NULL, 0, 0555, debug_table},
{CTL_DEV, "dev", NULL, 0, 0555, dev_table},
+ {CTL_SCHED, "sched", NULL, 0, 0555, sched_table},
{0}
};
@@ -360,7 +375,50 @@
static ctl_table dev_table[] = {
{0}
-};
+};
+
+static ctl_table sched_table[] = {
+ {SCHED_MAX_TIMESLICE, "max_timeslice", &max_timeslice,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &one, NULL},
+ {SCHED_MIN_TIMESLICE, "min_timeslice", &min_timeslice,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &one, NULL},
+ {SCHED_CHILD_PENALTY, "child_penalty", &child_penalty,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_PARENT_PENALTY, "parent_penalty", &parent_penalty,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_EXIT_WEIGHT, "exit_weight", &exit_weight,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_PRIO_BONUS_RATIO, "prio_bonus_ratio", &prio_bonus_ratio,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_INTERACTIVE_DELTA, "interactive_delta", &interactive_delta,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_MAX_SLEEP_AVG, "max_sleep_avg", &max_sleep_avg,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &one, NULL},
+ {SCHED_STARVATION_LIMIT, "starvation_limit", &starvation_limit,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_NODE_THRESHOLD, "node_threshold", &node_threshold,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &one, NULL},
+ {SCHED_MAX_ACCELERATION, "max_accel_slices", &max_accel_slices,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, NULL},
+ {SCHED_NEG_FEEDBACK, "retard_prct_slice", &retard_prct_slice,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, &one_hundred},
+ {SCHED_FORCE_SWITCH, "force_switch", &force_switch,
+ sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+ &sysctl_intvec, NULL, &zero, &one},
+ {0}
+};
extern void init_irq_proc (void);
--- linux-2.5.66.virgin/include/linux/sysctl.h Fri Mar 7 06:07:40 2003
+++ linux-2.5.66.twiddle/include/linux/sysctl.h Fri Mar 28 13:53:47 2003
@@ -66,7 +66,8 @@
CTL_DEV=7, /* Devices */
CTL_BUS=8, /* Busses */
CTL_ABI=9, /* Binary emulation */
- CTL_CPU=10 /* CPU stuff (speed scaling, etc) */
+ CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
+ CTL_SCHED=11, /* scheduler tunables */
};
/* CTL_BUS names: */
@@ -157,6 +158,22 @@
VM_LOWER_ZONE_PROTECTION=20,/* Amount of protection of lower zones */
};
+/* Tunable scheduler parameters in /proc/sys/sched/ */
+enum {
+ SCHED_MIN_TIMESLICE=1, /* minimum process timeslice */
+ SCHED_MAX_TIMESLICE=2, /* maximum process timeslice */
+ SCHED_CHILD_PENALTY=3, /* penalty on fork to child */
+ SCHED_PARENT_PENALTY=4, /* penalty on fork to parent */
+ SCHED_EXIT_WEIGHT=5, /* penalty to parent of CPU hog child */
+ SCHED_PRIO_BONUS_RATIO=6, /* percent of max prio given as bonus */
+ SCHED_INTERACTIVE_DELTA=7, /* delta used to scale interactivity */
+ SCHED_MAX_SLEEP_AVG=8, /* maximum sleep avg attainable */
+ SCHED_STARVATION_LIMIT=9, /* no re-active if expired is starved */
+ SCHED_NODE_THRESHOLD=10, /* NUMA node rebalance threshold */
+ SCHED_MAX_ACCELERATION=11, /* maximum bonus slices per activation */
+ SCHED_NEG_FEEDBACK=12, /* percent slice onus per activation */
+ SCHED_FORCE_SWITCH=13, /* force switch to expired array */
+};
/* CTL_NET names: */
enum
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-28 17:50 ` Mike Galbraith
@ 2003-03-28 19:54 ` Mike Galbraith
2003-03-30 22:51 ` Michal Schmidt
1 sibling, 0 replies; 10+ messages in thread
From: Mike Galbraith @ 2003-03-28 19:54 UTC (permalink / raw)
To: linux-kernel
At 06:50 PM 3/28/2003 +0100, Mike Galbraith wrote:
>Anyway, it's attached if you want to play with it ;-)
P.S. it's been beaten hard on my little UP (+preempt, but) box. It is
interesting to watch, and I haven't been able to piss it off yet.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-28 17:50 ` Mike Galbraith
2003-03-28 19:54 ` Mike Galbraith
@ 2003-03-30 22:51 ` Michal Schmidt
2003-03-31 2:26 ` Mike Galbraith
1 sibling, 1 reply; 10+ messages in thread
From: Michal Schmidt @ 2003-03-30 22:51 UTC (permalink / raw)
To: Mike Galbraith; +Cc: linux-kernel
Mike Galbraith wrote:
>
> Greetings potential victims :)
>
> Care to see if the attached cures your woes?
>
> This is a mixture of Ingo's last posted plus the scheduler tuning knobs
> patch (/proc/sys/sched/*). I added three new knobs to watch the effect
> on different loads. max_accel_slices limits the amount of sleep_time
> you may add in one activation. retard_prct_slices is a percentage of a
> slice to deduct from sleep_time each activation (negative feedback for
> heavy context switchers.. dang irman process_load). force_switch is
> there because I'm playing :) I didn't do much to the scheduler itself,
> only made it switch arrays in something closer to a square wave. With
> the settings as in the patch, and running a kernel build, top and irman,
> irman reports worst case response times of 150ms for NULL load, 316ms
> for memory_load, 414 for io_load, and 504ms for process_load.
>
> Anyway, it's attached if you want to play with it ;-)
>
> -Mike
>
> Oh, it's against virgin 2.5.66.
Thanks, running 2.5.66 with the patch applied I could no more reproduce
the problem. I haven't tried playing with the knobs.
Michal
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Reproducible terrible interactivity since 2.5.64bk2
2003-03-30 22:51 ` Michal Schmidt
@ 2003-03-31 2:26 ` Mike Galbraith
0 siblings, 0 replies; 10+ messages in thread
From: Mike Galbraith @ 2003-03-31 2:26 UTC (permalink / raw)
To: Michal Schmidt; +Cc: linux-kernel
At 12:51 AM 3/31/2003 +0200, Michal Schmidt wrote:
>Mike Galbraith wrote:
>>Greetings potential victims :)
>>Care to see if the attached cures your woes?
>>This is a mixture of Ingo's last posted plus the scheduler tuning knobs
>>patch (/proc/sys/sched/*). I added three new knobs to watch the effect
>>on different loads. max_accel_slices limits the amount of sleep_time you
>>may add in one activation. retard_prct_slices is a percentage of a slice
>>to deduct from sleep_time each activation (negative feedback for heavy
>>context switchers.. dang irman process_load). force_switch is there
>>because I'm playing :) I didn't do much to the scheduler itself, only
>>made it switch arrays in something closer to a square wave. With the
>>settings as in the patch, and running a kernel build, top and irman,
>>irman reports worst case response times of 150ms for NULL load, 316ms for
>>memory_load, 414 for io_load, and 504ms for process_load.
>>Anyway, it's attached if you want to play with it ;-)
>> -Mike
>>Oh, it's against virgin 2.5.66.
>
>
>Thanks, running 2.5.66 with the patch applied I could no more reproduce
>the problem. I haven't tried playing with the knobs.
Thanks for the info.
-Mike
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-03-31 2:11 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-26 11:51 Reproducible terrible interactivity since 2.5.64bk2 Michal Schmidt
2003-03-26 14:08 ` Andrew Ebling
2003-03-26 14:16 ` Michal Schmidt
2003-03-26 14:40 ` Andrew Ebling
2003-03-28 17:50 ` Mike Galbraith
2003-03-28 19:54 ` Mike Galbraith
2003-03-30 22:51 ` Michal Schmidt
2003-03-31 2:26 ` Mike Galbraith
2003-03-26 18:25 ` Felipe Alfaro Solana
2003-03-26 18:41 ` Bill Davidsen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.