Commit 28fd5dfc authored by Li Zefan's avatar Li Zefan Committed by Linus Torvalds

cgroups: remove the css_set linked-list

Now we can run through the hash table instead of running through the
linked-list.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Reviewed-by: default avatarPaul Menage <menage@google.com>
Cc: Balbir Singh <balbir@linux.vnet.ibm.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e8d55fde
...@@ -149,12 +149,6 @@ struct css_set { ...@@ -149,12 +149,6 @@ struct css_set {
/* Reference count */ /* Reference count */
struct kref ref; struct kref ref;
/*
* List running through all cgroup groups. Protected by
* css_set_lock
*/
struct list_head list;
/* /*
* List running through all cgroup groups in the same hash * List running through all cgroup groups in the same hash
* slot. Protected by css_set_lock * slot. Protected by css_set_lock
......
...@@ -242,7 +242,6 @@ static void unlink_css_set(struct css_set *cg) ...@@ -242,7 +242,6 @@ static void unlink_css_set(struct css_set *cg)
{ {
write_lock(&css_set_lock); write_lock(&css_set_lock);
hlist_del(&cg->hlist); hlist_del(&cg->hlist);
list_del(&cg->list);
css_set_count--; css_set_count--;
while (!list_empty(&cg->cg_links)) { while (!list_empty(&cg->cg_links)) {
struct cg_cgroup_link *link; struct cg_cgroup_link *link;
...@@ -477,8 +476,6 @@ static struct css_set *find_css_set( ...@@ -477,8 +476,6 @@ static struct css_set *find_css_set(
BUG_ON(!list_empty(&tmp_cg_links)); BUG_ON(!list_empty(&tmp_cg_links));
/* Link this cgroup group into the list */
list_add(&res->list, &init_css_set.list);
css_set_count++; css_set_count++;
/* Add this cgroup group to the hash table */ /* Add this cgroup group to the hash table */
...@@ -963,7 +960,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type, ...@@ -963,7 +960,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
int ret = 0; int ret = 0;
struct super_block *sb; struct super_block *sb;
struct cgroupfs_root *root; struct cgroupfs_root *root;
struct list_head tmp_cg_links, *l; struct list_head tmp_cg_links;
INIT_LIST_HEAD(&tmp_cg_links); INIT_LIST_HEAD(&tmp_cg_links);
/* First find the desired set of subsystems */ /* First find the desired set of subsystems */
...@@ -1005,6 +1002,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type, ...@@ -1005,6 +1002,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
/* New superblock */ /* New superblock */
struct cgroup *cgrp = &root->top_cgroup; struct cgroup *cgrp = &root->top_cgroup;
struct inode *inode; struct inode *inode;
int i;
BUG_ON(sb->s_root != NULL); BUG_ON(sb->s_root != NULL);
...@@ -1049,22 +1047,25 @@ static int cgroup_get_sb(struct file_system_type *fs_type, ...@@ -1049,22 +1047,25 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
/* Link the top cgroup in this hierarchy into all /* Link the top cgroup in this hierarchy into all
* the css_set objects */ * the css_set objects */
write_lock(&css_set_lock); write_lock(&css_set_lock);
l = &init_css_set.list; for (i = 0; i < CSS_SET_TABLE_SIZE; i++) {
do { struct hlist_head *hhead = &css_set_table[i];
struct hlist_node *node;
struct css_set *cg; struct css_set *cg;
struct cg_cgroup_link *link;
cg = list_entry(l, struct css_set, list); hlist_for_each_entry(cg, node, hhead, hlist) {
BUG_ON(list_empty(&tmp_cg_links)); struct cg_cgroup_link *link;
link = list_entry(tmp_cg_links.next,
struct cg_cgroup_link, BUG_ON(list_empty(&tmp_cg_links));
cgrp_link_list); link = list_entry(tmp_cg_links.next,
list_del(&link->cgrp_link_list); struct cg_cgroup_link,
link->cg = cg; cgrp_link_list);
list_add(&link->cgrp_link_list, list_del(&link->cgrp_link_list);
&root->top_cgroup.css_sets); link->cg = cg;
list_add(&link->cg_link_list, &cg->cg_links); list_add(&link->cgrp_link_list,
l = l->next; &root->top_cgroup.css_sets);
} while (l != &init_css_set.list); list_add(&link->cg_link_list, &cg->cg_links);
}
}
write_unlock(&css_set_lock); write_unlock(&css_set_lock);
free_cg_links(&tmp_cg_links); free_cg_links(&tmp_cg_links);
...@@ -2514,7 +2515,6 @@ int __init cgroup_init_early(void) ...@@ -2514,7 +2515,6 @@ int __init cgroup_init_early(void)
int i; int i;
kref_init(&init_css_set.ref); kref_init(&init_css_set.ref);
kref_get(&init_css_set.ref); kref_get(&init_css_set.ref);
INIT_LIST_HEAD(&init_css_set.list);
INIT_LIST_HEAD(&init_css_set.cg_links); INIT_LIST_HEAD(&init_css_set.cg_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);
......
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