public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfq-iosched: queue groups more gracefully
@ 2011-06-23 16:22 Konstantin Khlebnikov
  2011-06-23 17:51 ` Vivek Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Khlebnikov @ 2011-06-23 16:22 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel, Vivek Goyal

This patch queue awakened cfq-groups according its current vdisktime,
it try to save upto one group timeslice from unused virtual disk time.
Thus group does not loses everything, if it was not continuously backlogged.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 block/cfq-iosched.c |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index c71533e..d5c7c79 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -592,6 +592,26 @@ cfq_group_slice(struct cfq_data *cfqd, struct cfq_group *cfqg)
 	return cfq_target_latency * cfqg->weight / st->total_weight;
 }
 
+static inline u64
+cfq_group_vslice(struct cfq_data *cfqd, struct cfq_group *cfqg)
+{
+	struct cfq_rb_root *st = &cfqd->grp_service_tree;
+	u64 vslice;
+
+	/* There no group slices in iops mode */
+	if (iops_mode(cfqd))
+		return 0;
+
+	/*
+	 * Equal to cfq_scale_slice(cfq_group_slice(cfqd, cfqg), cfqg).
+	 * Add group weight beacuse it currently not in service tree.
+	 */
+	vslice = (u64)cfq_target_latency << CFQ_SERVICE_SHIFT;
+	vslice *= BLKIO_WEIGHT_DEFAULT;
+	do_div(vslice, st->total_weight + cfqg->weight);
+	return vslice;
+}
+
 static inline unsigned
 cfq_scaled_cfqq_slice(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 {
@@ -884,16 +904,20 @@ cfq_group_notify_queue_add(struct cfq_data *cfqd, struct cfq_group *cfqg)
 		return;
 
 	/*
-	 * Currently put the group at the end. Later implement something
-	 * so that groups get lesser vtime based on their weights, so that
-	 * if group does not loose all if it was not continuously backlogged.
+	 * Bump vdisktime to be greater or equal min_vdisktime.
+	 */
+	cfqg->vdisktime = max_vdisktime(cfqg->vdisktime, st->min_vdisktime);
+
+	/*
+	 * Put the group at the end, but save one slice from unused time.
 	 */
 	n = rb_last(&st->rb);
 	if (n) {
 		__cfqg = rb_entry_cfqg(n);
-		cfqg->vdisktime = __cfqg->vdisktime + CFQ_IDLE_DELAY;
-	} else
-		cfqg->vdisktime = st->min_vdisktime;
+		cfqg->vdisktime = max_vdisktime(cfqg->vdisktime,
+				__cfqg->vdisktime -
+					cfq_group_vslice(cfqd, cfqg));
+	}
 	cfq_group_service_tree_add(st, cfqg);
 }
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-24 11:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-23 16:22 [PATCH] cfq-iosched: queue groups more gracefully Konstantin Khlebnikov
2011-06-23 17:51 ` Vivek Goyal
2011-06-24 11:13   ` Konstantin Khlebnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox