Skip to content

Commit

Permalink
block cfq: make queue preempt work for queues from different workload
Browse files Browse the repository at this point in the history
I got this:
             fio-874   [007]  2157.724514:   8,32   m   N cfq874 preempt
             fio-874   [007]  2157.724519:   8,32   m   N cfq830 slice expired t=1
             fio-874   [007]  2157.724520:   8,32   m   N cfq830 sl_used=1 disp=0 charge=1 iops=0 sect=0
             fio-874   [007]  2157.724521:   8,32   m   N cfq830 set_active wl_prio:0 wl_type:0
             fio-874   [007]  2157.724522:   8,32   m   N cfq830 Not idling. st->count:1

cfq830 is an async queue, and preempted by a sync queue cfq874. But since we
have cfqg->saved_workload_slice mechanism, the preempt is a nop.
Looks currently our preempt is totally broken if the two queues are not from
the same workload type.
Below patch fixes it. This will might make async queue starvation, but it's
what our old code does before cgroup is added.

Signed-off-by: Shaohua Li <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Shaohua Li authored and Jens Axboe committed Jan 14, 2011
1 parent 52cfd50 commit f8ae6e3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions block/cfq-iosched.c
Original file line number Diff line number Diff line change
Expand Up @@ -3284,9 +3284,18 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
*/
static void cfq_preempt_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq)
{
struct cfq_queue *old_cfqq = cfqd->active_queue;

cfq_log_cfqq(cfqd, cfqq, "preempt");
cfq_slice_expired(cfqd, 1);

/*
* workload type is changed, don't save slice, otherwise preempt
* doesn't happen
*/
if (cfqq_type(old_cfqq) != cfqq_type(cfqq))
cfqq->cfqg->saved_workload_slice = 0;

/*
* Put the new queue at the front of the of the current list,
* so we know that it will be selected next.
Expand Down

0 comments on commit f8ae6e3

Please sign in to comment.