--- linux-2.6.1/kernel/sched.c 2004-01-27 16:34:48.582447120 +1100 +++ linux-2.6.1-ck1/kernel/sched.c 2004-01-27 16:35:02.671305288 +1100 @@ -1561,6 +1561,20 @@ need_resched: if (!rq->nr_running) { next = rq->idle; rq->expired_timestamp = 0; +#ifdef CONFIG_SMP + if (ht_active) { + /* + * If a HT sibling task is sleeping due to + * priority reasons wake it up now + */ + runqueue_t *htrq; + htrq = cpu_rq(cpu_sibling_map[(rq->cpu)]); + + if (htrq->curr == htrq->idle && + htrq->nr_running) + resched_task(htrq->idle); + } +#endif goto switch_tasks; } } @@ -1581,6 +1595,47 @@ need_resched: queue = array->queue + idx; next = list_entry(queue->next, task_t, run_list); +#ifdef CONFIG_SMP + if (ht_active && next->mm && !rt_task(next)) { + 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; + } + + /* + * Reschedule a lower priority task + * on the HT sibling if present. + */ + if (htcurr->prio + htcurr->static_prio > + next->prio + next->static_prio + 10) + 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) + resched_task(htcurr); + } + } +#endif + if (next->activated > 0) { unsigned long long delta = now - next->timestamp;