--- linux-2.6.3-ck1pre/kernel/sched.c 2004-02-16 16:35:59.438517683 +1100 +++ linux-2.6.3-ck1/kernel/sched.c 2004-02-16 16:50:40.548143342 +1100 @@ -1527,6 +1527,14 @@ void scheduler_tick(int user_ticks, int cpustat->iowait += sys_ticks; else cpustat->idle += sys_ticks; + /* + * Check if an SMT task has been put to sleep for + * priority reasons. + */ + if (rq->nr_running) { + resched_task(p); + goto out; + } rebalance_tick(rq, 1); return; } @@ -1685,6 +1693,20 @@ need_resched: if (!rq->nr_running) { next = rq->idle; rq->expired_timestamp = 0; +#ifdef CONFIG_SMP + if (SMT_ACTIVE) { + /* + * If an SMT sibling task is sleeping due to + * priority reasons wake it up now + */ + runqueue_t *smt_rq; + smt_rq = cpu_rq(cpu_sibling_map[(rq->cpu)]); + + if (smt_rq->curr == smt_rq->idle && + smt_rq->nr_running) + resched_task(smt_rq->idle); + } +#endif goto switch_tasks; } } @@ -1705,6 +1727,44 @@ need_resched: queue = array->queue + idx; next = list_entry(queue->next, task_t, run_list); +#ifdef CONFIG_SMP + if (SMT_ACTIVE) { + runqueue_t *smt_rq; + task_t *smt_curr; + + smt_rq = cpu_rq(cpu_sibling_map[(rq->cpu)]); + smt_curr = smt_rq->curr; + + /* + * If a user task with lower static priority than the + * running task on the SMT sibling is trying + * to schedule, delay it till there is proportionately less + * timeslice left of the sibling task to prevent a lower + * priority task from using an unfair proportion of the + * physical cpu's resources. + */ + if (next->mm && smt_curr->mm && !rt_task(next) && + ((next->static_prio > smt_curr->static_prio && + (smt_curr->time_slice * SMT_SIBLING_IMPACT / 100) > + task_timeslice(next)) || rt_task(smt_curr))) { + next = rq->idle; + goto switch_tasks; + } + + /* + * Reschedule a lower priority task + * on the SMT sibling, or wake it up if it has been + * put to sleep for priority reasons. + */ + if ((smt_curr != smt_rq->idle && + smt_curr->static_prio > next->static_prio) || + (rt_task(next) && !rt_task(smt_curr)) || + (smt_curr == smt_rq->idle && smt_rq->nr_running)) + resched_task(smt_curr); + + } +#endif + if (next->activated > 0) { unsigned long long delta = now - next->timestamp;