Skip to content

Commit

Permalink
cfq-iosched: make io priorities inherit CPU scheduling class as well …
Browse files Browse the repository at this point in the history
…as nice

We currently set all processes to the best-effort scheduling class,
regardless of what CPU scheduling class they belong to. Improve that
so that we correctly track idle and rt scheduling classes as well.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Jens Axboe committed May 7, 2008
1 parent dbaf2c0 commit 6d63c27
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,10 +1303,10 @@ static void cfq_init_prio_data(struct cfq_queue *cfqq, struct io_context *ioc)
printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class);
case IOPRIO_CLASS_NONE:
/*
* no prio set, place us in the middle of the BE classes
* no prio set, inherit CPU scheduling settings
*/
cfqq->ioprio = task_nice_ioprio(tsk);
cfqq->ioprio_class = IOPRIO_CLASS_BE;
cfqq->ioprio_class = task_nice_ioclass(tsk);
break;
case IOPRIO_CLASS_RT:
cfqq->ioprio = task_ioprio(ioc);
Expand Down
14 changes: 14 additions & 0 deletions include/linux/ioprio.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ static inline int task_nice_ioprio(struct task_struct *task)
return (task_nice(task) + 20) / 5;
}

/*
* This is for the case where the task hasn't asked for a specific IO class.
* Check for idle and rt task process, and return appropriate IO class.
*/
static inline int task_nice_ioclass(struct task_struct *task)
{
if (task->policy == SCHED_IDLE)
return IOPRIO_CLASS_IDLE;
else if (task->policy == SCHED_FIFO || task->policy == SCHED_RR)
return IOPRIO_CLASS_RT;
else
return IOPRIO_CLASS_BE;
}

/*
* For inheritance, return the highest of the two given priorities
*/
Expand Down

0 comments on commit 6d63c27

Please sign in to comment.