2003-07-18 15:55:23

by Con Kolivas

[permalink] [raw]
Subject: [PATCH] O7int for interactivity

Here is an update to my Oint patches for 2.5/6 interactivity. Note I will be
away for a week so bash away and abuse this one lots and when I get back I can
see what else needs doing. Note I posted a preview earlier but this is the formal
O7 patch (check the datestamp which people hate in the naming of my patches).
I know this is turning into a marathon effort but... as you're all probably aware
there is nothing simple about tuning this beast. Thanks to all the testers and
people commenting; keep it coming please.

Changes in this patch:
The sleep buffer has been removed yet again. To smooth out X is just not
enough reason for this to be here as it can induce unfairness elsewhere, and
the actual size necessary for the sleep buffer to work nicely would depend on
the hardware.

Kernel threads are excluded from the idle detection code so they can become
max interactive regardless of how long they sleep. Should prevent some of
the bugs seen recently.

The requeuing has been rewritten. User threads will be requeued inversely
proportional to how cpu interactive they are. Prevents interactive tasks from
starving other interactive tasks during periods of cpu activity. This may have
been causing slowdowns in unlucky circumstances in O6

Con

patch-O7int-0307190129 is available here:
http://kernel.kolivas.org/2.5

and here:

--- linux-2.6.0-test1-mm1/kernel/sched.c 2003-07-17 19:59:16.000000000 +1000
+++ linux-2.6.0-testck1/kernel/sched.c 2003-07-19 01:56:41.000000000 +1000
@@ -76,7 +76,6 @@
#define MIN_SLEEP_AVG (HZ)
#define MAX_SLEEP_AVG (10*HZ)
#define STARVATION_LIMIT (10*HZ)
-#define SLEEP_BUFFER (HZ/100)
#define NODE_THRESHOLD 125
#define MAX_BONUS (MAX_USER_PRIO * PRIO_BONUS_RATIO / 100)

