--- linux-2.6.3-ck1pre/kernel/sched.c 2004-02-16 18:04:04.559290226 +1100 +++ linux-2.6.3-ck1/kernel/sched.c 2004-02-16 19:25:56.946625607 +1100 @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef CONFIG_NUMA #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu)) @@ -2155,6 +2156,26 @@ EXPORT_SYMBOL(sleep_on_timeout); void scheduling_functions_end_here(void) { } +/* + * Sets the initial io priority according to the policy and nice level. + */ +void set_sched_ioprio(task_t *p, long nice) +{ + int io_prio = (20 - nice) / 2; + + if (io_prio <= IOPRIO_IDLE) + io_prio = IOPRIO_IDLE + 1; + if (batch_task(p)) + io_prio = IOPRIO_IDLE; + if (iso_task(p)) + io_prio *= 2; + if (io_prio >= IOPRIO_RT) + io_prio = IOPRIO_RT - 1; + if (rt_task(p)) + io_prio = IOPRIO_RT; + p->ioprio = io_prio; +} + void set_user_nice(task_t *p, long nice) { unsigned long flags; @@ -2175,6 +2196,9 @@ void set_user_nice(task_t *p, long nice) * it wont have any effect on scheduling until the task is * not SCHED_NORMAL: */ + + set_sched_ioprio(p, nice); + if (rt_task(p)) { p->static_prio = NICE_TO_PRIO(nice); goto out_unlock; @@ -2395,8 +2419,8 @@ static int setscheduler(pid_t pid, int p p->sleep_avg = NS_MAX_SLEEP_AVG; p->interactive_credit = CREDIT_LIMIT + 1; } - out_unlock: + set_sched_ioprio(p, TASK_NICE(p)); task_rq_unlock(rq, &flags); out_unlock_tasklist: read_unlock_irq(&tasklist_lock);