aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-05-14 16:52:38 -0400
committerTejun Heo <tj@kernel.org>2013-05-14 16:52:38 -0400
commit9138125beabbb76b4a373d4a619870f6f5d86fc5 (patch)
tree61ccabf042ff21b81c6dcd074ea8edeb77fedfa8
parent693e751e70843c29884cde326016e746fa16073a (diff)
blk-throttle: implement proper hierarchy support
With the recent updates, blk-throttle is finally ready for proper hierarchy support. Dispatching now honors service_queue->parent_sq and propagates correctly. The only thing missing is setting ->parent_sq correctly so that throtl_grp hierarchy matches the cgroup hierarchy. This patch updates throtl_pd_init() such that service_queues form the same hierarchy as the cgroup hierarchy if sane_behavior is enabled. As this concludes proper hierarchy support for blkcg, the shameful .broken_hierarchy tag is removed from blkio_subsys. v2: Updated blkio-controller.txt as suggested by Vivek. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Vivek Goyal <vgoyal@redhat.com> Cc: Li Zefan <lizefan@huawei.com>
-rw-r--r--Documentation/cgroups/blkio-controller.txt29
-rw-r--r--block/blk-cgroup.c8
-rw-r--r--block/blk-throttle.c22
-rw-r--r--include/linux/cgroup.h2
4 files changed, 38 insertions, 23 deletions
diff --git a/Documentation/cgroups/blkio-controller.txt b/Documentation/cgroups/blkio-controller.txt
index da272c8f44e7..cd556b914786 100644
--- a/Documentation/cgroups/blkio-controller.txt
+++ b/Documentation/cgroups/blkio-controller.txt
@@ -94,11 +94,13 @@ Throttling/Upper Limit policy
94 94
95Hierarchical Cgroups 95Hierarchical Cgroups
96==================== 96====================
97- Currently only CFQ supports hierarchical groups. For throttling,
98 cgroup interface does allow creation of hierarchical cgroups and
99 internally it treats them as flat hierarchy.
100 97
101 If somebody created a hierarchy like as follows. 98Both CFQ and throttling implement hierarchy support; however,
99throttling's hierarchy support is enabled iff "sane_behavior" is
100enabled from cgroup side, which currently is a development option and
101not publicly available.
102
103If somebody created a hierarchy like as follows.
102 104
103 root 105 root
104 / \ 106 / \
@@ -106,21 +108,20 @@ Hierarchical Cgroups
106 | 108 |
107 test3 109 test3
108 110
109 CFQ will handle the hierarchy correctly but and throttling will 111CFQ by default and throttling with "sane_behavior" will handle the
110 practically treat all groups at same level. For details on CFQ 112hierarchy correctly. For details on CFQ hierarchy support, refer to
111 hierarchy support, refer to Documentation/block/cfq-iosched.txt. 113Documentation/block/cfq-iosched.txt. For throttling, all limits apply
112 Throttling will treat the hierarchy as if it looks like the 114to the whole subtree while all statistics are local to the IOs
113 following. 115directly generated by tasks in that cgroup.
116
117Throttling without "sane_behavior" enabled from cgroup side will
118practically treat all groups at same level as if it looks like the
119following.
114 120
115 pivot 121 pivot
116 / / \ \ 122 / / \ \
117 root test1 test2 test3 123 root test1 test2 test3
118 124
119 Nesting cgroups, while allowed, isn't officially supported and blkio
120 genereates warning when cgroups nest. Once throttling implements
121 hierarchy support, hierarchy will be supported and the warning will
122 be removed.
123
124Various user visible config options 125Various user visible config options
125=================================== 126===================================
126CONFIG_BLK_CGROUP 127CONFIG_BLK_CGROUP
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index d0747605f56c..290792a13e3c 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -911,14 +911,6 @@ struct cgroup_subsys blkio_subsys = {
911 .subsys_id = blkio_subsys_id, 911 .subsys_id = blkio_subsys_id,
912 .base_cftypes = blkcg_files, 912 .base_cftypes = blkcg_files,
913 .module = THIS_MODULE, 913 .module = THIS_MODULE,
914
915 /*
916 * blkio subsystem is utterly broken in terms of hierarchy support.
917 * It treats all cgroups equally regardless of where they're
918 * located in the hierarchy - all cgroups are treated as if they're
919 * right below the root. Fix it and remove the following.
920 */
921 .broken_hierarchy = true,
922}; 914};
923EXPORT_SYMBOL_GPL(blkio_subsys); 915EXPORT_SYMBOL_GPL(blkio_subsys);
924 916
diff --git a/block/blk-throttle.c b/block/blk-throttle.c
index 27f006bb363b..08a32dfd3844 100644
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -397,10 +397,30 @@ static void throtl_pd_init(struct blkcg_gq *blkg)
397{ 397{
398 struct throtl_grp *tg = blkg_to_tg(blkg); 398 struct throtl_grp *tg = blkg_to_tg(blkg);
399 struct throtl_data *td = blkg->q->td; 399 struct throtl_data *td = blkg->q->td;
400 struct throtl_service_queue *parent_sq;
400 unsigned long flags; 401 unsigned long flags;
401 int rw; 402 int rw;
402 403
403 throtl_service_queue_init(&tg->service_queue, &td->service_queue); 404 /*
405 * If sane_hierarchy is enabled, we switch to properly hierarchical
406 * behavior where limits on a given throtl_grp are applied to the
407 * whole subtree rather than just the group itself. e.g. If 16M
408 * read_bps limit is set on the root group, the whole system can't
409 * exceed 16M for the device.
410 *
411 * If sane_hierarchy is not enabled, the broken flat hierarchy
412 * behavior is retained where all throtl_grps are treated as if
413 * they're all separate root groups right below throtl_data.
414 * Limits of a group don't interact with limits of other groups
415 * regardless of the position of the group in the hierarchy.
416 */
417 parent_sq = &td->service_queue;
418
419 if (cgroup_sane_behavior(blkg->blkcg->css.cgroup) && blkg->parent)
420 parent_sq = &blkg_to_tg(blkg->parent)->service_queue;
421
422 throtl_service_queue_init(&tg->service_queue, parent_sq);
423
404 for (rw = READ; rw <= WRITE; rw++) { 424 for (rw = READ; rw <= WRITE; rw++) {
405 throtl_qnode_init(&tg->qnode_on_self[rw], tg); 425 throtl_qnode_init(&tg->qnode_on_self[rw], tg);
406 throtl_qnode_init(&tg->qnode_on_parent[rw], tg); 426 throtl_qnode_init(&tg->qnode_on_parent[rw], tg);
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5047355b9a0f..09f1a1408ae0 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -272,6 +272,8 @@ enum {
272 * - memcg: use_hierarchy is on by default and the cgroup file for 272 * - memcg: use_hierarchy is on by default and the cgroup file for
273 * the flag is not created. 273 * the flag is not created.
274 * 274 *
275 * - blkcg: blk-throttle becomes properly hierarchical.
276 *
275 * The followings are planned changes. 277 * The followings are planned changes.
276 * 278 *
277 * - release_agent will be disallowed once replacement notification 279 * - release_agent will be disallowed once replacement notification