Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c553f8e3 authored by Shaohua Li's avatar Shaohua Li Committed by Jens Axboe
Browse files

block cfq: compensate preempted queue even if it has no slice assigned



If a queue is preempted before it gets slice assigned, the queue doesn't get
compensation, which looks unfair. For such queue, we compensate it for a whole
slice.

Signed-off-by: default avatarShaohua Li <shaohua.li@intel.com>
Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
parent f8ae6e3e
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -598,8 +598,8 @@ cfq_group_slice(struct cfq_data *cfqd, struct cfq_group *cfqg)
	return cfq_target_latency * cfqg->weight / st->total_weight;
	return cfq_target_latency * cfqg->weight / st->total_weight;
}
}


static inline void
static inline unsigned
cfq_set_prio_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
cfq_scaled_group_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
{
{
	unsigned slice = cfq_prio_to_slice(cfqd, cfqq);
	unsigned slice = cfq_prio_to_slice(cfqd, cfqq);
	if (cfqd->cfq_latency) {
	if (cfqd->cfq_latency) {
@@ -625,6 +625,14 @@ cfq_set_prio_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
				    low_slice);
				    low_slice);
		}
		}
	}
	}
	return slice;
}

static inline void
cfq_set_prio_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
{
	unsigned slice = cfq_scaled_group_slice(cfqd, cfqq);

	cfqq->slice_start = jiffies;
	cfqq->slice_start = jiffies;
	cfqq->slice_end = jiffies + slice;
	cfqq->slice_end = jiffies + slice;
	cfqq->allocated_slice = slice;
	cfqq->allocated_slice = slice;
@@ -1661,7 +1669,10 @@ __cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq,
	/*
	/*
	 * store what was left of this slice, if the queue idled/timed out
	 * store what was left of this slice, if the queue idled/timed out
	 */
	 */
	if (timed_out && !cfq_cfqq_slice_new(cfqq)) {
	if (timed_out) {
		if (cfq_cfqq_slice_new(cfqq))
			cfqq->slice_resid = cfq_scaled_group_slice(cfqd, cfqq);
		else
			cfqq->slice_resid = cfqq->slice_end - jiffies;
			cfqq->slice_resid = cfqq->slice_end - jiffies;
		cfq_log_cfqq(cfqd, cfqq, "resid=%ld", cfqq->slice_resid);
		cfq_log_cfqq(cfqd, cfqq, "resid=%ld", cfqq->slice_resid);
	}
	}