aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2008-04-29 04:00:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:10 -0400
commit28fd5dfc12bde391981dfdcf20755952b6e916af (patch)
treece0637c3f8c04d802b467cd518a9d0c076f1eeea /kernel
parente8d55fdeb882cfcb5e8db5a5ce16edfba78aafc5 (diff)
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: Li Zefan <lizf@cn.fujitsu.com> Reviewed-by: Paul 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b893c8c94858..aeceb8868981 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -242,7 +242,6 @@ static void unlink_css_set(struct css_set *cg)
242{ 242{
243 write_lock(&css_set_lock); 243 write_lock(&css_set_lock);
244 hlist_del(&cg->hlist); 244 hlist_del(&cg->hlist);
245 list_del(&cg->list);
246 css_set_count--; 245 css_set_count--;
247 while (!list_empty(&cg->cg_links)) { 246 while (!list_empty(&cg->cg_links)) {
248 struct cg_cgroup_link *link; 247 struct cg_cgroup_link *link;
@@ -477,8 +476,6 @@ static struct css_set *find_css_set(
477 476
478 BUG_ON(!list_empty(&tmp_cg_links)); 477 BUG_ON(!list_empty(&tmp_cg_links));
479 478
480 /* Link this cgroup group into the list */
481 list_add(&res->list, &init_css_set.list);
482 css_set_count++; 479 css_set_count++;
483 480
484 /* Add this cgroup group to the hash table */ 481 /* Add this cgroup group to the hash table */
@@ -963,7 +960,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
963 int ret = 0; 960 int ret = 0;
964 struct super_block *sb; 961 struct super_block *sb;
965 struct cgroupfs_root *root; 962 struct cgroupfs_root *root;
966 struct list_head tmp_cg_links, *l; 963 struct list_head tmp_cg_links;
967 INIT_LIST_HEAD(&tmp_cg_links); 964 INIT_LIST_HEAD(&tmp_cg_links);
968 965
969 /* First find the desired set of subsystems */ 966 /* First find the desired set of subsystems */
@@ -1005,6 +1002,7 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
1005 /* New superblock */ 1002 /* New superblock */
1006 struct cgroup *cgrp = &root->top_cgroup; 1003 struct cgroup *cgrp = &root->top_cgroup;
1007 struct inode *inode; 1004 struct inode *inode;
1005 int i;
1008 1006
1009 BUG_ON(sb->s_root != NULL); 1007 BUG_ON(sb->s_root != NULL);
1010 1008
@@ -1049,22 +1047,25 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
1049 /* Link the top cgroup in this hierarchy into all 1047 /* Link the top cgroup in this hierarchy into all
1050 * the css_set objects */ 1048 * the css_set objects */
1051 write_lock(&css_set_lock); 1049 write_lock(&css_set_lock);
1052 l = &init_css_set.list; 1050 for (i = 0; i < CSS_SET_TABLE_SIZE; i++) {
1053 do { 1051 struct hlist_head *hhead = &css_set_table[i];
1052 struct hlist_node *node;
1054 struct css_set *cg; 1053 struct css_set *cg;
1055 struct cg_cgroup_link *link; 1054
1056 cg = list_entry(l, struct css_set, list); 1055 hlist_for_each_entry(cg, node, hhead, hlist) {
1057 BUG_ON(list_empty(&tmp_cg_links)); 1056 struct cg_cgroup_link *link;
1058 link = list_entry(tmp_cg_links.next, 1057
1059 struct cg_cgroup_link, 1058 BUG_ON(list_empty(&tmp_cg_links));
1060 cgrp_link_list); 1059 link = list_entry(tmp_cg_links.next,
1061 list_del(&link->cgrp_link_list); 1060 struct cg_cgroup_link,
1062 link->cg = cg; 1061 cgrp_link_list);
1063 list_add(&link->cgrp_link_list, 1062 list_del(&link->cgrp_link_list);
1064 &root->top_cgroup.css_sets); 1063 link->cg = cg;
1065 list_add(&link->cg_link_list, &cg->cg_links); 1064 list_add(&link->cgrp_link_list,
1066 l = l->next; 1065 &root->top_cgroup.css_sets);
1067 } while (l != &init_css_set.list); 1066 list_add(&link->cg_link_list, &cg->cg_links);
1067 }
1068 }
1068 write_unlock(&css_set_lock); 1069 write_unlock(&css_set_lock);
1069 1070
1070 free_cg_links(&tmp_cg_links); 1071 free_cg_links(&tmp_cg_links);
@@ -2514,7 +2515,6 @@ int __init cgroup_init_early(void)
2514 int i; 2515 int i;
2515 kref_init(&init_css_set.ref); 2516 kref_init(&init_css_set.ref);
2516 kref_get(&init_css_set.ref); 2517 kref_get(&init_css_set.ref);
2517 INIT_LIST_HEAD(&init_css_set.list);
2518 INIT_LIST_HEAD(&init_css_set.cg_links); 2518 INIT_LIST_HEAD(&init_css_set.cg_links);
2519 INIT_LIST_HEAD(&init_css_set.tasks); 2519 INIT_LIST_HEAD(&init_css_set.tasks);
2520 INIT_HLIST_NODE(&init_css_set.hlist); 2520 INIT_HLIST_NODE(&init_css_set.hlist);