From: Vivek Goyal <vgoyal@redhat.com>
To: linux-kernel@vger.kernel.org, jens.axboe@oracle.com
Cc: nauman@google.com, dpshah@google.com, lizf@cn.fujitsu.com,
ryov@valinux.co.jp, fernando@oss.ntt.co.jp,
s-uchida@ap.jp.nec.com, taka@valinux.co.jp,
guijianfeng@cn.fujitsu.com, jmoyer@redhat.com,
balbir@linux.vnet.ibm.com, righi.andrea@gmail.com,
m-ikeda@ds.jp.nec.com, vgoyal@redhat.com,
akpm@linux-foundation.org, riel@redhat.com,
kamezawa.hiroyu@jp.fujitsu.com
Subject: [PATCH 07/20] blkio: Provide capablity to enqueue/dequeue group entities
Date: Tue, 3 Nov 2009 18:43:44 -0500 [thread overview]
Message-ID: <1257291837-6246-8-git-send-email-vgoyal@redhat.com> (raw)
In-Reply-To: <1257291837-6246-1-git-send-email-vgoyal@redhat.com>
o This patch embeds cfq_entity object in cfq_group and provides helper routines
so that group entities can be scheduled.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
block/cfq-iosched.c | 110 +++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 93 insertions(+), 17 deletions(-)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index bc99163..8ec8a82 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -79,6 +79,7 @@ struct cfq_service_tree {
#define CFQ_RB_ROOT (struct cfq_service_tree) { RB_ROOT, NULL, 0, NULL}
struct cfq_sched_data {
+ unsigned int nr_active;
struct cfq_service_tree service_tree[IO_IOPRIO_CLASSES];
};
@@ -89,6 +90,10 @@ struct cfq_entity {
struct cfq_service_tree *st;
unsigned short ioprio_class;
bool ioprio_class_changed;
+ struct cfq_entity *parent;
+ bool on_st;
+ /* Points to the sched_data of group entity. Null for cfqq */
+ struct cfq_sched_data *my_sd;
};
/*
@@ -136,6 +141,7 @@ struct cfq_queue {
/* Per cgroup grouping structure */
struct cfq_group {
+ struct cfq_entity entity;
struct cfq_sched_data sched_data;
#ifdef CONFIG_CFQ_GROUP_IOSCHED
struct blkio_group blkg;
@@ -260,9 +266,23 @@ static struct cfq_io_context *cfq_cic_lookup(struct cfq_data *,
static void cfq_put_queue(struct cfq_queue *cfqq);
static struct cfq_entity *__cfq_get_next_entity(struct cfq_service_tree *st);
+static inline struct cfq_entity *parent_entity(struct cfq_entity *cfqe)
+{
+ return cfqe->parent;
+}
+
static inline struct cfq_queue *cfqq_of(struct cfq_entity *cfqe)
{
- return container_of(cfqe, struct cfq_queue, entity);
+ if (!cfqe->my_sd)
+ return container_of(cfqe, struct cfq_queue, entity);
+ return NULL;
+}
+
+static inline struct cfq_group *cfqg_of(struct cfq_entity *cfqe)
+{
+ if (cfqe->my_sd)
+ return container_of(cfqe, struct cfq_group, entity);
+ return NULL;
}
static inline void
@@ -352,6 +372,33 @@ cfq_weight_slice(struct cfq_data *cfqd, int sync, unsigned int weight)
return cfq_delta(base_slice, weight, BLKIO_WEIGHT_DEFAULT);
}
+#ifdef CONFIG_CFQ_GROUP_IOSCHED
+/* check for entity->parent so that loop is not executed for root entity. */
+#define for_each_entity(entity) \
+ for (; entity && entity->parent; entity = entity->parent)
+
+static inline struct cfq_sched_data *
+cfq_entity_sched_data(struct cfq_entity *cfqe)
+{
+ return &cfqg_of(parent_entity(cfqe))->sched_data;
+}
+#else /* CONFIG_CFQ_GROUP_IOSCHED */
+#define for_each_entity(entity) \
+ for (; entity != NULL; entity = NULL)
+static inline struct cfq_data *cfqd_of(struct cfq_entity *cfqe)
+{
+ return cfqq_of(cfqe)->cfqd;
+}
+
+static inline struct cfq_sched_data *
+cfq_entity_sched_data(struct cfq_entity *cfqe)
+{
+ struct cfq_data *cfqd = cfqd_of(cfqe);
+
+ return &cfqd->root_group.sched_data;
+}
+#endif /* CONFIG_CFQ_GROUP_IOSCHED */
+
static inline int rq_in_driver(struct cfq_data *cfqd)
{
return cfqd->rq_in_driver[0] + cfqd->rq_in_driver[1];
@@ -606,16 +653,28 @@ static void __dequeue_cfqe(struct cfq_service_tree *st, struct cfq_entity *cfqe)
static void dequeue_cfqe(struct cfq_entity *cfqe)
{
struct cfq_service_tree *st = cfqe->st;
+ struct cfq_sched_data *sd = cfq_entity_sched_data(cfqe);
if (st->active == cfqe)
st->active = NULL;
__dequeue_cfqe(st, cfqe);
+ sd->nr_active--;
+ cfqe->on_st = 0;
}
static void dequeue_cfqq(struct cfq_queue *cfqq)
{
- dequeue_cfqe(&cfqq->entity);
+ struct cfq_entity *cfqe = &cfqq->entity;
+
+ for_each_entity(cfqe) {
+ struct cfq_sched_data *sd = cfq_entity_sched_data(cfqe);
+
+ dequeue_cfqe(cfqe);
+ /* Do not dequeue parent if it has other entities under it */
+ if (sd->nr_active)
+ break;
+ }
}
static void __enqueue_cfqe(struct cfq_service_tree *st, struct cfq_entity *cfqe,
@@ -653,6 +712,10 @@ static void __enqueue_cfqe(struct cfq_service_tree *st, struct cfq_entity *cfqe,
static void enqueue_cfqe(struct cfq_entity *cfqe)
{
+ struct cfq_sched_data *sd = cfq_entity_sched_data(cfqe);
+
+ cfqe->on_st = 1;
+ sd->nr_active++;
cfqe_update_ioprio_class(cfqe);
place_cfqe(cfqe->st, cfqe, 0);
__enqueue_cfqe(cfqe->st, cfqe, 0);
@@ -660,7 +723,13 @@ static void enqueue_cfqe(struct cfq_entity *cfqe)
static void enqueue_cfqq(struct cfq_queue *cfqq)
{
- enqueue_cfqe(&cfqq->entity);
+ struct cfq_entity *cfqe = &cfqq->entity;
+
+ for_each_entity(cfqe) {
+ if (cfqe->on_st)
+ break;
+ enqueue_cfqe(cfqe);
+ }
}
/* Requeue a cfqq which is already on the service tree */
@@ -687,14 +756,22 @@ static void requeue_cfqq(struct cfq_queue *cfqq, int add_front)
static void cfqe_served(struct cfq_entity *cfqe, unsigned long served)
{
- /*
- * Can't update entity disk time while it is on sorted rb-tree
- * as vdisktime is used as key.
- */
- __dequeue_cfqe(cfqe->st, cfqe);
- cfqe->vdisktime += cfq_delta_fair(served, cfqe);
- update_min_vdisktime(cfqe->st);
- __enqueue_cfqe(cfqe->st, cfqe, 0);
+ for_each_entity(cfqe) {
+ /*
+ * Can't update entity disk time while it is on sorted rb-tree
+ * as vdisktime is used as key.
+ */
+ __dequeue_cfqe(cfqe->st, cfqe);
+ cfqe->vdisktime += cfq_delta_fair(served, cfqe);
+ update_min_vdisktime(cfqe->st);
+ __enqueue_cfqe(cfqe->st, cfqe, 0);
+
+ /* If entity prio class has changed, take that into account */
+ if (unlikely(cfqe->ioprio_class_changed)) {
+ dequeue_cfqe(cfqe);
+ enqueue_cfqe(cfqe);
+ }
+ }
}
static void cfqq_served(struct cfq_queue *cfqq, unsigned long served)
@@ -708,12 +785,6 @@ static void cfqq_served(struct cfq_queue *cfqq, unsigned long served)
*/
served = cfq_prio_to_slice(cfqq->cfqd, cfqq);
cfqe_served(&cfqq->entity, served);
-
- /* If cfqq prio class has changed, take that into account */
- if (unlikely(cfqq->entity.ioprio_class_changed)) {
- dequeue_cfqq(cfqq);
- enqueue_cfqq(cfqq);
- }
}
/*
@@ -1941,6 +2012,8 @@ static void cfq_init_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq,
cfq_mark_cfqq_sync(cfqq);
}
cfqq->pid = pid;
+ cfqq->entity.parent = &cfqd->root_group.entity;
+ cfqq->entity.my_sd = NULL;
}
static struct cfq_queue *
@@ -2707,6 +2780,9 @@ static void cfq_init_root_group(struct cfq_data *cfqd)
struct cfq_group *cfqg = &cfqd->root_group;
int i;
+ cfqg->entity.parent = NULL;
+ cfqg->entity.my_sd = &cfqg->sched_data;
+
for (i = 0; i < IO_IOPRIO_CLASSES; i++)
cfqg->sched_data.service_tree[i] = CFQ_RB_ROOT;
}
--
1.6.2.5
next prev parent reply other threads:[~2009-11-03 23:46 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 23:43 [RFC] Block IO Controller V1 Vivek Goyal
2009-11-03 23:43 ` [PATCH 01/20] blkio: Documentation Vivek Goyal
2009-11-04 13:37 ` Jeff Moyer
2009-11-04 17:21 ` Balbir Singh
2009-11-04 17:52 ` Vivek Goyal
2009-11-04 23:36 ` Balbir Singh
2009-11-03 23:43 ` [PATCH 02/20] blkio: Change CFQ to use CFS like queue time stamps Vivek Goyal
2009-11-04 14:30 ` Jeff Moyer
2009-11-04 16:37 ` Vivek Goyal
2009-11-04 17:59 ` Corrado Zoccolo
2009-11-04 18:54 ` Vivek Goyal
2009-11-05 2:44 ` Divyesh Shah
2009-11-05 14:39 ` Vivek Goyal
2009-11-04 21:18 ` Corrado Zoccolo
2009-11-04 22:25 ` Vivek Goyal
2009-11-05 8:36 ` Corrado Zoccolo
2009-11-04 23:22 ` Vivek Goyal
2009-11-05 8:27 ` Corrado Zoccolo
2009-11-05 0:05 ` Vivek Goyal
2009-11-06 22:22 ` [RFC] Workload type Vs Groups (Was: Re: [PATCH 02/20] blkio: Change CFQ to use CFS like queue time stamps) Vivek Goyal
2009-11-09 17:33 ` Nauman Rafique
2009-11-09 21:47 ` Corrado Zoccolo
2009-11-09 23:12 ` Vivek Goyal
2009-11-10 11:29 ` Corrado Zoccolo
2009-11-10 13:31 ` Vivek Goyal
2009-11-10 14:12 ` Vivek Goyal
2009-11-10 18:05 ` Corrado Zoccolo
2009-11-10 19:15 ` Vivek Goyal
2009-11-12 8:53 ` Corrado Zoccolo
2009-11-11 0:48 ` [PATCH 02/20] blkio: Change CFQ to use CFS like queue time stamps Gui Jianfeng
2009-11-12 23:07 ` Vivek Goyal
2009-11-13 0:59 ` Gui Jianfeng
2009-11-13 1:24 ` Vivek Goyal
2009-11-13 2:05 ` Gui Jianfeng
2009-11-03 23:43 ` [PATCH 03/20] blkio: Introduce the notion of weights Vivek Goyal
2009-11-04 15:06 ` Jeff Moyer
2009-11-04 15:41 ` Vivek Goyal
2009-11-04 17:07 ` Divyesh Shah
2009-11-04 19:00 ` Vivek Goyal
2009-11-04 19:15 ` Jeff Moyer
2009-11-03 23:43 ` [PATCH 04/20] blkio: Introduce the notion of cfq entity Vivek Goyal
2009-11-03 23:43 ` [PATCH 05/20] blkio: Introduce the notion of cfq groups Vivek Goyal
2009-11-03 23:43 ` [PATCH 06/20] blkio: Introduce cgroup interface Vivek Goyal
2009-11-04 15:23 ` Jeff Moyer
2009-11-04 16:47 ` Vivek Goyal
2009-11-03 23:43 ` Vivek Goyal [this message]
2009-11-04 15:34 ` [PATCH 07/20] blkio: Provide capablity to enqueue/dequeue group entities Jeff Moyer
2009-11-04 16:54 ` Vivek Goyal
2009-11-03 23:43 ` [PATCH 08/20] blkio: Add support for dynamic creation of cfq_groups Vivek Goyal
2009-11-04 16:01 ` Jeff Moyer
2009-11-03 23:43 ` [PATCH 09/20] blkio: Porpogate blkio cgroup weight or ioprio class updation to cfq groups Vivek Goyal
2009-11-05 5:35 ` Gui Jianfeng
2009-11-05 14:42 ` Vivek Goyal
2009-11-03 23:43 ` [PATCH 10/20] blkio: Implement cfq group deletion and reference counting support Vivek Goyal
2009-11-04 18:44 ` Jeff Moyer
2009-11-04 19:00 ` Vivek Goyal
2009-11-03 23:43 ` [PATCH 11/20] blkio: Some CFQ debugging Aid Vivek Goyal
2009-11-04 18:52 ` Jeff Moyer
2009-11-04 19:12 ` Vivek Goyal
2009-11-04 19:25 ` Jeff Moyer
2009-11-05 3:10 ` Divyesh Shah
2009-11-05 14:42 ` Vivek Goyal
2009-11-06 0:56 ` Divyesh Shah
2009-11-03 23:43 ` [PATCH 12/20] blkio: Export disk time and sectors dispatched from cgroup interface Vivek Goyal
2009-11-03 23:43 ` [PATCH 13/20] blkio: Add a group dequeue interface in cgroup for debugging Vivek Goyal
2009-11-03 23:43 ` [PATCH 14/20] blkio: Do not allow request merging across cfq groups Vivek Goyal
2009-11-03 23:43 ` [PATCH 15/20] blkio: Take care of preemptions across groups Vivek Goyal
2009-11-04 19:00 ` Jeff Moyer
2009-11-04 19:27 ` Vivek Goyal
2009-11-04 19:30 ` Jeff Moyer
2009-11-06 7:55 ` Gui Jianfeng
2009-11-06 22:10 ` Vivek Goyal
2009-11-09 7:41 ` Gui Jianfeng
2009-11-03 23:43 ` [PATCH 16/20] blkio: do not select co-operating queues from different cfq groups Vivek Goyal
2009-11-03 23:43 ` [PATCH 17/20] blkio: Wait for queue to get backlogged before it expires Vivek Goyal
2009-11-03 23:43 ` [PATCH 18/20] blkio: arm idle timer even if think time is great then time slice left Vivek Goyal
2009-11-04 19:04 ` Jeff Moyer
2009-11-04 19:17 ` Vivek Goyal
2009-11-03 23:43 ` [PATCH 19/20] blkio: Arm slice timer even if there are requests in driver Vivek Goyal
2009-11-03 23:43 ` [PATCH 20/20] blkio: Drop the reference to queue once the task changes cgroup Vivek Goyal
2009-11-04 19:09 ` Jeff Moyer
2009-11-04 19:18 ` Vivek Goyal
2009-11-04 7:43 ` [RFC] Block IO Controller V1 Jens Axboe
2009-11-04 13:39 ` Vivek Goyal
2009-11-04 19:12 ` Jeff Moyer
2009-11-04 19:19 ` Vivek Goyal
2009-11-04 19:27 ` Jeff Moyer
2009-11-04 19:38 ` Vivek Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1257291837-6246-8-git-send-email-vgoyal@redhat.com \
--to=vgoyal@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=dpshah@google.com \
--cc=fernando@oss.ntt.co.jp \
--cc=guijianfeng@cn.fujitsu.com \
--cc=jens.axboe@oracle.com \
--cc=jmoyer@redhat.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=m-ikeda@ds.jp.nec.com \
--cc=nauman@google.com \
--cc=riel@redhat.com \
--cc=righi.andrea@gmail.com \
--cc=ryov@valinux.co.jp \
--cc=s-uchida@ap.jp.nec.com \
--cc=taka@valinux.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome