--- linux-2.6.4/kernel/sched.c 2004-03-11 22:31:40.165410505 +1100 +++ linux-2.6.4-ck1/kernel/sched.c 2004-03-11 22:37:27.557271710 +1100 @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef CONFIG_NUMA #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu)) @@ -2477,6 +2478,28 @@ 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) +{ +#ifdef CONFIG_IOSCHED_CFQ + 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; +#endif +} + void set_user_nice(task_t *p, long nice) { unsigned long flags; @@ -2497,6 +2520,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; @@ -2723,8 +2749,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);