--- linux-2.6.1-iso1/kernel/sched.c 2004-02-02 14:43:17.000000000 +1100 +++ linux-2.6.1-htnice2/kernel/sched.c 2004-02-02 19:01:25.631442311 +1100 @@ -1675,58 +1675,54 @@ need_resched: next = list_entry(queue->next, task_t, run_list); #ifdef CONFIG_SMP - if (ht_active && next->mm && !rt_task(next)) { + if (ht_active) { runqueue_t *htrq; htrq = cpu_rq(cpu_sibling_map[(rq->cpu)]); task_t *htcurr; htcurr = htrq->curr; - if (likely(htcurr->mm && !rt_task(htcurr))){ - /* - * If a user task with >10 dynamic + - * static priority difference from another - * running user task on the hyperthread sibling - * is trying to schedule, delay it to prevent a - * lower priority task from using an unfair - * proportion of the physical cpu resources. - */ - if (next->prio + next->static_prio > - htcurr->prio + htcurr->static_prio + 10) { - next = rq->idle; - goto switch_tasks; - } - - if (unlikely(batch_task(next))) { - /* - * Prevent a batch task from running if a user - * non batch task is running on a HT sibling. - */ - if (htrq->nr_running > htrq->nr_batch) { - dequeue_task(next, array); - enqueue_task(next, rq->batch); - next = rq->idle; - goto switch_tasks; - } - } else { - /* - * Reschedule a lower priority or batch task - * on the HT sibling if present. - */ - if (htcurr->prio + htcurr->static_prio > - next->prio + next->static_prio + 10 || - batch_task(htcurr)) - resched_task(htcurr); - else - /* - * If a HT sibling task has been put to sleep - * previously for priority reasons wake it up - * now. - */ - if (htcurr == htrq->idle && - htrq->nr_running > htrq->nr_batch) - resched_task(htcurr); - } + /* + * If a user task with lower static priority than the + * running task on the hyperthread sibling is trying + * to schedule, delay it till there is equal timeslice + * left of the hyperthread task to prevent a lower priority + * task from using an unfair proportion of the physical + * cpu's resources. + */ + if (next->mm && htcurr->mm && !rt_task(next) && + !batch_task(htcurr) && ((next->static_prio > + htcurr->static_prio && htcurr->time_slice > + task_timeslice(next)) || rt_task(htcurr))) { + next = rq->idle; + goto switch_tasks; } + + /* + * Prevent a batch task from running if a user + * non batch task is running on a HT sibling. + */ + if (unlikely(batch_task(next) && htrq->nr_running > + htrq->nr_batch)) { + dequeue_task(next, array); + enqueue_task(next, rq->batch); + next = rq->idle; + if (htcurr == htrq->idle) + resched_task(htcurr); + goto switch_tasks; + } + + /* + * Reschedule a lower priority or batch task + * on the HT sibling, or wake it up if it has been + * put to sleep for priority reasons. + */ + if ((htcurr != htrq->idle && + htcurr->static_prio > next->static_prio) || + (rt_task(next) && !rt_task(htcurr)) || + (htcurr == htrq->idle && htrq->nr_running) || + (!batch_task(next) && batch_task(htcurr))) + resched_task(htcurr); + } #endif