Commit 69d0206c authored by Tejun Heo's avatar Tejun Heo

cgroup: bring some sanity to naming around cg_cgroup_link

cgroups and css_sets are mapped M:N and this M:N mapping is
represented by struct cg_cgroup_link which forms linked lists on both
sides.  The naming around this mapping is already confusing and struct
cg_cgroup_link exacerbates the situation quite a bit.

>From cgroup side, it starts off ->css_sets and runs through
->cgrp_link_list.  From css_set side, it starts off ->cg_links and
runs through ->cg_link_list.  This is rather reversed as
cgrp_link_list is used to iterate css_sets and cg_link_list cgroups.
Also, this is the only place which is still using the confusing "cg"
for css_sets.  This patch cleans it up a bit.

* s/cgroup->css_sets/cgroup->cset_links/
  s/css_set->cg_links/css_set->cgrp_links/
  s/cgroup_iter->cg_link/cgroup_iter->cset_link/

* s/cg_cgroup_link/cgrp_cset_link/

* s/cgrp_cset_link->cg/cgrp_cset_link->cset/
  s/cgrp_cset_link->cgrp_link_list/cgrp_cset_link->cset_link/
  s/cgrp_cset_link->cg_link_list/cgrp_cset_link->cgrp_link/

* s/init_css_set_link/init_cgrp_cset_link/
  s/free_cg_links/free_cgrp_cset_links/
  s/allocate_cg_links/allocate_cgrp_cset_links/

* s/cgl[12]/link[12]/ in compare_css_sets()

* s/saved_link/tmp_link/ s/tmp/tmp_links/ and a couple similar
  adustments.

* Comment and whiteline adjustments.

