diff options
author | Tejun Heo <tj@kernel.org> | 2013-04-12 13:29:04 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-04-12 13:29:04 -0400 |
commit | 26d5bbe5ba2073fc7ef9e69a55543b2376f5bad0 (patch) | |
tree | d4dcfdec4d3046bb3cee35864264669d44a3a3dc | |
parent | ef824fa129b7579f56b92d466ecda2e378879806 (diff) |
Revert "cgroup: remove bind() method from cgroup_subsys."
This reverts commit 84cfb6ab484b442d5115eb3baf9db7d74a3ea626. There
are scheduled changes which make use of the removed callback.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Rami Rosen <ramirose@gmail.com>
Cc: Li Zefan <lizefan@huawei.com>
-rw-r--r-- | Documentation/cgroups/cgroups.txt | 20 | ||||
-rw-r--r-- | include/linux/cgroup.h | 2 | ||||
-rw-r--r-- | kernel/cgroup.c | 4 |
3 files changed, 21 insertions, 5 deletions
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt index 2b51e12ce178..638bf17ff869 100644 --- a/Documentation/cgroups/cgroups.txt +++ b/Documentation/cgroups/cgroups.txt | |||
@@ -211,9 +211,10 @@ matches, and any of the requested subsystems are in use in an existing | |||
211 | hierarchy, the mount will fail with -EBUSY. Otherwise, a new hierarchy | 211 | hierarchy, the mount will fail with -EBUSY. Otherwise, a new hierarchy |
212 | is activated, associated with the requested subsystems. | 212 | is activated, associated with the requested subsystems. |
213 | 213 | ||
214 | It's not possible to bind a new subsystem to an active cgroup | 214 | It's not currently possible to bind a new subsystem to an active |
215 | hierarchy, or to unbind a subsystem from an active cgroup | 215 | cgroup hierarchy, or to unbind a subsystem from an active cgroup |
216 | hierarchy. | 216 | hierarchy. This may be possible in future, but is fraught with nasty |
217 | error-recovery issues. | ||
217 | 218 | ||
218 | When a cgroup filesystem is unmounted, if there are any | 219 | When a cgroup filesystem is unmounted, if there are any |
219 | child cgroups created below the top-level cgroup, that hierarchy | 220 | child cgroups created below the top-level cgroup, that hierarchy |
@@ -381,8 +382,10 @@ To Specify a hierarchy's release_agent: | |||
381 | 382 | ||
382 | Note that specifying 'release_agent' more than once will return failure. | 383 | Note that specifying 'release_agent' more than once will return failure. |
383 | 384 | ||
384 | Note that changing the set of subsystems is only supported when the | 385 | Note that changing the set of subsystems is currently only supported |
385 | hierarchy consists of a single (root) cgroup. | 386 | when the hierarchy consists of a single (root) cgroup. Supporting |
387 | the ability to arbitrarily bind/unbind subsystems from an existing | ||
388 | cgroup hierarchy is intended to be implemented in the future. | ||
386 | 389 | ||
387 | Then under /sys/fs/cgroup/rg1 you can find a tree that corresponds to the | 390 | Then under /sys/fs/cgroup/rg1 you can find a tree that corresponds to the |
388 | tree of the cgroups in the system. For instance, /sys/fs/cgroup/rg1 | 391 | tree of the cgroups in the system. For instance, /sys/fs/cgroup/rg1 |
@@ -640,6 +643,13 @@ void exit(struct task_struct *task) | |||
640 | 643 | ||
641 | Called during task exit. | 644 | Called during task exit. |
642 | 645 | ||
646 | void bind(struct cgroup *root) | ||
647 | (cgroup_mutex held by caller) | ||
648 | |||
649 | Called when a cgroup subsystem is rebound to a different hierarchy | ||
650 | and root cgroup. Currently this will only involve movement between | ||
651 | the default hierarchy (which never has sub-cgroups) and a hierarchy | ||
652 | that is being created/destroyed (and hence has no sub-cgroups). | ||
643 | 653 | ||
644 | 4. Extended attribute usage | 654 | 4. Extended attribute usage |
645 | =========================== | 655 | =========================== |
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index a2b9d4b13369..45aee0fc6b98 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -484,6 +484,8 @@ struct cgroup_subsys { | |||
484 | void (*fork)(struct task_struct *task); | 484 | void (*fork)(struct task_struct *task); |
485 | void (*exit)(struct cgroup *cgrp, struct cgroup *old_cgrp, | 485 | void (*exit)(struct cgroup *cgrp, struct cgroup *old_cgrp, |
486 | struct task_struct *task); | 486 | struct task_struct *task); |
487 | void (*bind)(struct cgroup *root); | ||
488 | |||
487 | int subsys_id; | 489 | int subsys_id; |
488 | int active; | 490 | int active; |
489 | int disabled; | 491 | int disabled; |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7bf3ce09c50c..678a22c75fdb 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1091,12 +1091,16 @@ static int rebind_subsystems(struct cgroupfs_root *root, | |||
1091 | cgrp->subsys[i]->cgroup = cgrp; | 1091 | cgrp->subsys[i]->cgroup = cgrp; |
1092 | list_move(&ss->sibling, &root->subsys_list); | 1092 | list_move(&ss->sibling, &root->subsys_list); |
1093 | ss->root = root; | 1093 | ss->root = root; |
1094 | if (ss->bind) | ||
1095 | ss->bind(cgrp); | ||
1094 | /* refcount was already taken, and we're keeping it */ | 1096 | /* refcount was already taken, and we're keeping it */ |
1095 | } else if (bit & removed_mask) { | 1097 | } else if (bit & removed_mask) { |
1096 | /* We're removing this subsystem */ | 1098 | /* We're removing this subsystem */ |
1097 | BUG_ON(ss == NULL); | 1099 | BUG_ON(ss == NULL); |
1098 | BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]); | 1100 | BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]); |
1099 | BUG_ON(cgrp->subsys[i]->cgroup != cgrp); | 1101 | BUG_ON(cgrp->subsys[i]->cgroup != cgrp); |
1102 | if (ss->bind) | ||
1103 | ss->bind(dummytop); | ||
1100 | dummytop->subsys[i]->cgroup = dummytop; | 1104 | dummytop->subsys[i]->cgroup = dummytop; |
1101 | cgrp->subsys[i] = NULL; | 1105 | cgrp->subsys[i] = NULL; |
1102 | subsys[i]->root = &rootnode; | 1106 | subsys[i]->root = &rootnode; |