--- linux-2.6.1-cfqionice/kernel/sched.c 2004-02-02 19:01:25.000000000 +1100 +++ linux-2.6.1-schedioprio/kernel/sched.c 2004-02-02 22:32:18.089450444 +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)) @@ -2010,6 +2011,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; @@ -2030,6 +2051,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; @@ -2250,8 +2274,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);