After the changes, we have

	list_for_each_entry(link, &cont->cset_links, cset_link) {
		struct css_set *cset = link->cset;

instead of

	list_for_each_entry(link, &cont->css_sets, cgrp_link_list) {
		struct css_set *cset = link->cg;

This patch is purely cosmetic.

v2: Fix broken sentences in the patch description.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarLi Zefan <lizefan@huawei.com>
parent 5abb8855
...@@ -215,10 +215,10 @@ struct cgroup { ...@@ -215,10 +215,10 @@ struct cgroup {
struct cgroupfs_root *root; struct cgroupfs_root *root;
/* /*
* List of cg_cgroup_links pointing at css_sets with * List of cgrp_cset_links pointing at css_sets with tasks in this
* tasks in this cgroup. Protected by css_set_lock * cgroup. Protected by css_set_lock.
*/ */
struct list_head css_sets; struct list_head cset_links;
struct list_head allcg_node; /* cgroupfs_root->allcg_list */ struct list_head allcg_node; /* cgroupfs_root->allcg_list */
struct list_head cft_q_node; /* used during cftype add/rm */ struct list_head cft_q_node; /* used during cftype add/rm */
...@@ -365,11 +365,10 @@ struct css_set { ...@@ -365,11 +365,10 @@ struct css_set {
struct list_head tasks; struct list_head tasks;
/* /*
* List of cg_cgroup_link objects on link chains from * List of cgrp_cset_links pointing at cgroups referenced from this
* cgroups referenced from this css_set. Protected by * css_set. Protected by css_set_lock.
* css_set_lock
*/ */
struct list_head cg_links; struct list_head cgrp_links;
/* /*
* Set of subsystem states, one for each subsystem. This array * Set of subsystem states, one for each subsystem. This array
...@@ -792,7 +791,7 @@ struct cgroup *cgroup_next_descendant_post(struct cgroup *pos, ...@@ -792,7 +791,7 @@ struct cgroup *cgroup_next_descendant_post(struct cgroup *pos,
/* A cgroup_iter should be treated as an opaque object */ /* A cgroup_iter should be treated as an opaque object */
struct cgroup_iter { struct cgroup_iter {
struct list_head *cg_link; struct list_head *cset_link;
struct list_head *task; struct list_head *task;
}; };
......
...@@ -315,20 +315,24 @@ static void cgroup_release_agent(struct work_struct *work); ...@@ -315,20 +315,24 @@ static void cgroup_release_agent(struct work_struct *work);
static DECLARE_WORK(release_agent_work, cgroup_release_agent); static DECLARE_WORK(release_agent_work, cgroup_release_agent);
static void check_for_release(struct cgroup *cgrp); static void check_for_release(struct cgroup *cgrp);
/* Link structure for associating css_set objects with cgroups */ /*
struct cg_cgroup_link { * A cgroup can be associated with multiple css_sets as different tasks may
/* * belong to different cgroups on different hierarchies. In the other
* List running through cg_cgroup_links associated with a * direction, a css_set is naturally associated with multiple cgroups.
* cgroup, anchored on cgroup->css_sets * This M:N relationship is represented by the following link structure
*/ * which exists for each association and allows traversing the associations
struct list_head cgrp_link_list; * from both sides.
struct cgroup *cgrp; */
/* struct cgrp_cset_link {
* List running through cg_cgroup_links pointing at a /* the cgroup and css_set this link associates */
* single css_set object, anchored on css_set->cg_links struct cgroup *cgrp;
*/ struct css_set *cset;
struct list_head cg_link_list;
struct css_set *cg; /* list of cgrp_cset_links anchored at cgrp->cset_links */
struct list_head cset_link;
/* list of cgrp_cset_links anchored at css_set->cgrp_links */
struct list_head cgrp_link;
}; };
/* The default css_set - used by init and its children prior to any /* The default css_set - used by init and its children prior to any
...@@ -339,7 +343,7 @@ struct cg_cgroup_link { ...@@ -339,7 +343,7 @@ struct cg_cgroup_link {
*/ */
static struct css_set init_css_set; static struct css_set init_css_set;
static struct cg_cgroup_link init_css_set_link; static struct cgrp_cset_link init_cgrp_cset_link;
static int cgroup_init_idr(struct cgroup_subsys *ss, static int cgroup_init_idr(struct cgroup_subsys *ss,
struct cgroup_subsys_state *css); struct cgroup_subsys_state *css);
...@@ -378,8 +382,7 @@ static int use_task_css_set_links __read_mostly; ...@@ -378,8 +382,7 @@ static int use_task_css_set_links __read_mostly;
static void __put_css_set(struct css_set *cset, int taskexit) static void __put_css_set(struct css_set *cset, int taskexit)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link, *tmp_link;
struct cg_cgroup_link *saved_link;
/* /*
* Ensure that the refcount doesn't hit zero while any readers * Ensure that the refcount doesn't hit zero while any readers
...@@ -398,12 +401,11 @@ static void __put_css_set(struct css_set *cset, int taskexit) ...@@ -398,12 +401,11 @@ static void __put_css_set(struct css_set *cset, int taskexit)
hash_del(&cset->hlist); hash_del(&cset->hlist);
css_set_count--; css_set_count--;
list_for_each_entry_safe(link, saved_link, &cset->cg_links, list_for_each_entry_safe(link, tmp_link, &cset->cgrp_links, cgrp_link) {
cg_link_list) {
struct cgroup *cgrp = link->cgrp; struct cgroup *cgrp = link->cgrp;
list_del(&link->cg_link_list); list_del(&link->cset_link);
list_del(&link->cgrp_link_list); list_del(&link->cgrp_link);
/* /*
* We may not be holding cgroup_mutex, and if cgrp->count is * We may not be holding cgroup_mutex, and if cgrp->count is
...@@ -475,26 +477,26 @@ static bool compare_css_sets(struct css_set *cset, ...@@ -475,26 +477,26 @@ static bool compare_css_sets(struct css_set *cset,
* candidates. * candidates.
*/ */
l1 = &cset->cg_links; l1 = &cset->cgrp_links;
l2 = &old_cset->cg_links; l2 = &old_cset->cgrp_links;
while (1) { while (1) {
struct cg_cgroup_link *cgl1, *cgl2; struct cgrp_cset_link *link1, *link2;
struct cgroup *cgrp1, *cgrp2; struct cgroup *cgrp1, *cgrp2;
l1 = l1->next; l1 = l1->next;
l2 = l2->next; l2 = l2->next;
/* See if we reached the end - both lists are equal length. */ /* See if we reached the end - both lists are equal length. */
if (l1 == &cset->cg_links) { if (l1 == &cset->cgrp_links) {
BUG_ON(l2 != &old_cset->cg_links); BUG_ON(l2 != &old_cset->cgrp_links);
break; break;
} else { } else {
BUG_ON(l2 == &old_cset->cg_links); BUG_ON(l2 == &old_cset->cgrp_links);
} }
/* Locate the cgroups associated with these links. */ /* Locate the cgroups associated with these links. */
cgl1 = list_entry(l1, struct cg_cgroup_link, cg_link_list); link1 = list_entry(l1, struct cgrp_cset_link, cgrp_link);
cgl2 = list_entry(l2, struct cg_cgroup_link, cg_link_list); link2 = list_entry(l2, struct cgrp_cset_link, cgrp_link);
cgrp1 = cgl1->cgrp; cgrp1 = link1->cgrp;
cgrp2 = cgl2->cgrp; cgrp2 = link2->cgrp;
/* Hierarchies should be linked in the same order. */ /* Hierarchies should be linked in the same order. */
BUG_ON(cgrp1->root != cgrp2->root); BUG_ON(cgrp1->root != cgrp2->root);
...@@ -569,61 +571,64 @@ static struct css_set *find_existing_css_set(struct css_set *old_cset, ...@@ -569,61 +571,64 @@ static struct css_set *find_existing_css_set(struct css_set *old_cset,
return NULL; return NULL;
} }
static void free_cg_links(struct list_head *tmp) static void free_cgrp_cset_links(struct list_head *links_to_free)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link, *tmp_link;
struct cg_cgroup_link *saved_link;
list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) { list_for_each_entry_safe(link, tmp_link, links_to_free, cset_link) {
list_del(&link->cgrp_link_list); list_del(&link->cset_link);
kfree(link); kfree(link);
} }
} }
/* /**
* allocate_cg_links() allocates "count" cg_cgroup_link structures * allocate_cgrp_cset_links - allocate cgrp_cset_links
* and chains them on tmp through their cgrp_link_list fields. Returns 0 on * @count: the number of links to allocate
* success or a negative error * @tmp_links: list_head the allocated links are put on
*
* Allocate @count cgrp_cset_link structures and chain them on @tmp_links
* through ->cset_link. Returns 0 on success or -errno.
*/ */
static int allocate_cg_links(int count, struct list_head *tmp) static int allocate_cgrp_cset_links(int count, struct list_head *tmp_links)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
int i; int i;
INIT_LIST_HEAD(tmp);
INIT_LIST_HEAD(tmp_links);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
link = kmalloc(sizeof(*link), GFP_KERNEL); link = kmalloc(sizeof(*link), GFP_KERNEL);
if (!link) { if (!link) {
free_cg_links(tmp); free_cgrp_cset_links(tmp_links);
return -ENOMEM; return -ENOMEM;
} }
list_add(&link->cgrp_link_list, tmp); list_add(&link->cset_link, tmp_links);
} }
return 0; return 0;
} }
/** /**
* link_css_set - a helper function to link a css_set to a cgroup * link_css_set - a helper function to link a css_set to a cgroup
* @tmp_cg_links: cg_cgroup_link objects allocated by allocate_cg_links() * @tmp_links: cgrp_cset_link objects allocated by allocate_cgrp_cset_links()
* @cset: the css_set to be linked * @cset: the css_set to be linked
* @cgrp: the destination cgroup * @cgrp: the destination cgroup
*/ */
static void link_css_set(struct list_head *tmp_cg_links, static void link_css_set(struct list_head *tmp_links, struct css_set *cset,
struct css_set *cset, struct cgroup *cgrp) struct cgroup *cgrp)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
BUG_ON(list_empty(tmp_cg_links)); BUG_ON(list_empty(tmp_links));
link = list_first_entry(tmp_cg_links, struct cg_cgroup_link, link = list_first_entry(tmp_links, struct cgrp_cset_link, cset_link);
cgrp_link_list); link->cset = cset;
link->cg = cset;
link->cgrp = cgrp; link->cgrp = cgrp;
atomic_inc(&cgrp->count); atomic_inc(&cgrp->count);
list_move(&link->cgrp_link_list, &cgrp->css_sets); list_move(&link->cset_link, &cgrp->cset_links);
/* /*
* Always add links to the tail of the list so that the list * Always add links to the tail of the list so that the list
* is sorted by order of hierarchy creation * is sorted by order of hierarchy creation
*/ */
list_add_tail(&link->cg_link_list, &cset->cg_links); list_add_tail(&link->cgrp_link, &cset->cgrp_links);
} }
/* /*
...@@ -638,10 +643,8 @@ static struct css_set *find_css_set(struct css_set *old_cset, ...@@ -638,10 +643,8 @@ static struct css_set *find_css_set(struct css_set *old_cset,
{ {
struct css_set *cset; struct css_set *cset;
struct cgroup_subsys_state *template[CGROUP_SUBSYS_COUNT]; struct cgroup_subsys_state *template[CGROUP_SUBSYS_COUNT];
struct list_head tmp_links;
struct list_head tmp_cg_links; struct cgrp_cset_link *link;
struct cg_cgroup_link *link;
unsigned long key; unsigned long key;
/* First see if we already have a cgroup group that matches /* First see if we already have a cgroup group that matches
...@@ -659,14 +662,14 @@ static struct css_set *find_css_set(struct css_set *old_cset, ...@@ -659,14 +662,14 @@ static struct css_set *find_css_set(struct css_set *old_cset,
if (!cset) if (!cset)
return NULL; return NULL;
/* Allocate all the cg_cgroup_link objects that we'll need */ /* Allocate all the cgrp_cset_link objects that we'll need */
if (allocate_cg_links(root_count, &tmp_cg_links) < 0) { if (allocate_cgrp_cset_links(root_count, &tmp_links) < 0) {
kfree(cset); kfree(cset);
return NULL; return NULL;
} }
atomic_set(&cset->refcount, 1); atomic_set(&cset->refcount, 1);
INIT_LIST_HEAD(&cset->cg_links); INIT_LIST_HEAD(&cset->cgrp_links);
INIT_LIST_HEAD(&cset->tasks); INIT_LIST_HEAD(&cset->tasks);
INIT_HLIST_NODE(&cset->hlist); INIT_HLIST_NODE(&cset->hlist);
...@@ -676,14 +679,15 @@ static struct css_set *find_css_set(struct css_set *old_cset, ...@@ -676,14 +679,15 @@ static struct css_set *find_css_set(struct css_set *old_cset,
write_lock(&css_set_lock); write_lock(&css_set_lock);
/* Add reference counts and links from the new css_set. */ /* Add reference counts and links from the new css_set. */
list_for_each_entry(link, &old_cset->cg_links, cg_link_list) { list_for_each_entry(link, &old_cset->cgrp_links, cgrp_link) {
struct cgroup *c = link->cgrp; struct cgroup *c = link->cgrp;
if (c->root == cgrp->root) if (c->root == cgrp->root)
c = cgrp; c = cgrp;
link_css_set(&tmp_cg_links, cset, c); link_css_set(&tmp_links, cset, c);
} }
BUG_ON(!list_empty(&tmp_cg_links)); BUG_ON(!list_empty(&tmp_links));
css_set_count++; css_set_count++;
...@@ -717,9 +721,11 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task, ...@@ -717,9 +721,11 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task,
if (cset == &init_css_set) { if (cset == &init_css_set) {
res = &root->top_cgroup; res = &root->top_cgroup;
} else { } else {
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
list_for_each_entry(link, &cset->cg_links, cg_link_list) {
list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
struct cgroup *c = link->cgrp; struct cgroup *c = link->cgrp;
if (c->root == root) { if (c->root == root) {
res = c; res = c;
break; break;
...@@ -1405,7 +1411,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp) ...@@ -1405,7 +1411,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
INIT_LIST_HEAD(&cgrp->sibling); INIT_LIST_HEAD(&cgrp->sibling);
INIT_LIST_HEAD(&cgrp->children); INIT_LIST_HEAD(&cgrp->children);
INIT_LIST_HEAD(&cgrp->files); INIT_LIST_HEAD(&cgrp->files);
INIT_LIST_HEAD(&cgrp->css_sets); INIT_LIST_HEAD(&cgrp->cset_links);
INIT_LIST_HEAD(&cgrp->allcg_node); INIT_LIST_HEAD(&cgrp->allcg_node);
INIT_LIST_HEAD(&cgrp->release_list); INIT_LIST_HEAD(&cgrp->release_list);
INIT_LIST_HEAD(&cgrp->pidlists); INIT_LIST_HEAD(&cgrp->pidlists);
...@@ -1604,7 +1610,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1604,7 +1610,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
BUG_ON(!root); BUG_ON(!root);
if (root == opts.new_root) { if (root == opts.new_root) {
/* We used the new root structure, so this is a new hierarchy */ /* We used the new root structure, so this is a new hierarchy */
struct list_head tmp_cg_links; struct list_head tmp_links;
struct cgroup *root_cgrp = &root->top_cgroup; struct cgroup *root_cgrp = &root->top_cgroup;
struct cgroupfs_root *existing_root; struct cgroupfs_root *existing_root;
const struct cred *cred; const struct cred *cred;
...@@ -1636,7 +1642,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1636,7 +1642,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
* that's us. The worst that can happen is that we * that's us. The worst that can happen is that we
* have some link structures left over * have some link structures left over
*/ */
ret = allocate_cg_links(css_set_count, &tmp_cg_links); ret = allocate_cgrp_cset_links(css_set_count, &tmp_links);
if (ret) if (ret)
goto unlock_drop; goto unlock_drop;
...@@ -1646,7 +1652,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1646,7 +1652,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
ret = rebind_subsystems(root, root->subsys_mask); ret = rebind_subsystems(root, root->subsys_mask);
if (ret == -EBUSY) { if (ret == -EBUSY) {
free_cg_links(&tmp_cg_links); free_cgrp_cset_links(&tmp_links);
goto unlock_drop; goto unlock_drop;
} }
/* /*
...@@ -1668,10 +1674,10 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1668,10 +1674,10 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
* the css_set objects */ * the css_set objects */
write_lock(&css_set_lock); write_lock(&css_set_lock);
hash_for_each(css_set_table, i, cset, hlist) hash_for_each(css_set_table, i, cset, hlist)
link_css_set(&tmp_cg_links, cset, root_cgrp); link_css_set(&tmp_links, cset, root_cgrp);
write_unlock(&css_set_lock); write_unlock(&css_set_lock);
free_cg_links(&tmp_cg_links); free_cgrp_cset_links(&tmp_links);
BUG_ON(!list_empty(&root_cgrp->children)); BUG_ON(!list_empty(&root_cgrp->children));
BUG_ON(root->number_of_cgroups != 1); BUG_ON(root->number_of_cgroups != 1);
...@@ -1722,9 +1728,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1722,9 +1728,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
static void cgroup_kill_sb(struct super_block *sb) { static void cgroup_kill_sb(struct super_block *sb) {
struct cgroupfs_root *root = sb->s_fs_info; struct cgroupfs_root *root = sb->s_fs_info;
struct cgroup *cgrp = &root->top_cgroup; struct cgroup *cgrp = &root->top_cgroup;
struct cgrp_cset_link *link, *tmp_link;
int ret; int ret;
struct cg_cgroup_link *link;
struct cg_cgroup_link *saved_link;
BUG_ON(!root); BUG_ON(!root);
...@@ -1740,15 +1745,14 @@ static void cgroup_kill_sb(struct super_block *sb) { ...@@ -1740,15 +1745,14 @@ static void cgroup_kill_sb(struct super_block *sb) {
BUG_ON(ret); BUG_ON(ret);
/* /*
* Release all the links from css_sets to this hierarchy's * Release all the links from cset_links to this hierarchy's
* root cgroup * root cgroup
*/ */
write_lock(&css_set_lock); write_lock(&css_set_lock);
list_for_each_entry_safe(link, saved_link, &cgrp->css_sets, list_for_each_entry_safe(link, tmp_link, &cgrp->cset_links, cset_link) {
cgrp_link_list) { list_del(&link->cset_link);
list_del(&link->cg_link_list); list_del(&link->cgrp_link);
list_del(&link->cgrp_link_list);
kfree(link); kfree(link);
} }
write_unlock(&css_set_lock); write_unlock(&css_set_lock);
...@@ -2908,12 +2912,11 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) ...@@ -2908,12 +2912,11 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
int cgroup_task_count(const struct cgroup *cgrp) int cgroup_task_count(const struct cgroup *cgrp)
{ {
int count = 0; int count = 0;
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
read_lock(&css_set_lock); read_lock(&css_set_lock);
list_for_each_entry(link, &cgrp->css_sets, cgrp_link_list) { list_for_each_entry(link, &cgrp->cset_links, cset_link)
count += atomic_read(&link->cg->refcount); count += atomic_read(&link->cset->refcount);
}
read_unlock(&css_set_lock); read_unlock(&css_set_lock);
return count; return count;
} }
...@@ -2922,24 +2925,23 @@ int cgroup_task_count(const struct cgroup *cgrp) ...@@ -2922,24 +2925,23 @@ int cgroup_task_count(const struct cgroup *cgrp)
* Advance a list_head iterator. The iterator should be positioned at * Advance a list_head iterator. The iterator should be positioned at
* the start of a css_set * the start of a css_set
*/ */
static void cgroup_advance_iter(struct cgroup *cgrp, static void cgroup_advance_iter(struct cgroup *cgrp, struct cgroup_iter *it)
struct cgroup_iter *it)
{ {
struct list_head *l = it->cg_link; struct list_head *l = it->cset_link;
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
struct css_set *cset; struct css_set *cset;
/* Advance to the next non-empty css_set */ /* Advance to the next non-empty css_set */
do { do {
l = l->next; l = l->next;
if (l == &cgrp->css_sets) { if (l == &cgrp->cset_links) {
it->cg_link = NULL; it->cset_link = NULL;
return; return;
} }
link = list_entry(l, struct cg_cgroup_link, cgrp_link_list); link = list_entry(l, struct cgrp_cset_link, cset_link);
cset = link->cg; cset = link->cset;
} while (list_empty(&cset->tasks)); } while (list_empty(&cset->tasks));
it->cg_link = l; it->cset_link = l;
it->task = cset->tasks.next; it->task = cset->tasks.next;
} }
...@@ -3160,7 +3162,7 @@ void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it) ...@@ -3160,7 +3162,7 @@ void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it)
cgroup_enable_task_cg_lists(); cgroup_enable_task_cg_lists();
read_lock(&css_set_lock); read_lock(&css_set_lock);
it->cg_link = &cgrp->css_sets; it->cset_link = &cgrp->cset_links;
cgroup_advance_iter(cgrp, it); cgroup_advance_iter(cgrp, it);
} }
...@@ -3169,16 +3171,16 @@ struct task_struct *cgroup_iter_next(struct cgroup *cgrp, ...@@ -3169,16 +3171,16 @@ struct task_struct *cgroup_iter_next(struct cgroup *cgrp,
{ {
struct task_struct *res; struct task_struct *res;
struct list_head *l = it->task; struct list_head *l = it->task;
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
/* If the iterator cg is NULL, we have no tasks */ /* If the iterator cg is NULL, we have no tasks */
if (!it->cg_link) if (!it->cset_link)
return NULL; return NULL;
res = list_entry(l, struct task_struct, cg_list); res = list_entry(l, struct task_struct, cg_list);
/* Advance iterator to find next entry */ /* Advance iterator to find next entry */
l = l->next; l = l->next;
link = list_entry(it->cg_link, struct cg_cgroup_link, cgrp_link_list); link = list_entry(it->cset_link, struct cgrp_cset_link, cset_link);
if (l == &link->cg->tasks) { if (l == &link->cset->tasks) {
/* We reached the end of this task list - move on to /* We reached the end of this task list - move on to
* the next cg_cgroup_link */ * the next cg_cgroup_link */
cgroup_advance_iter(cgrp, it); cgroup_advance_iter(cgrp, it);
...@@ -4625,7 +4627,7 @@ EXPORT_SYMBOL_GPL(cgroup_load_subsys); ...@@ -4625,7 +4627,7 @@ EXPORT_SYMBOL_GPL(cgroup_load_subsys);
*/ */
void cgroup_unload_subsys(struct cgroup_subsys *ss) void cgroup_unload_subsys(struct cgroup_subsys *ss)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
BUG_ON(ss->module == NULL); BUG_ON(ss->module == NULL);
...@@ -4654,8 +4656,8 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss) ...@@ -4654,8 +4656,8 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
* in loading, we need to pay our respects to the hashtable gods. * in loading, we need to pay our respects to the hashtable gods.
*/ */
write_lock(&css_set_lock); write_lock(&css_set_lock);
list_for_each_entry(link, &dummytop->css_sets, cgrp_link_list) { list_for_each_entry(link, &dummytop->cset_links, cset_link) {
struct css_set *cset = link->cg; struct css_set *cset = link->cset;
unsigned long key; unsigned long key;
hash_del(&cset->hlist); hash_del(&cset->hlist);
...@@ -4688,7 +4690,7 @@ int __init cgroup_init_early(void) ...@@ -4688,7 +4690,7 @@ int __init cgroup_init_early(void)
{ {
int i; int i;
atomic_set(&init_css_set.refcount, 1); atomic_set(&init_css_set.refcount, 1);
INIT_LIST_HEAD(&init_css_set.cg_links); INIT_LIST_HEAD(&init_css_set.cgrp_links);
INIT_LIST_HEAD(&init_css_set.tasks); INIT_LIST_HEAD(&init_css_set.tasks);
INIT_HLIST_NODE(&init_css_set.hlist); INIT_HLIST_NODE(&init_css_set.hlist);
css_set_count = 1; css_set_count = 1;
...@@ -4696,12 +4698,10 @@ int __init cgroup_init_early(void) ...@@ -4696,12 +4698,10 @@ int __init cgroup_init_early(void)
root_count = 1; root_count = 1;
init_task.cgroups = &init_css_set; init_task.cgroups = &init_css_set;
init_css_set_link.cg = &init_css_set; init_cgrp_cset_link.cset = &init_css_set;
init_css_set_link.cgrp = dummytop; init_cgrp_cset_link.cgrp = dummytop;
list_add(&init_css_set_link.cgrp_link_list, list_add(&init_cgrp_cset_link.cset_link, &rootnode.top_cgroup.cset_links);
&rootnode.top_cgroup.css_sets); list_add(&init_cgrp_cset_link.cgrp_link, &init_css_set.cgrp_links);
list_add(&init_css_set_link.cg_link_list,
&init_css_set.cg_links);
for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
struct cgroup_subsys *ss = subsys[i]; struct cgroup_subsys *ss = subsys[i];
...@@ -5454,13 +5454,13 @@ static int current_css_set_cg_links_read(struct cgroup *cont, ...@@ -5454,13 +5454,13 @@ static int current_css_set_cg_links_read(struct cgroup *cont,
struct cftype *cft, struct cftype *cft,
struct seq_file *seq) struct seq_file *seq)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
struct css_set *cset; struct css_set *cset;
read_lock(&css_set_lock); read_lock(&css_set_lock);
rcu_read_lock(); rcu_read_lock();
cset = rcu_dereference(current->cgroups); cset = rcu_dereference(current->cgroups);
list_for_each_entry(link, &cset->cg_links, cg_link_list) { list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
struct cgroup *c = link->cgrp; struct cgroup *c = link->cgrp;
const char *name; const char *name;
...@@ -5481,11 +5481,11 @@ static int cgroup_css_links_read(struct cgroup *cont, ...@@ -5481,11 +5481,11 @@ static int cgroup_css_links_read(struct cgroup *cont,
struct cftype *cft, struct cftype *cft,
struct seq_file *seq) struct seq_file *seq)
{ {
struct cg_cgroup_link *link; struct cgrp_cset_link *link;
read_lock(&css_set_lock); read_lock(&css_set_lock);
list_for_each_entry(link, &cont->css_sets, cgrp_link_list) { list_for_each_entry(link, &cont->cset_links, cset_link) {
struct css_set *cset = link->cg; struct css_set *cset = link->cset;
struct task_struct *task; struct task_struct *task;
int count = 0; int count = 0;
seq_printf(seq, "css_set %p\n", cset); seq_printf(seq, "css_set %p\n", cset);
......
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