Re: [PATCH 11/24] cfq-iosched: add leaf_weight
Hello, Vivek. On Tue, Jan 08, 2013 at 10:34:48AM -0500, Vivek Goyal wrote: > How does it help to map leaf weight to weight in root group. Old programs > anyway don't know about leaf_weight. So nobody is going to update it. And > if they update it, they better know what does it do. Because what cfq does before this patchset in flat hierarchy is basically treating root weight as the leaf weight. R:500 / \ A:250 B:750 Ratio of R is computed as 500 / (500 + 250 + 750). The root blkcg's tasks are competinig with the children blkcgs. This is currently the only supported config and we don't want to break existing users, so keeping root's weight and leaf_weight synchronized and ignoring root's weight, which BTW can't mean anything anyway as it doesn't have a parent or siblings, keeps the behavior unchanged for flat configs. Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 11/24] cfq-iosched: add leaf_weight
On Fri, Dec 28, 2012 at 12:35:33PM -0800, Tejun Heo wrote: [..] > + > + /* on root, leaf_weight is mapped to weight */ > + { > + .name = "leaf_weight_device", > + .flags = CFTYPE_ONLY_ON_ROOT, > + .read_seq_string = cfqg_print_weight_device, > + .write_string = cfqg_set_weight_device, > + .max_write_len = 256, > + }, > + { > + .name = "leaf_weight", > + .flags = CFTYPE_ONLY_ON_ROOT, > + .read_seq_string = cfq_print_weight, > + .write_u64 = cfq_set_weight, > + }, Hi Tejun, How does it help to map leaf weight to weight in root group. Old programs anyway don't know about leaf_weight. So nobody is going to update it. And if they update it, they better know what does it do. I think we just need to map "weight" to "leaf_weight" once you switch to making use of leaf_weight and at that point of time a user will expect that updating weight retains the old behavior. I think you have done that in later patch. But mapping leaf_weight to weight seems unnecessary atleast from backward compatibility point of view. Thanks Vivek -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 11/24] cfq-iosched: add leaf_weight
On Fri, Dec 28, 2012 at 12:35:33PM -0800, Tejun Heo wrote: [..] + + /* on root, leaf_weight is mapped to weight */ + { + .name = leaf_weight_device, + .flags = CFTYPE_ONLY_ON_ROOT, + .read_seq_string = cfqg_print_weight_device, + .write_string = cfqg_set_weight_device, + .max_write_len = 256, + }, + { + .name = leaf_weight, + .flags = CFTYPE_ONLY_ON_ROOT, + .read_seq_string = cfq_print_weight, + .write_u64 = cfq_set_weight, + }, Hi Tejun, How does it help to map leaf weight to weight in root group. Old programs anyway don't know about leaf_weight. So nobody is going to update it. And if they update it, they better know what does it do. I think we just need to map weight to leaf_weight once you switch to making use of leaf_weight and at that point of time a user will expect that updating weight retains the old behavior. I think you have done that in later patch. But mapping leaf_weight to weight seems unnecessary atleast from backward compatibility point of view. Thanks Vivek -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 11/24] cfq-iosched: add leaf_weight
Hello, Vivek. On Tue, Jan 08, 2013 at 10:34:48AM -0500, Vivek Goyal wrote: How does it help to map leaf weight to weight in root group. Old programs anyway don't know about leaf_weight. So nobody is going to update it. And if they update it, they better know what does it do. Because what cfq does before this patchset in flat hierarchy is basically treating root weight as the leaf weight. R:500 / \ A:250 B:750 Ratio of R is computed as 500 / (500 + 250 + 750). The root blkcg's tasks are competinig with the children blkcgs. This is currently the only supported config and we don't want to break existing users, so keeping root's weight and leaf_weight synchronized and ignoring root's weight, which BTW can't mean anything anyway as it doesn't have a parent or siblings, keeps the behavior unchanged for flat configs. Thanks. -- tejun -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/24] cfq-iosched: add leaf_weight
cfq blkcg is about to grow proper hierarchy handling, where a child blkg's weight would nest inside the parent's. This makes tasks in a blkg to compete against both tasks in the sibling blkgs and the tasks of child blkgs. We're gonna use the existing weight as the group weight which decides the blkg's weight against its siblings. This patch introduces a new weight - leaf_weight - which decides the weight of a blkg against the child blkgs. It's named leaf_weight because another way to look at it is that each internal blkg nodes have a hidden child leaf node which contains all its tasks and leaf_weight is the weight of the leaf node and handled the same as the weight of the child blkgs. This patch only adds leaf_weight fields and exposes it to userland. The new weight isn't actually used anywhere yet. Note that cfq-iosched currently offcially supports only single level hierarchy and root blkgs compete with the first level blkgs - ie. root weight is basically being used as leaf_weight. For root blkgs, the two weights are kept in sync for backward compatibility. v2: cfqd->root_group->leaf_weight initialization was missing from cfq_init_queue() causing divide by zero when !CONFIG_CFQ_GROUP_SCHED. Fix it. Reported by Fengguang. Signed-off-by: Tejun Heo Cc: Fengguang Wu --- block/blk-cgroup.c | 4 +- block/blk-cgroup.h | 1 + block/cfq-iosched.c | 134 3 files changed, 130 insertions(+), 9 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 942f344..10e1df9 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -26,7 +26,8 @@ static DEFINE_MUTEX(blkcg_pol_mutex); -struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT }; +struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT, + .cfq_leaf_weight = 2 * CFQ_WEIGHT_DEFAULT, }; EXPORT_SYMBOL_GPL(blkcg_root); static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS]; @@ -710,6 +711,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup) return ERR_PTR(-ENOMEM); blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT; + blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT; blkcg->id = atomic64_inc_return(_seq); /* root is 0, start from 1 */ done: spin_lock_init(>lock); diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index b26ed58..2446225 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h @@ -54,6 +54,7 @@ struct blkcg { /* TODO: per-policy storage in blkcg */ unsigned intcfq_weight; /* belongs to cfq */ + unsigned intcfq_leaf_weight; }; struct blkg_stat { diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index bc076f4..175218d6 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -223,10 +223,21 @@ struct cfq_group { /* group service_tree key */ u64 vdisktime; + + /* +* There are two weights - (internal) weight is the weight of this +* cfqg against the sibling cfqgs. leaf_weight is the wight of +* this cfqg against the child cfqgs. For the root cfqg, both +* weights are kept in sync for backward compatibility. +*/ unsigned int weight; unsigned int new_weight; unsigned int dev_weight; + unsigned int leaf_weight; + unsigned int new_leaf_weight; + unsigned int dev_leaf_weight; + /* number of cfqq currently on this group */ int nr_cfqq; @@ -1182,10 +1193,16 @@ static void cfq_update_group_weight(struct cfq_group *cfqg) { BUG_ON(!RB_EMPTY_NODE(>rb_node)); + if (cfqg->new_weight) { cfqg->weight = cfqg->new_weight; cfqg->new_weight = 0; } + + if (cfqg->new_leaf_weight) { + cfqg->leaf_weight = cfqg->new_leaf_weight; + cfqg->new_leaf_weight = 0; + } } static void @@ -1348,6 +1365,7 @@ static void cfq_pd_init(struct blkcg_gq *blkg) cfq_init_cfqg_base(cfqg); cfqg->weight = blkg->blkcg->cfq_weight; + cfqg->leaf_weight = blkg->blkcg->cfq_leaf_weight; } /* @@ -1404,6 +1422,26 @@ static int cfqg_print_weight_device(struct cgroup *cgrp, struct cftype *cft, return 0; } +static u64 cfqg_prfill_leaf_weight_device(struct seq_file *sf, + struct blkg_policy_data *pd, int off) +{ + struct cfq_group *cfqg = pd_to_cfqg(pd); + + if (!cfqg->dev_leaf_weight) + return 0; + return __blkg_prfill_u64(sf, pd, cfqg->dev_leaf_weight); +} + +static int cfqg_print_leaf_weight_device(struct cgroup *cgrp, +struct cftype *cft, +struct seq_file *sf) +{ + blkcg_print_blkgs(sf, cgroup_to_blkcg(cgrp), + cfqg_prfill_leaf_weight_device, _policy_cfq, 0, +
[PATCH 11/24] cfq-iosched: add leaf_weight
cfq blkcg is about to grow proper hierarchy handling, where a child blkg's weight would nest inside the parent's. This makes tasks in a blkg to compete against both tasks in the sibling blkgs and the tasks of child blkgs. We're gonna use the existing weight as the group weight which decides the blkg's weight against its siblings. This patch introduces a new weight - leaf_weight - which decides the weight of a blkg against the child blkgs. It's named leaf_weight because another way to look at it is that each internal blkg nodes have a hidden child leaf node which contains all its tasks and leaf_weight is the weight of the leaf node and handled the same as the weight of the child blkgs. This patch only adds leaf_weight fields and exposes it to userland. The new weight isn't actually used anywhere yet. Note that cfq-iosched currently offcially supports only single level hierarchy and root blkgs compete with the first level blkgs - ie. root weight is basically being used as leaf_weight. For root blkgs, the two weights are kept in sync for backward compatibility. v2: cfqd-root_group-leaf_weight initialization was missing from cfq_init_queue() causing divide by zero when !CONFIG_CFQ_GROUP_SCHED. Fix it. Reported by Fengguang. Signed-off-by: Tejun Heo t...@kernel.org Cc: Fengguang Wu fengguang...@intel.com --- block/blk-cgroup.c | 4 +- block/blk-cgroup.h | 1 + block/cfq-iosched.c | 134 3 files changed, 130 insertions(+), 9 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 942f344..10e1df9 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -26,7 +26,8 @@ static DEFINE_MUTEX(blkcg_pol_mutex); -struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT }; +struct blkcg blkcg_root = { .cfq_weight = 2 * CFQ_WEIGHT_DEFAULT, + .cfq_leaf_weight = 2 * CFQ_WEIGHT_DEFAULT, }; EXPORT_SYMBOL_GPL(blkcg_root); static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS]; @@ -710,6 +711,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup) return ERR_PTR(-ENOMEM); blkcg-cfq_weight = CFQ_WEIGHT_DEFAULT; + blkcg-cfq_leaf_weight = CFQ_WEIGHT_DEFAULT; blkcg-id = atomic64_inc_return(id_seq); /* root is 0, start from 1 */ done: spin_lock_init(blkcg-lock); diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index b26ed58..2446225 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h @@ -54,6 +54,7 @@ struct blkcg { /* TODO: per-policy storage in blkcg */ unsigned intcfq_weight; /* belongs to cfq */ + unsigned intcfq_leaf_weight; }; struct blkg_stat { diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index bc076f4..175218d6 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -223,10 +223,21 @@ struct cfq_group { /* group service_tree key */ u64 vdisktime; + + /* +* There are two weights - (internal) weight is the weight of this +* cfqg against the sibling cfqgs. leaf_weight is the wight of +* this cfqg against the child cfqgs. For the root cfqg, both +* weights are kept in sync for backward compatibility. +*/ unsigned int weight; unsigned int new_weight; unsigned int dev_weight; + unsigned int leaf_weight; + unsigned int new_leaf_weight; + unsigned int dev_leaf_weight; + /* number of cfqq currently on this group */ int nr_cfqq; @@ -1182,10 +1193,16 @@ static void cfq_update_group_weight(struct cfq_group *cfqg) { BUG_ON(!RB_EMPTY_NODE(cfqg-rb_node)); + if (cfqg-new_weight) { cfqg-weight = cfqg-new_weight; cfqg-new_weight = 0; } + + if (cfqg-new_leaf_weight) { + cfqg-leaf_weight = cfqg-new_leaf_weight; + cfqg-new_leaf_weight = 0; + } } static void @@ -1348,6 +1365,7 @@ static void cfq_pd_init(struct blkcg_gq *blkg) cfq_init_cfqg_base(cfqg); cfqg-weight = blkg-blkcg-cfq_weight; + cfqg-leaf_weight = blkg-blkcg-cfq_leaf_weight; } /* @@ -1404,6 +1422,26 @@ static int cfqg_print_weight_device(struct cgroup *cgrp, struct cftype *cft, return 0; } +static u64 cfqg_prfill_leaf_weight_device(struct seq_file *sf, + struct blkg_policy_data *pd, int off) +{ + struct cfq_group *cfqg = pd_to_cfqg(pd); + + if (!cfqg-dev_leaf_weight) + return 0; + return __blkg_prfill_u64(sf, pd, cfqg-dev_leaf_weight); +} + +static int cfqg_print_leaf_weight_device(struct cgroup *cgrp, +struct cftype *cft, +struct seq_file *sf) +{ + blkcg_print_blkgs(sf, cgroup_to_blkcg(cgrp), + cfqg_prfill_leaf_weight_device,