Commit b326f9d0 authored by Tejun Heo's avatar Tejun Heo

cgroup: clean up find_css_set() and friends

find_css_set() passes uninitialized on-stack template[] array to
find_existing_css_set() which sets the entries for all subsystems.
Passing around an uninitialized array is a bit icky and we want to
introduce an iterator which only iterates loaded subsystems.  Let's
initialize it on definition.

While at it, also make the following cosmetic cleanups.

* Convert to proper /** comments.

* Reorder variable declarations.

* Replace comment on synchronization with lockdep_assert_held().

This patch doesn't make any functional differences.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarLi Zefan <lizefan@huawei.com>
parent a8a648c4
...@@ -434,7 +434,7 @@ static inline void put_css_set_taskexit(struct css_set *cset) ...@@ -434,7 +434,7 @@ static inline void put_css_set_taskexit(struct css_set *cset)
__put_css_set(cset, 1); __put_css_set(cset, 1);
} }
/* /**
* compare_css_sets - helper function for find_existing_css_set(). * compare_css_sets - helper function for find_existing_css_set().
* @cset: candidate css_set being tested * @cset: candidate css_set being tested
* @old_cset: existing css_set for a task * @old_cset: existing css_set for a task
...@@ -506,27 +506,20 @@ static bool compare_css_sets(struct css_set *cset, ...@@ -506,27 +506,20 @@ static bool compare_css_sets(struct css_set *cset,
return true; return true;
} }
/* /**
* find_existing_css_set() is a helper for * find_existing_css_set - init css array and find the matching css_set
* find_css_set(), and checks to see whether an existing * @old_cset: the css_set that we're using before the cgroup transition
* css_set is suitable. * @cgrp: the cgroup that we're moving into
* * @template: out param for the new set of csses, should be clear on entry
* oldcg: the cgroup group that we're using before the cgroup
* transition
*
* cgrp: the cgroup that we're moving into
*
* template: location in which to build the desired set of subsystem
* state objects for the new cgroup group
*/ */
static struct css_set *find_existing_css_set(struct css_set *old_cset, static struct css_set *find_existing_css_set(struct css_set *old_cset,
struct cgroup *cgrp, struct cgroup *cgrp,
struct cgroup_subsys_state *template[]) struct cgroup_subsys_state *template[])
{ {
int i;
struct cgroupfs_root *root = cgrp->root; struct cgroupfs_root *root = cgrp->root;
struct css_set *cset; struct css_set *cset;
unsigned long key; unsigned long key;
int i;
/* /*
* Build the set of subsystem state objects that we want to see in the * Build the set of subsystem state objects that we want to see in the
...@@ -618,22 +611,25 @@ static void link_css_set(struct list_head *tmp_links, struct css_set *cset, ...@@ -618,22 +611,25 @@ static void link_css_set(struct list_head *tmp_links, struct css_set *cset,
list_add_tail(&link->cgrp_link, &cset->cgrp_links); list_add_tail(&link->cgrp_link, &cset->cgrp_links);
} }
/* /**
* find_css_set() takes an existing cgroup group and a * find_css_set - return a new css_set with one cgroup updated
* cgroup object, and returns a css_set object that's * @old_cset: the baseline css_set
* equivalent to the old group, but with the given cgroup * @cgrp: the cgroup to be updated
* substituted into the appropriate hierarchy. Must be called with *
* cgroup_mutex held * Return a new css_set that's equivalent to @old_cset, but with @cgrp
* substituted into the appropriate hierarchy.
*/ */
static struct css_set *find_css_set(struct css_set *old_cset, static struct css_set *find_css_set(struct css_set *old_cset,
struct cgroup *cgrp) struct cgroup *cgrp)
{ {
struct cgroup_subsys_state *template[CGROUP_SUBSYS_COUNT] = { };
struct css_set *cset; struct css_set *cset;
struct cgroup_subsys_state *template[CGROUP_SUBSYS_COUNT];
struct list_head tmp_links; struct list_head tmp_links;
struct cgrp_cset_link *link; struct cgrp_cset_link *link;
unsigned long key; unsigned long key;
lockdep_assert_held(&cgroup_mutex);
/* First see if we already have a cgroup group that matches /* First see if we already have a cgroup group that matches
* the desired set */ * the desired set */
read_lock(&css_set_lock); read_lock(&css_set_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment