--- linux-2.6.1-hto1/kernel/sched.c 2004-01-24 23:28:53.652590094 +1100 +++ linux-2.6.1-htb1/kernel/sched.c 2004-01-24 23:27:10.787471726 +1100 @@ -1612,7 +1612,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)]); @@ -1674,21 +1674,36 @@ need_resched: goto switch_tasks; } + if (unlikely(batch_task(next))) { /* - * Reschedule a lower priority task + * 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) - resched_task(htcurr); - else + 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) - resched_task(htcurr); + if (htcurr == htrq->idle && + htrq->nr_running > htrq->nr_batch) + resched_task(htcurr); + } } } #endif