diff options
author | Tejun Heo <tj@kernel.org> | 2014-02-25 10:04:02 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-02-25 10:04:02 -0500 |
commit | ceb6a081f6f52d17ec9e46e271cc26a1eb8a7573 (patch) | |
tree | 100b59acde1d14b2995b0a399ff53e1ea6c571ed /kernel/cgroup.c | |
parent | b3dc094e93905ae9c1bc0815402ad8e5b203d068 (diff) |
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>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 5def4a800425..23e3a8c74bd4 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -758,25 +758,15 @@ static void cgroup_destroy_root(struct cgroupfs_root *root) | |||
758 | cgroup_free_root(root); | 758 | cgroup_free_root(root); |
759 | } | 759 | } |
760 | 760 | ||
761 | /* | 761 | /* look up cgroup associated with given css_set on the specified hierarchy */ |
762 | * Return the cgroup for "task" from the given hierarchy. Must be | 762 | static struct cgroup *cset_cgroup_from_root(struct css_set *cset, |
763 | * called with cgroup_mutex and css_set_rwsem held. | ||
764 | */ | ||
765 | static struct cgroup *task_cgroup_from_root(struct task_struct *task, | ||
766 | struct cgroupfs_root *root) | 763 | struct cgroupfs_root *root) |
767 | { | 764 | { |
768 | struct css_set *cset; | ||
769 | struct cgroup *res = NULL; | 765 | struct cgroup *res = NULL; |
770 | 766 | ||
771 | lockdep_assert_held(&cgroup_mutex); | 767 | lockdep_assert_held(&cgroup_mutex); |
772 | lockdep_assert_held(&css_set_rwsem); | 768 | lockdep_assert_held(&css_set_rwsem); |
773 | 769 | ||
774 | /* | ||
775 | * No need to lock the task - since we hold cgroup_mutex the | ||
776 | * task can't change groups, so the only thing that can happen | ||
777 | * is that it exits and its css is set back to init_css_set. | ||
778 | */ | ||
779 | cset = task_css_set(task); | ||
780 | if (cset == &init_css_set) { | 770 | if (cset == &init_css_set) { |
781 | res = &root->top_cgroup; | 771 | res = &root->top_cgroup; |
782 | } else { | 772 | } else { |
@@ -797,6 +787,21 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task, | |||
797 | } | 787 | } |
798 | 788 | ||
799 | /* | 789 | /* |
790 | * Return the cgroup for "task" from the given hierarchy. Must be | ||
791 | * called with cgroup_mutex and css_set_rwsem held. | ||
792 | */ | ||
793 | static struct cgroup *task_cgroup_from_root(struct task_struct *task, | ||
794 | struct cgroupfs_root *root) | ||
795 | { | ||
796 | /* | ||
797 | * No need to lock the task - since we hold cgroup_mutex the | ||
798 | * task can't change groups, so the only thing that can happen | ||
799 | * is that it exits and its css is set back to init_css_set. | ||
800 | */ | ||
801 | return cset_cgroup_from_root(task_css_set(task), root); | ||
802 | } | ||
803 | |||
804 | /* | ||
800 | * There is one global cgroup mutex. We also require taking | 805 | * There is one global cgroup mutex. We also require taking |
801 | * task_lock() when dereferencing a task's cgroup subsys pointers. | 806 | * task_lock() when dereferencing a task's cgroup subsys pointers. |
802 | * See "The task_lock() exception", at the end of this comment. | 807 | * See "The task_lock() exception", at the end of this comment. |