@@ -391,11 +390,11 @@ static inline void activate_task(task_t

if (sleep_time > 0) {
/*
- * Tasks that sleep a long time are categorised as idle and
+ * User tasks that sleep a long time are categorised as idle and
* will get just under interactive status with a small runtime
* to allow them to become interactive or non-interactive rapidly
*/
- if (sleep_time > MIN_SLEEP_AVG){
+ if (sleep_time > MIN_SLEEP_AVG && p->mm){
p->avg_start = jiffies - MIN_SLEEP_AVG;
p->sleep_avg = MIN_SLEEP_AVG * (MAX_BONUS - INTERACTIVE_DELTA - 2) /
MAX_BONUS;
@@ -421,13 +420,8 @@ static inline void activate_task(task_t
*/
p->sleep_avg = (p->sleep_avg * MAX_BONUS / runtime + 1) * runtime / MAX_BONUS;

- /*
- * Keep a small buffer of SLEEP_BUFFER sleep_avg to
- * prevent fully interactive tasks from becoming
- * lower priority with small bursts of cpu usage.
- */
- if (p->sleep_avg > (MAX_SLEEP_AVG + SLEEP_BUFFER))
- p->sleep_avg = MAX_SLEEP_AVG + SLEEP_BUFFER;
+ if (p->sleep_avg > MAX_SLEEP_AVG)
+ p->sleep_avg = MAX_SLEEP_AVG;
}

if (unlikely(p->avg_start > jiffies)){
@@ -1310,10 +1304,12 @@ void scheduler_tick(int user_ticks, int
enqueue_task(p, rq->expired);
} else
enqueue_task(p, rq->active);
- } else if (p->prio < effective_prio(p)){
+ } else if (p->mm && !((task_timeslice(p) - p->time_slice) %
+ (MIN_TIMESLICE * (MAX_BONUS + 1 - p->sleep_avg * MAX_BONUS / MAX_SLEEP_AVG)))){
/*
- * Tasks that have lowered their priority are put to the end
- * of the active array with their remaining timeslice
+ * Running user tasks get requeued with their remaining timeslice
+ * after a period proportional to how cpu intensive they are to
+ * minimise the duration one interactive task can starve another
*/
dequeue_task(p, rq->active);
set_tsk_need_resched(p);


2003-07-18 22:39:35

by Felipe Alfaro Solana

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Fri, 2003-07-18 at 18:10, Con Kolivas wrote:
> Here is an update to my Oint patches for 2.5/6 interactivity. Note I will be
> away for a week so bash away and abuse this one lots and when I get back I can
> see what else needs doing. Note I posted a preview earlier but this is the formal
> O7 patch (check the datestamp which people hate in the naming of my patches).
> I know this is turning into a marathon effort but... as you're all probably aware
> there is nothing simple about tuning this beast. Thanks to all the testers and
> people commenting; keep it coming please.

Feels pretty nice here... X still feels a little "heavy" and slow when
forcing Evolution to repaint its main window. Anyways, this seems to be
on the right track.

2003-07-18 22:52:12

by Mike Fedyk

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> Here is an update to my Oint patches for 2.5/6 interactivity. Note I will be
> away for a week so bash away and abuse this one lots and when I get back I can
> see what else needs doing. Note I posted a preview earlier but this is the formal
> O7 patch (check the datestamp which people hate in the naming of my patches).
> I know this is turning into a marathon effort but... as you're all probably aware
> there is nothing simple about tuning this beast. Thanks to all the testers and
> people commenting; keep it coming please.

Is this on top of 06 or 06.1?

2003-07-18 23:12:34

by Con Kolivas

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Sat, 19 Jul 2003 09:07, Mike Fedyk wrote:
> On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> > Here is an update to my Oint patches for 2.5/6 interactivity. Note I will
> Is this on top of 06 or 06.1?

On top of O6.1.

Con

2003-07-18 23:26:24

by Mike Fedyk

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Sat, Jul 19, 2003 at 09:30:37AM +1000, Con Kolivas wrote:
> On Sat, 19 Jul 2003 09:07, Mike Fedyk wrote:
> > On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> > > Here is an update to my Oint patches for 2.5/6 interactivity. Note I will
> > Is this on top of 06 or 06.1?
>
> On top of O6.1.
>

Thanks,

Compiling 07int now.

Oh, btw, I had a few starvation problems while testing 06int and mozilla.

I was able to get mozilla to livelock, and it's pri would stay at 15, and
badblocks run niced at 5 would get completely starved, no activity, or only
a few KB/s compared to the normal 40MB/s. I think that even happened when
it was at nice 0, but I'm not sure.

Anyway, I'll be trying the same workload on 07int.

Mike

2003-07-19 00:52:49

by William Lee Irwin III

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> Here is an update to my Oint patches for 2.5/6 interactivity. Note I
> will be away for a week so bash away and abuse this one lots and when
> I get back I can see what else needs doing. Note I posted a preview
> earlier but this is the formal O7 patch (check the datestamp which
> people hate in the naming of my patches). I know this is turning into
> a marathon effort but... as you're all probably aware there is
> nothing simple about tuning this beast. Thanks to all the testers and
> people commenting; keep it coming please.

I was able to trigger persistent starvation of openoffice by acroread
and temporary starvation of fvwm2 by it. AIUI this is a known issue but
I collected some detailed information on which whatever analysis you're
doing can be done.

Attached is a script(1)-generated log of top(1) during the incident.


-- wli


Attachments:
(No filename) (909.00 B)
top.log.2.gz (21.40 kB)
top.log.gz
Download all attachments

2003-07-19 03:25:10

by Eugene Teo

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

<quote sender="Felipe Alfaro Solana">
> On Fri, 2003-07-18 at 18:10, Con Kolivas wrote:
> > Here is an update to my Oint patches for 2.5/6 interactivity. Note I will be
> > away for a week so bash away and abuse this one lots and when I get back I can
> > see what else needs doing. Note I posted a preview earlier but this is the formal
> > O7 patch (check the datestamp which people hate in the naming of my patches).
> > I know this is turning into a marathon effort but... as you're all probably aware
> > there is nothing simple about tuning this beast. Thanks to all the testers and
> > people commenting; keep it coming please.
>
> Feels pretty nice here... X still feels a little "heavy" and slow when
> forcing Evolution to repaint its main window. Anyways, this seems to be
> on the right track.

I was telling Con that when I first trying the O7int patch, after
a series of activities (mutt, xmms, licq, firebird, blah, and blah),
i experienced high loads (2.00+, 3.00+ - that is pretty high for me
already, considering the reasonably high-end laptop i am using). xmms
seem to starved. doing top, i discovered that most, if not all the
X apps that i am running at the moment are in low priority, that is
18-25 at least. compiling kernel, listening to mp3s, typing something
seems difficult. i couldn't deduce what has really gone wrong. i have
not experience this before (O6.1int, and below).

Any idea?

Eugene

2003-07-19 03:26:24

by Eugene Teo

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

<quote sender="Mike Fedyk">
> On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> > Here is an update to my Oint patches for 2.5/6 interactivity. Note I will be
> > away for a week so bash away and abuse this one lots and when I get back I can
> > see what else needs doing. Note I posted a preview earlier but this is the formal
> > O7 patch (check the datestamp which people hate in the naming of my patches).
> > I know this is turning into a marathon effort but... as you're all probably aware
> > there is nothing simple about tuning this beast. Thanks to all the testers and
> > people commenting; keep it coming please.
>
> Is this on top of 06 or 06.1?

His patches are usually on top of the previous patch,
so if you applied O6int, apply O6.1int on it, then O7int on O6.1int.
But do read his readme file when you download it.

Eugene

2003-07-19 16:07:54

by Mike Fedyk

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Sat, Jul 19, 2003 at 11:40:59AM +0800, Eugene Teo wrote:
> <quote sender="Mike Fedyk">
> > On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> > > Here is an update to my Oint patches for 2.5/6 interactivity. Note I will be
> > > away for a week so bash away and abuse this one lots and when I get back I can
> > > see what else needs doing. Note I posted a preview earlier but this is the formal
> > > O7 patch (check the datestamp which people hate in the naming of my patches).
> > > I know this is turning into a marathon effort but... as you're all probably aware
> > > there is nothing simple about tuning this beast. Thanks to all the testers and
> > > people commenting; keep it coming please.
> >
> > Is this on top of 06 or 06.1?
>
> His patches are usually on top of the previous patch,
> so if you applied O6int, apply O6.1int on it, then O7int on O6.1int.
> But do read his readme file when you download it.

Yeah, I didn't even go to his web site. I've been taking his patches sent
through email, saving it to a file, and running that through patch... :-D

2003-07-21 17:08:59

by Mike Fedyk

[permalink] [raw]
Subject: Re: [PATCH] O7int for interactivity

On Sat, Jul 19, 2003 at 09:30:37AM +1000, Con Kolivas wrote:
> On Sat, 19 Jul 2003 09:07, Mike Fedyk wrote:
> > On Sat, Jul 19, 2003 at 02:10:49AM +1000, Con Kolivas wrote:
> > > Here is an update to my Oint patches for 2.5/6 interactivity. Note I will
> > Is this on top of 06 or 06.1?
>
> On top of O6.1.
>

Ok, after some testing I have a test case that hits a severe starvation case.

I have the courier-imap server running on my box, and when mozilla gets
messages with junk filtering turned on, it has to download each message to
scan it, almost all of the processing is in mozilla, and the mouse is smooth
as you'd see on windows, but I can't get anything else to run.

My kde taskbar won't switch desktops, though gkrellm keeps running smoothly
reporting 100% processor usage.

I'm not using sound on this machine ATM, so I have nothing to say about
XMMS...