--- linux-2.6.2/kernel/sched.c 2004-02-04 17:11:55.637964232 +1100 +++ linux-2.6.2-ck1/kernel/sched.c 2004-02-04 17:23:28.585620176 +1100 @@ -1726,7 +1726,7 @@ need_resched: if (ht_active) { /* * If a HT sibling task is sleeping due to - * priority reasons wake it up now + * priority or batch reasons wake it up now */ runqueue_t *htrq; htrq = cpu_rq(cpu_sibling_map[(rq->cpu)]); @@ -1782,7 +1782,7 @@ need_resched: * cpu's resources. */ if (next->mm && htcurr->mm && !rt_task(next) && - ((next->static_prio > + !batch_task(htcurr) && ((next->static_prio > htcurr->static_prio && htcurr->time_slice > task_timeslice(next)) || rt_task(htcurr))) { next = rq->idle; @@ -1790,14 +1790,29 @@ need_resched: } /* - * Reschedule a lower priority task + * 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 && htcurr->mm)) { + 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)) + (htcurr == htrq->idle && htrq->nr_running) || + (batch_task(htcurr) && next->mm && !batch_task(next))) resched_task(htcurr); }