Messages in this thread Patch in this message | | | Date | Sun, 27 Jun 2004 22:04:01 +1000 | From | Con Kolivas <> | Subject | Re: [PATCH] Staircase scheduler v7.4 |
| |
Con Kolivas wrote: > Here is an incremental patch from 2.6.7-staircase7.4 (without any later > changes) to staircase7.6 which I hope addresses your problem of no > timeslice tasks. Can you try it please? Sorry about the previous noise. > > Con > > P.S. > Those with ck kernels I'm about to post another diff for -ck addressing > the same thing.
Eeek that one I posted _was_ the one for ck kernels. This is the one for vanilla kernels with staircase7.4. Crikey I'm having a blowout here.
Con Index: linux-2.6.7-staircase/kernel/sched.c =================================================================== --- linux-2.6.7-staircase.orig/kernel/sched.c 2004-06-25 02:24:34.000000000 +1000 +++ linux-2.6.7-staircase/kernel/sched.c 2004-06-27 21:49:48.912434799 +1000 @@ -218,8 +218,8 @@ static void enqueue_task(struct task_struct *p, runqueue_t *rq) { - if (rq->curr->flags & PF_PREEMPTED) { - rq->curr->flags &= ~PF_PREEMPTED; + if (p->flags & PF_PREEMPTED) { + p->flags &= ~PF_PREEMPTED; list_add(&p->run_list, rq->queue + p->prio); } else list_add_tail(&p->run_list, rq->queue + p->prio); @@ -255,7 +255,10 @@ rq->nr_running++; } -// burst - extra intervals an interactive task can run for at best priority +/* + * burst - extra intervals an interactive task can run for at best priority + * instead of descending priorities. + */ static unsigned int burst(task_t *p) { unsigned int task_user_prio; @@ -282,7 +285,10 @@ p->burst--; } -// slice - the duration a task runs before losing burst +/* + * slice - the duration a task runs before getting requeued at it's best + * priority and has it's burst decremented. + */ static unsigned int slice(task_t *p) { unsigned int slice = RR_INTERVAL; @@ -291,7 +297,9 @@ return slice; } -// interactive - interactive tasks get longer intervals at best priority +/* + * interactive - sysctl which allows interactive tasks to have bursts + */ int interactive = 1; /* @@ -326,20 +334,25 @@ return prio; } +/* + * recalc_task_prio - this checks for tasks that run ultra short timeslices + * or have just forked a thread/process and make them continue their old + * slice instead of starting a new one at high priority. + */ static void recalc_task_prio(task_t *p, unsigned long long now) { unsigned long sleep_time = now - p->timestamp; - unsigned long run_time = NS_TO_JIFFIES(p->runtime); - unsigned long total_run = NS_TO_JIFFIES(p->totalrun) + run_time; - if ((!run_time && NS_TO_JIFFIES(p->runtime + sleep_time) < - RR_INTERVAL) || p->flags & PF_FORKED) { + unsigned long ns_totalrun = p->totalrun + p->runtime; + unsigned long total_run = NS_TO_JIFFIES(ns_totalrun); + if (p->flags & PF_FORKED || (!(NS_TO_JIFFIES(p->runtime)) && + NS_TO_JIFFIES(p->runtime + sleep_time) < RR_INTERVAL)) { p->flags &= ~PF_FORKED; if (p->slice - total_run < 1) { p->totalrun = 0; dec_burst(p); } else { - p->totalrun += p->runtime; - p->slice -= NS_TO_JIFFIES(p->totalrun); + p->totalrun = ns_totalrun; + p->slice -= total_run; } } else { inc_burst(p); @@ -764,7 +777,9 @@ unsigned long flags; runqueue_t *rq = task_rq_lock(current, &flags); - //Forked process gets no burst to prevent fork bombs. + /* + * Forked process gets no burst to prevent fork bombs. + */ p->burst = 0; BUG_ON(p->state != TASK_RUNNING); @@ -1746,11 +1761,15 @@ cpustat->system += sys_ticks; spin_lock(&rq->lock); - // SCHED_FIFO tasks never run out of timeslice. + /* + * SCHED_FIFO tasks never run out of timeslice. + */ if (unlikely(p->policy == SCHED_FIFO)) goto out_unlock; rq->cache_ticks++; - // Tasks lose burst each time they use up a full slice(). + /* + * Tasks lose burst each time they use up a full slice(). + */ if (!--p->slice) { set_tsk_need_resched(p); dequeue_task(p, rq); @@ -3564,7 +3583,9 @@ for (j = 0; j <= MAX_PRIO; j++) INIT_LIST_HEAD(&rq->queue[j]); memset(rq->bitmap, 0, BITS_TO_LONGS(MAX_PRIO+1)*sizeof(long)); - // delimiter for bitsearch + /* + * delimiter for bitsearch + */ __set_bit(MAX_PRIO, rq->bitmap); } /*[unhandled content-type:application/pgp-signature] | |