cgroup: separate out cset_group_from_root() from task_cgroup_from_root()
This will be used by the planned migration path update. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
This commit is contained in:
parent
b3dc094e93
commit
ceb6a081f6
1 changed files with 17 additions and 12 deletions
|
@ -758,25 +758,15 @@ static void cgroup_destroy_root(struct cgroupfs_root *root)
|
||||||
cgroup_free_root(root);
|
cgroup_free_root(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* look up cgroup associated with given css_set on the specified hierarchy */
|
||||||
* Return the cgroup for "task" from the given hierarchy. Must be
|
static struct cgroup *cset_cgroup_from_root(struct css_set *cset,
|
||||||
* called with cgroup_mutex and css_set_rwsem held.
|
|
||||||
*/
|
|
||||||
static struct cgroup *task_cgroup_from_root(struct task_struct *task,
|
|
||||||
struct cgroupfs_root *root)
|
struct cgroupfs_root *root)
|
||||||
{
|
{
|
||||||
struct css_set *cset;
|
|
||||||
struct cgroup *res = NULL;
|
struct cgroup *res = NULL;
|
||||||
|
|
||||||
lockdep_assert_held(&cgroup_mutex);
|
lockdep_assert_held(&cgroup_mutex);
|
||||||
lockdep_assert_held(&css_set_rwsem);
|
lockdep_assert_held(&css_set_rwsem);
|
||||||
|
|
||||||
/*
|
|
||||||
* No need to lock the task - since we hold cgroup_mutex the
|
|
||||||
* task can't change groups, so the only thing that can happen
|
|
||||||
* is that it exits and its css is set back to init_css_set.
|
|
||||||
*/
|
|
||||||
cset = task_css_set(task);
|
|
||||||
if (cset == &init_css_set) {
|
if (cset == &init_css_set) {
|
||||||
res = &root->top_cgroup;
|
res = &root->top_cgroup;
|
||||||
} else {
|
} else {
|
||||||
|
@ -796,6 +786,21 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the cgroup for "task" from the given hierarchy. Must be
|
||||||
|
* called with cgroup_mutex and css_set_rwsem held.
|
||||||
|
*/
|
||||||
|
static struct cgroup *task_cgroup_from_root(struct task_struct *task,
|
||||||
|
struct cgroupfs_root *root)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* No need to lock the task - since we hold cgroup_mutex the
|
||||||
|
* task can't change groups, so the only thing that can happen
|
||||||
|
* is that it exits and its css is set back to init_css_set.
|
||||||
|
*/
|
||||||
|
return cset_cgroup_from_root(task_css_set(task), root);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There is one global cgroup mutex. We also require taking
|
* There is one global cgroup mutex. We also require taking
|
||||||
* task_lock() when dereferencing a task's cgroup subsys pointers.
|
* task_lock() when dereferencing a task's cgroup subsys pointers.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue