aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-06-13 00:04:50 -0400
committerTejun Heo <tj@kernel.org>2013-06-13 13:55:17 -0400
commit69d0206c793a17431eacee2694ee7a4b25df76b7 (patch)
treef242ce2e576886a18bec4ff6adc9cd7ba9bbe722 /kernel/cgroup.c
parent5abb8855734fd7b3fa7f91c13916d0e35d99763c (diff)
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: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c226
1 files changed, 113 insertions, 113 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 1f5a4e101ed1..ef97bd0cd546 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -315,20 +315,24 @@ static void cgroup_release_agent(struct work_struct *work);
315static DECLARE_WORK(release_agent_work, cgroup_release_agent); 315static DECLARE_WORK(release_agent_work, cgroup_release_agent);
316static void check_for_release(struct cgroup *cgrp); 316static void check_for_release(struct cgroup *cgrp);
317 317
318/* Link structure for associating css_set objects with cgroups */ 318/*
319struct cg_cgroup_link { 319 * A cgroup can be associated with multiple css_sets as different tasks may
320 /* 320 * belong to different cgroups on different hierarchies. In the other
321 * List running through cg_cgroup_links associated with a 321 * direction, a css_set is naturally associated with multiple cgroups.
322 * cgroup, anchored on cgroup->css_sets 322 * This M:N relationship is represented by the following link structure
323 */ 323 * which exists for each association and allows traversing the associations
324 struct list_head cgrp_link_list; 324 * from both sides.
325 struct cgroup *cgrp; 325 */
326 /* 326struct cgrp_cset_link {
327 * List running through cg_cgroup_links pointing at a 327 /* the cgroup and css_set this link associates */
328 * single css_set object, anchored on css_set->cg_links 328 struct cgroup *cgrp;
329 */ 329 struct css_set *cset;
330 struct list_head cg_link_list; 330
331 struct css_set *cg; 331 /* list of cgrp_cset_links anchored at cgrp->cset_links */
332 struct list_head cset_link;
333
334 /* list of cgrp_cset_links anchored at css_set->cgrp_links */
335 struct list_head cgrp_link;
332}; 336};
333 337
334/* The default css_set - used by init and its children prior to any 338/* The default css_set - used by init and its children prior to any
@@ -339,7 +343,7 @@ struct cg_cgroup_link {
339 */ 343 */
340 344
341static struct css_set init_css_set; 345static struct css_set init_css_set;
342static struct cg_cgroup_link init_css_set_link; 346static struct cgrp_cset_link init_cgrp_cset_link;
343 347
344static int cgroup_init_idr(struct cgroup_subsys *ss, 348static int cgroup_init_idr(struct cgroup_subsys *ss,
345 struct cgroup_subsys_state *css); 349 struct cgroup_subsys_state *css);
@@ -378,8 +382,7 @@ static int use_task_css_set_links __read_mostly;
378 382
379static void __put_css_set(struct css_set *cset, int taskexit) 383static void __put_css_set(struct css_set *cset, int taskexit)
380{ 384{
381 struct cg_cgroup_link *link; 385 struct cgrp_cset_link *link, *tmp_link;
382 struct cg_cgroup_link *saved_link;
383 386
384 /* 387 /*
385 * Ensure that the refcount doesn't hit zero while any readers 388 * 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 hash_del(&cset->hlist); 401 hash_del(&cset->hlist);
399 css_set_count--; 402 css_set_count--;
400 403
401 list_for_each_entry_safe(link, saved_link, &cset->cg_links, 404 list_for_each_entry_safe(link, tmp_link, &cset->cgrp_links, cgrp_link) {
402 cg_link_list) {
403 struct cgroup *cgrp = link->cgrp; 405 struct cgroup *cgrp = link->cgrp;
404 406
405 list_del(&link->cg_link_list); 407 list_del(&link->cset_link);
406 list_del(&link->cgrp_link_list); 408 list_del(&link->cgrp_link);
407 409
408 /* 410 /*
409 * We may not be holding cgroup_mutex, and if cgrp->count is 411 * 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 * candidates. 477 * candidates.
476 */ 478 */
477 479
478 l1 = &cset->cg_links; 480 l1 = &cset->cgrp_links;
479 l2 = &old_cset->cg_links; 481 l2 = &old_cset->cgrp_links;
480 while (1) { 482 while (1) {
481 struct cg_cgroup_link *cgl1, *cgl2; 483 struct cgrp_cset_link *link1, *link2;
482 struct cgroup *cgrp1, *cgrp2; 484 struct cgroup *cgrp1, *cgrp2;
483 485
484 l1 = l1->next; 486 l1 = l1->next;
485 l2 = l2->next; 487 l2 = l2->next;
486 /* See if we reached the end - both lists are equal length. */ 488 /* See if we reached the end - both lists are equal length. */
487 if (l1 == &cset->cg_links) { 489 if (l1 == &cset->cgrp_links) {
488 BUG_ON(l2 != &old_cset->cg_links); 490 BUG_ON(l2 != &old_cset->cgrp_links);
489 break; 491 break;
490 } else { 492 } else {
491 BUG_ON(l2 == &old_cset->cg_links); 493 BUG_ON(l2 == &old_cset->cgrp_links);
492 } 494 }
493 /* Locate the cgroups associated with these links. */ 495 /* Locate the cgroups associated with these links. */
494 cgl1 = list_entry(l1, struct cg_cgroup_link, cg_link_list); 496 link1 = list_entry(l1, struct cgrp_cset_link, cgrp_link);
495 cgl2 = list_entry(l2, struct cg_cgroup_link, cg_link_list); 497 link2 = list_entry(l2, struct cgrp_cset_link, cgrp_link);
496 cgrp1 = cgl1->cgrp; 498 cgrp1 = link1->cgrp;
497 cgrp2 = cgl2->cgrp; 499 cgrp2 = link2->cgrp;
498 /* Hierarchies should be linked in the same order. */ 500 /* Hierarchies should be linked in the same order. */
499 BUG_ON(cgrp1->root != cgrp2->root); 501 BUG_ON(cgrp1->root != cgrp2->root);
500 502
@@ -569,61 +571,64 @@ static struct css_set *find_existing_css_set(struct css_set *old_cset,
569 return NULL; 571 return NULL;
570} 572}
571 573
572static void free_cg_links(struct list_head *tmp) 574static void free_cgrp_cset_links(struct list_head *links_to_free)
573{ 575{
574 struct cg_cgroup_link *link; 576 struct cgrp_cset_link *link, *tmp_link;
575 struct cg_cgroup_link *saved_link;
576 577
577 list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) { 578 list_for_each_entry_safe(link, tmp_link, links_to_free, cset_link) {
578 list_del(&link->cgrp_link_list); 579 list_del(&link->cset_link);
579 kfree(link); 580 kfree(link);
580 } 581 }
581} 582}
582 583
583/* 584/**
584 * allocate_cg_links() allocates "count" cg_cgroup_link structures 585 * allocate_cgrp_cset_links - allocate cgrp_cset_links
585 * and chains them on tmp through their cgrp_link_list fields. Returns 0 on 586 * @count: the number of links to allocate
586 * success or a negative error 587 * @tmp_links: list_head the allocated links are put on
588 *
589 * Allocate @count cgrp_cset_link structures and chain them on @tmp_links
590 * through ->cset_link. Returns 0 on success or -errno.
587 */ 591 */
588static int allocate_cg_links(int count, struct list_head *tmp) 592static int allocate_cgrp_cset_links(int count, struct list_head *tmp_links)
589{ 593{
590 struct cg_cgroup_link *link; 594 struct cgrp_cset_link *link;
591 int i; 595 int i;
592 INIT_LIST_HEAD(tmp); 596
597 INIT_LIST_HEAD(tmp_links);
598
593 for (i = 0; i < count; i++) { 599 for (i = 0; i < count; i++) {
594 link = kmalloc(sizeof(*link), GFP_KERNEL); 600 link = kmalloc(sizeof(*link), GFP_KERNEL);
595 if (!link) { 601 if (!link) {
596 free_cg_links(tmp); 602 free_cgrp_cset_links(tmp_links);
597 return -ENOMEM; 603 return -ENOMEM;
598 } 604 }
599 list_add(&link->cgrp_link_list, tmp); 605 list_add(&link->cset_link, tmp_links);
600 } 606 }
601 return 0; 607 return 0;
602} 608}
603 609
604/** 610/**
605 * link_css_set - a helper function to link a css_set to a cgroup 611 * link_css_set - a helper function to link a css_set to a cgroup
606 * @tmp_cg_links: cg_cgroup_link objects allocated by allocate_cg_links() 612 * @tmp_links: cgrp_cset_link objects allocated by allocate_cgrp_cset_links()
607 * @cset: the css_set to be linked 613 * @cset: the css_set to be linked
608 * @cgrp: the destination cgroup 614 * @cgrp: the destination cgroup
609 */ 615 */
610static void link_css_set(struct list_head *tmp_cg_links, 616static void link_css_set(struct list_head *tmp_links, struct css_set *cset,
611 struct css_set *cset, struct cgroup *cgrp) 617 struct cgroup *cgrp)
612{ 618{
613 struct cg_cgroup_link *link; 619 struct cgrp_cset_link *link;
614 620
615 BUG_ON(list_empty(tmp_cg_links)); 621 BUG_ON(list_empty(tmp_links));
616 link = list_first_entry(tmp_cg_links, struct cg_cgroup_link, 622 link = list_first_entry(tmp_links, struct cgrp_cset_link, cset_link);
617 cgrp_link_list); 623 link->cset = cset;
618 link->cg = cset;
619 link->cgrp = cgrp; 624 link->cgrp = cgrp;
620 atomic_inc(&cgrp->count); 625 atomic_inc(&cgrp->count);
621 list_move(&link->cgrp_link_list, &cgrp->css_sets); 626 list_move(&link->cset_link, &cgrp->cset_links);
622 /* 627 /*
623 * Always add links to the tail of the list so that the list 628 * Always add links to the tail of the list so that the list
624 * is sorted by order of hierarchy creation 629 * is sorted by order of hierarchy creation
625 */ 630 */
626 list_add_tail(&link->cg_link_list, &cset->cg_links); 631 list_add_tail(&link->cgrp_link, &cset->cgrp_links);
627} 632}
628 633
629/* 634/*
@@ -638,10 +643,8 @@ static struct css_set *find_css_set(struct css_set *old_cset,
638{ 643{
639 struct css_set *cset; 644 struct css_set *cset;
640 struct cgroup_subsys_state *template[CGROUP_SUBSYS_COUNT]; 645 struct cgroup_subsys_state *template[CGROUP_SUBSYS_COUNT];
641 646 struct list_head tmp_links;
642 struct list_head tmp_cg_links; 647 struct cgrp_cset_link *link;
643
644 struct cg_cgroup_link *link;
645 unsigned long key; 648 unsigned long key;
646 649
647 /* First see if we already have a cgroup group that matches 650 /* 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 if (!cset) 662 if (!cset)
660 return NULL; 663 return NULL;
661 664
662 /* Allocate all the cg_cgroup_link objects that we'll need */ 665 /* Allocate all the cgrp_cset_link objects that we'll need */
663 if (allocate_cg_links(root_count, &tmp_cg_links) < 0) { 666 if (allocate_cgrp_cset_links(root_count, &tmp_links) < 0) {
664 kfree(cset); 667 kfree(cset);
665 return NULL; 668 return NULL;
666 } 669 }
667 670
668 atomic_set(&cset->refcount, 1); 671 atomic_set(&cset->refcount, 1);
669 INIT_LIST_HEAD(&cset->cg_links); 672 INIT_LIST_HEAD(&cset->cgrp_links);
670 INIT_LIST_HEAD(&cset->tasks); 673 INIT_LIST_HEAD(&cset->tasks);
671 INIT_HLIST_NODE(&cset->hlist); 674 INIT_HLIST_NODE(&cset->hlist);
672 675
@@ -676,14 +679,15 @@ static struct css_set *find_css_set(struct css_set *old_cset,
676 679
677 write_lock(&css_set_lock); 680 write_lock(&css_set_lock);
678 /* Add reference counts and links from the new css_set. */ 681 /* Add reference counts and links from the new css_set. */
679 list_for_each_entry(link, &old_cset->cg_links, cg_link_list) { 682 list_for_each_entry(link, &old_cset->cgrp_links, cgrp_link) {
680 struct cgroup *c = link->cgrp; 683 struct cgroup *c = link->cgrp;
684
681 if (c->root == cgrp->root) 685 if (c->root == cgrp->root)
682 c = cgrp; 686 c = cgrp;
683 link_css_set(&tmp_cg_links, cset, c); 687 link_css_set(&tmp_links, cset, c);
684 } 688 }
685 689
686 BUG_ON(!list_empty(&tmp_cg_links)); 690 BUG_ON(!list_empty(&tmp_links));
687 691
688 css_set_count++; 692 css_set_count++;
689 693
@@ -717,9 +721,11 @@ static struct cgroup *task_cgroup_from_root(struct task_struct *task,
717 if (cset == &init_css_set) { 721 if (cset == &init_css_set) {
718 res = &root->top_cgroup; 722 res = &root->top_cgroup;
719 } else { 723 } else {
720 struct cg_cgroup_link *link; 724 struct cgrp_cset_link *link;
721 list_for_each_entry(link, &cset->cg_links, cg_link_list) { 725
726 list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
722 struct cgroup *c = link->cgrp; 727 struct cgroup *c = link->cgrp;
728
723 if (c->root == root) { 729 if (c->root == root) {
724 res = c; 730 res = c;
725 break; 731 break;
@@ -1405,7 +1411,7 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
1405 INIT_LIST_HEAD(&cgrp->sibling); 1411 INIT_LIST_HEAD(&cgrp->sibling);
1406 INIT_LIST_HEAD(&cgrp->children); 1412 INIT_LIST_HEAD(&cgrp->children);
1407 INIT_LIST_HEAD(&cgrp->files); 1413 INIT_LIST_HEAD(&cgrp->files);
1408 INIT_LIST_HEAD(&cgrp->css_sets); 1414 INIT_LIST_HEAD(&cgrp->cset_links);
1409 INIT_LIST_HEAD(&cgrp->allcg_node); 1415 INIT_LIST_HEAD(&cgrp->allcg_node);
1410 INIT_LIST_HEAD(&cgrp->release_list); 1416 INIT_LIST_HEAD(&cgrp->release_list);
1411 INIT_LIST_HEAD(&cgrp->pidlists); 1417 INIT_LIST_HEAD(&cgrp->pidlists);
@@ -1604,7 +1610,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1604 BUG_ON(!root); 1610 BUG_ON(!root);
1605 if (root == opts.new_root) { 1611 if (root == opts.new_root) {
1606 /* We used the new root structure, so this is a new hierarchy */ 1612 /* We used the new root structure, so this is a new hierarchy */
1607 struct list_head tmp_cg_links; 1613 struct list_head tmp_links;
1608 struct cgroup *root_cgrp = &root->top_cgroup; 1614 struct cgroup *root_cgrp = &root->top_cgroup;
1609 struct cgroupfs_root *existing_root; 1615 struct cgroupfs_root *existing_root;
1610 const struct cred *cred; 1616 const struct cred *cred;
@@ -1636,7 +1642,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1636 * that's us. The worst that can happen is that we 1642 * that's us. The worst that can happen is that we
1637 * have some link structures left over 1643 * have some link structures left over
1638 */ 1644 */
1639 ret = allocate_cg_links(css_set_count, &tmp_cg_links); 1645 ret = allocate_cgrp_cset_links(css_set_count, &tmp_links);
1640 if (ret) 1646 if (ret)
1641 goto unlock_drop; 1647 goto unlock_drop;
1642 1648
@@ -1646,7 +1652,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1646 1652
1647 ret = rebind_subsystems(root, root->subsys_mask); 1653 ret = rebind_subsystems(root, root->subsys_mask);
1648 if (ret == -EBUSY) { 1654 if (ret == -EBUSY) {
1649 free_cg_links(&tmp_cg_links); 1655 free_cgrp_cset_links(&tmp_links);
1650 goto unlock_drop; 1656 goto unlock_drop;
1651 } 1657 }
1652 /* 1658 /*
@@ -1668,10 +1674,10 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1668 * the css_set objects */ 1674 * the css_set objects */
1669 write_lock(&css_set_lock); 1675 write_lock(&css_set_lock);
1670 hash_for_each(css_set_table, i, cset, hlist) 1676 hash_for_each(css_set_table, i, cset, hlist)
1671 link_css_set(&tmp_cg_links, cset, root_cgrp); 1677 link_css_set(&tmp_links, cset, root_cgrp);
1672 write_unlock(&css_set_lock); 1678 write_unlock(&css_set_lock);
1673 1679
1674 free_cg_links(&tmp_cg_links); 1680 free_cgrp_cset_links(&tmp_links);
1675 1681
1676 BUG_ON(!list_empty(&root_cgrp->children)); 1682 BUG_ON(!list_empty(&root_cgrp->children));
1677 BUG_ON(root->number_of_cgroups != 1); 1683 BUG_ON(root->number_of_cgroups != 1);
@@ -1722,9 +1728,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1722static void cgroup_kill_sb(struct super_block *sb) { 1728static void cgroup_kill_sb(struct super_block *sb) {
1723 struct cgroupfs_root *root = sb->s_fs_info; 1729 struct cgroupfs_root *root = sb->s_fs_info;
1724 struct cgroup *cgrp = &root->top_cgroup; 1730 struct cgroup *cgrp = &root->top_cgroup;
1731 struct cgrp_cset_link *link, *tmp_link;
1725 int ret; 1732 int ret;
1726 struct cg_cgroup_link *link;
1727 struct cg_cgroup_link *saved_link;
1728 1733
1729 BUG_ON(!root); 1734 BUG_ON(!root);
1730 1735
@@ -1740,15 +1745,14 @@ static void cgroup_kill_sb(struct super_block *sb) {
1740 BUG_ON(ret); 1745 BUG_ON(ret);
1741 1746
1742 /* 1747 /*
1743 * Release all the links from css_sets to this hierarchy's 1748 * Release all the links from cset_links to this hierarchy's
1744 * root cgroup 1749 * root cgroup
1745 */ 1750 */
1746 write_lock(&css_set_lock); 1751 write_lock(&css_set_lock);
1747 1752
1748 list_for_each_entry_safe(link, saved_link, &cgrp->css_sets, 1753 list_for_each_entry_safe(link, tmp_link, &cgrp->cset_links, cset_link) {
1749 cgrp_link_list) { 1754 list_del(&link->cset_link);
1750 list_del(&link->cg_link_list); 1755 list_del(&link->cgrp_link);
1751 list_del(&link->cgrp_link_list);
1752 kfree(link); 1756 kfree(link);
1753 } 1757 }
1754 write_unlock(&css_set_lock); 1758 write_unlock(&css_set_lock);
@@ -2908,12 +2912,11 @@ int cgroup_rm_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
2908int cgroup_task_count(const struct cgroup *cgrp) 2912int cgroup_task_count(const struct cgroup *cgrp)
2909{ 2913{
2910 int count = 0; 2914 int count = 0;
2911 struct cg_cgroup_link *link; 2915 struct cgrp_cset_link *link;
2912 2916
2913 read_lock(&css_set_lock); 2917 read_lock(&css_set_lock);
2914 list_for_each_entry(link, &cgrp->css_sets, cgrp_link_list) { 2918 list_for_each_entry(link, &cgrp->cset_links, cset_link)
2915 count += atomic_read(&link->cg->refcount); 2919 count += atomic_read(&link->cset->refcount);
2916 }
2917 read_unlock(&css_set_lock); 2920 read_unlock(&css_set_lock);
2918 return count; 2921 return count;
2919} 2922}
@@ -2922,24 +2925,23 @@ int cgroup_task_count(const struct cgroup *cgrp)
2922 * Advance a list_head iterator. The iterator should be positioned at 2925 * Advance a list_head iterator. The iterator should be positioned at
2923 * the start of a css_set 2926 * the start of a css_set
2924 */ 2927 */
2925static void cgroup_advance_iter(struct cgroup *cgrp, 2928static void cgroup_advance_iter(struct cgroup *cgrp, struct cgroup_iter *it)
2926 struct cgroup_iter *it)
2927{ 2929{
2928 struct list_head *l = it->cg_link; 2930 struct list_head *l = it->cset_link;
2929 struct cg_cgroup_link *link; 2931 struct cgrp_cset_link *link;
2930 struct css_set *cset; 2932 struct css_set *cset;
2931 2933
2932 /* Advance to the next non-empty css_set */ 2934 /* Advance to the next non-empty css_set */
2933 do { 2935 do {
2934 l = l->next; 2936 l = l->next;
2935 if (l == &cgrp->css_sets) { 2937 if (l == &cgrp->cset_links) {
2936 it->cg_link = NULL; 2938 it->cset_link = NULL;
2937 return; 2939 return;
2938 } 2940 }
2939 link = list_entry(l, struct cg_cgroup_link, cgrp_link_list); 2941 link = list_entry(l, struct cgrp_cset_link, cset_link);
2940 cset = link->cg; 2942 cset = link->cset;
2941 } while (list_empty(&cset->tasks)); 2943 } while (list_empty(&cset->tasks));
2942 it->cg_link = l; 2944 it->cset_link = l;
2943 it->task = cset->tasks.next; 2945 it->task = cset->tasks.next;
2944} 2946}
2945 2947
@@ -3160,7 +3162,7 @@ void cgroup_iter_start(struct cgroup *cgrp, struct cgroup_iter *it)
3160 cgroup_enable_task_cg_lists(); 3162 cgroup_enable_task_cg_lists();
3161 3163
3162 read_lock(&css_set_lock); 3164 read_lock(&css_set_lock);
3163 it->cg_link = &cgrp->css_sets; 3165 it->cset_link = &cgrp->cset_links;
3164 cgroup_advance_iter(cgrp, it); 3166 cgroup_advance_iter(cgrp, it);
3165} 3167}
3166 3168
@@ -3169,16 +3171,16 @@ struct task_struct *cgroup_iter_next(struct cgroup *cgrp,
3169{ 3171{
3170 struct task_struct *res; 3172 struct task_struct *res;
3171 struct list_head *l = it->task; 3173 struct list_head *l = it->task;
3172 struct cg_cgroup_link *link; 3174 struct cgrp_cset_link *link;
3173 3175
3174 /* If the iterator cg is NULL, we have no tasks */ 3176 /* If the iterator cg is NULL, we have no tasks */
3175 if (!it->cg_link) 3177 if (!it->cset_link)
3176 return NULL; 3178 return NULL;
3177 res = list_entry(l, struct task_struct, cg_list); 3179 res = list_entry(l, struct task_struct, cg_list);
3178 /* Advance iterator to find next entry */ 3180 /* Advance iterator to find next entry */
3179 l = l->next; 3181 l = l->next;
3180 link = list_entry(it->cg_link, struct cg_cgroup_link, cgrp_link_list); 3182 link = list_entry(it->cset_link, struct cgrp_cset_link, cset_link);
3181 if (l == &link->cg->tasks) { 3183 if (l == &link->cset->tasks) {
3182 /* We reached the end of this task list - move on to 3184 /* We reached the end of this task list - move on to
3183 * the next cg_cgroup_link */ 3185 * the next cg_cgroup_link */
3184 cgroup_advance_iter(cgrp, it); 3186 cgroup_advance_iter(cgrp, it);
@@ -4625,7 +4627,7 @@ EXPORT_SYMBOL_GPL(cgroup_load_subsys);
4625 */ 4627 */
4626void cgroup_unload_subsys(struct cgroup_subsys *ss) 4628void cgroup_unload_subsys(struct cgroup_subsys *ss)
4627{ 4629{
4628 struct cg_cgroup_link *link; 4630 struct cgrp_cset_link *link;
4629 4631
4630 BUG_ON(ss->module == NULL); 4632 BUG_ON(ss->module == NULL);
4631 4633
@@ -4654,8 +4656,8 @@ void cgroup_unload_subsys(struct cgroup_subsys *ss)
4654 * in loading, we need to pay our respects to the hashtable gods. 4656 * in loading, we need to pay our respects to the hashtable gods.
4655 */ 4657 */
4656 write_lock(&css_set_lock); 4658 write_lock(&css_set_lock);
4657 list_for_each_entry(link, &dummytop->css_sets, cgrp_link_list) { 4659 list_for_each_entry(link, &dummytop->cset_links, cset_link) {
4658 struct css_set *cset = link->cg; 4660 struct css_set *cset = link->cset;
4659 unsigned long key; 4661 unsigned long key;
4660 4662
4661 hash_del(&cset->hlist); 4663 hash_del(&cset->hlist);
@@ -4688,7 +4690,7 @@ int __init cgroup_init_early(void)
4688{ 4690{
4689 int i; 4691 int i;
4690 atomic_set(&init_css_set.refcount, 1); 4692 atomic_set(&init_css_set.refcount, 1);
4691 INIT_LIST_HEAD(&init_css_set.cg_links); 4693 INIT_LIST_HEAD(&init_css_set.cgrp_links);
4692 INIT_LIST_HEAD(&init_css_set.tasks); 4694 INIT_LIST_HEAD(&init_css_set.tasks);
4693 INIT_HLIST_NODE(&init_css_set.hlist); 4695 INIT_HLIST_NODE(&init_css_set.hlist);
4694 css_set_count = 1; 4696 css_set_count = 1;
@@ -4696,12 +4698,10 @@ int __init cgroup_init_early(void)
4696 root_count = 1; 4698 root_count = 1;
4697 init_task.cgroups = &init_css_set; 4699 init_task.cgroups = &init_css_set;
4698 4700
4699 init_css_set_link.cg = &init_css_set; 4701 init_cgrp_cset_link.cset = &init_css_set;
4700 init_css_set_link.cgrp = dummytop; 4702 init_cgrp_cset_link.cgrp = dummytop;
4701 list_add(&init_css_set_link.cgrp_link_list, 4703 list_add(&init_cgrp_cset_link.cset_link, &rootnode.top_cgroup.cset_links);
4702 &rootnode.top_cgroup.css_sets); 4704 list_add(&init_cgrp_cset_link.cgrp_link, &init_css_set.cgrp_links);
4703 list_add(&init_css_set_link.cg_link_list,
4704 &init_css_set.cg_links);
4705 4705
4706 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 4706 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
4707 struct cgroup_subsys *ss = subsys[i]; 4707 struct cgroup_subsys *ss = subsys[i];
@@ -5454,13 +5454,13 @@ static int current_css_set_cg_links_read(struct cgroup *cont,
5454 struct cftype *cft, 5454 struct cftype *cft,
5455 struct seq_file *seq) 5455 struct seq_file *seq)
5456{ 5456{
5457 struct cg_cgroup_link *link; 5457 struct cgrp_cset_link *link;
5458 struct css_set *cset; 5458 struct css_set *cset;
5459 5459
5460 read_lock(&css_set_lock); 5460 read_lock(&css_set_lock);
5461 rcu_read_lock(); 5461 rcu_read_lock();
5462 cset = rcu_dereference(current->cgroups); 5462 cset = rcu_dereference(current->cgroups);
5463 list_for_each_entry(link, &cset->cg_links, cg_link_list) { 5463 list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
5464 struct cgroup *c = link->cgrp; 5464 struct cgroup *c = link->cgrp;
5465 const char *name; 5465 const char *name;
5466 5466
@@ -5481,11 +5481,11 @@ static int cgroup_css_links_read(struct cgroup *cont,
5481 struct cftype *cft, 5481 struct cftype *cft,
5482 struct seq_file *seq) 5482 struct seq_file *seq)
5483{ 5483{
5484 struct cg_cgroup_link *link; 5484 struct cgrp_cset_link *link;
5485 5485
5486 read_lock(&css_set_lock); 5486 read_lock(&css_set_lock);
5487 list_for_each_entry(link, &cont->css_sets, cgrp_link_list) { 5487 list_for_each_entry(link, &cont->cset_links, cset_link) {
5488 struct css_set *cset = link->cg; 5488 struct css_set *cset = link->cset;
5489 struct task_struct *task; 5489 struct task_struct *task;
5490 int count = 0; 5490 int count = 0;
5491 seq_printf(seq, "css_set %p\n", cset); 5491 seq_printf(seq, "css_set %p\n", cset);