diff options
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 88 |
1 files changed, 46 insertions, 42 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index c288bce428f8..4bc22f4a1abb 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -779,68 +779,72 @@ static inline struct cgroup *cgroup_from_id(struct cgroup_subsys *ss, int id) | |||
779 | return idr_find(&ss->root->cgroup_idr, id); | 779 | return idr_find(&ss->root->cgroup_idr, id); |
780 | } | 780 | } |
781 | 781 | ||
782 | struct cgroup *cgroup_next_child(struct cgroup *pos, struct cgroup *cgrp); | 782 | struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos, |
783 | struct cgroup_subsys_state *parent); | ||
783 | 784 | ||
784 | /** | 785 | /** |
785 | * cgroup_for_each_child - iterate through children of a cgroup | 786 | * css_for_each_child - iterate through children of a css |
786 | * @pos: the cgroup * to use as the loop cursor | 787 | * @pos: the css * to use as the loop cursor |
787 | * @cgrp: cgroup whose children to walk | 788 | * @parent: css whose children to walk |
788 | * | 789 | * |
789 | * Walk @cgrp's children. Must be called under rcu_read_lock(). A child | 790 | * Walk @parent's children. Must be called under rcu_read_lock(). A child |
790 | * cgroup which hasn't finished ->css_online() or already has finished | 791 | * css which hasn't finished ->css_online() or already has finished |
791 | * ->css_offline() may show up during traversal and it's each subsystem's | 792 | * ->css_offline() may show up during traversal and it's each subsystem's |
792 | * responsibility to verify that each @pos is alive. | 793 | * responsibility to verify that each @pos is alive. |
793 | * | 794 | * |
794 | * If a subsystem synchronizes against the parent in its ->css_online() and | 795 | * If a subsystem synchronizes against the parent in its ->css_online() and |
795 | * before starting iterating, a cgroup which finished ->css_online() is | 796 | * before starting iterating, a css which finished ->css_online() is |
796 | * guaranteed to be visible in the future iterations. | 797 | * guaranteed to be visible in the future iterations. |
797 | * | 798 | * |
798 | * It is allowed to temporarily drop RCU read lock during iteration. The | 799 | * It is allowed to temporarily drop RCU read lock during iteration. The |
799 | * caller is responsible for ensuring that @pos remains accessible until | 800 | * caller is responsible for ensuring that @pos remains accessible until |
800 | * the start of the next iteration by, for example, bumping the css refcnt. | 801 | * the start of the next iteration by, for example, bumping the css refcnt. |
801 | */ | 802 | */ |
802 | #define cgroup_for_each_child(pos, cgrp) \ | 803 | #define css_for_each_child(pos, parent) \ |
803 | for ((pos) = cgroup_next_child(NULL, (cgrp)); (pos); \ | 804 | for ((pos) = css_next_child(NULL, (parent)); (pos); \ |
804 | (pos) = cgroup_next_child((pos), (cgrp))) | 805 | (pos) = css_next_child((pos), (parent))) |
805 | 806 | ||
806 | struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos, | 807 | struct cgroup_subsys_state * |
807 | struct cgroup *cgroup); | 808 | css_next_descendant_pre(struct cgroup_subsys_state *pos, |
808 | struct cgroup *cgroup_rightmost_descendant(struct cgroup *pos); | 809 | struct cgroup_subsys_state *css); |
810 | |||
811 | struct cgroup_subsys_state * | ||
812 | css_rightmost_descendant(struct cgroup_subsys_state *pos); | ||
809 | 813 | ||
810 | /** | 814 | /** |
811 | * cgroup_for_each_descendant_pre - pre-order walk of a cgroup's descendants | 815 | * css_for_each_descendant_pre - pre-order walk of a css's descendants |
812 | * @pos: the cgroup * to use as the loop cursor | 816 | * @pos: the css * to use as the loop cursor |
813 | * @cgroup: cgroup whose descendants to walk | 817 | * @root: css whose descendants to walk |
814 | * | 818 | * |
815 | * Walk @cgroup's descendants. Must be called under rcu_read_lock(). A | 819 | * Walk @root's descendants. Must be called under rcu_read_lock(). A |
816 | * descendant cgroup which hasn't finished ->css_online() or already has | 820 | * descendant css which hasn't finished ->css_online() or already has |
817 | * finished ->css_offline() may show up during traversal and it's each | 821 | * finished ->css_offline() may show up during traversal and it's each |
818 | * subsystem's responsibility to verify that each @pos is alive. | 822 | * subsystem's responsibility to verify that each @pos is alive. |
819 | * | 823 | * |
820 | * If a subsystem synchronizes against the parent in its ->css_online() and | 824 | * If a subsystem synchronizes against the parent in its ->css_online() and |
821 | * before starting iterating, and synchronizes against @pos on each | 825 | * before starting iterating, and synchronizes against @pos on each |
822 | * iteration, any descendant cgroup which finished ->css_online() is | 826 | * iteration, any descendant css which finished ->css_online() is |
823 | * guaranteed to be visible in the future iterations. | 827 | * guaranteed to be visible in the future iterations. |
824 | * | 828 | * |
825 | * In other words, the following guarantees that a descendant can't escape | 829 | * In other words, the following guarantees that a descendant can't escape |
826 | * state updates of its ancestors. | 830 | * state updates of its ancestors. |
827 | * | 831 | * |
828 | * my_online(@cgrp) | 832 | * my_online(@css) |
829 | * { | 833 | * { |
830 | * Lock @cgrp->parent and @cgrp; | 834 | * Lock @css's parent and @css; |
831 | * Inherit state from @cgrp->parent; | 835 | * Inherit state from the parent; |
832 | * Unlock both. | 836 | * Unlock both. |
833 | * } | 837 | * } |
834 | * | 838 | * |
835 | * my_update_state(@cgrp) | 839 | * my_update_state(@css) |
836 | * { | 840 | * { |
837 | * Lock @cgrp; | 841 | * Lock @css; |
838 | * Update @cgrp's state; | 842 | * Update @css's state; |
839 | * Unlock @cgrp; | 843 | * Unlock @css; |
840 | * | 844 | * |
841 | * cgroup_for_each_descendant_pre(@pos, @cgrp) { | 845 | * css_for_each_descendant_pre(@pos, @css) { |
842 | * Lock @pos; | 846 | * Lock @pos; |
843 | * Verify @pos is alive and inherit state from @pos->parent; | 847 | * Verify @pos is alive and inherit state from @pos's parent; |
844 | * Unlock @pos; | 848 | * Unlock @pos; |
845 | * } | 849 | * } |
846 | * } | 850 | * } |
@@ -851,8 +855,7 @@ struct cgroup *cgroup_rightmost_descendant(struct cgroup *pos); | |||
851 | * visible by walking order and, as long as inheriting operations to the | 855 | * visible by walking order and, as long as inheriting operations to the |
852 | * same @pos are atomic to each other, multiple updates racing each other | 856 | * same @pos are atomic to each other, multiple updates racing each other |
853 | * still result in the correct state. It's guaranateed that at least one | 857 | * still result in the correct state. It's guaranateed that at least one |
854 | * inheritance happens for any cgroup after the latest update to its | 858 | * inheritance happens for any css after the latest update to its parent. |
855 | * parent. | ||
856 | * | 859 | * |
857 | * If checking parent's state requires locking the parent, each inheriting | 860 | * If checking parent's state requires locking the parent, each inheriting |
858 | * iteration should lock and unlock both @pos->parent and @pos. | 861 | * iteration should lock and unlock both @pos->parent and @pos. |
@@ -865,25 +868,26 @@ struct cgroup *cgroup_rightmost_descendant(struct cgroup *pos); | |||
865 | * caller is responsible for ensuring that @pos remains accessible until | 868 | * caller is responsible for ensuring that @pos remains accessible until |
866 | * the start of the next iteration by, for example, bumping the css refcnt. | 869 | * the start of the next iteration by, for example, bumping the css refcnt. |
867 | */ | 870 | */ |
868 | #define cgroup_for_each_descendant_pre(pos, cgroup) \ | 871 | #define css_for_each_descendant_pre(pos, css) \ |
869 | for (pos = cgroup_next_descendant_pre(NULL, (cgroup)); (pos); \ | 872 | for ((pos) = css_next_descendant_pre(NULL, (css)); (pos); \ |
870 | pos = cgroup_next_descendant_pre((pos), (cgroup))) | 873 | (pos) = css_next_descendant_pre((pos), (css))) |
871 | 874 | ||
872 | struct cgroup *cgroup_next_descendant_post(struct cgroup *pos, | 875 | struct cgroup_subsys_state * |
873 | struct cgroup *cgroup); | 876 | css_next_descendant_post(struct cgroup_subsys_state *pos, |
877 | struct cgroup_subsys_state *css); | ||
874 | 878 | ||
875 | /** | 879 | /** |
876 | * cgroup_for_each_descendant_post - post-order walk of a cgroup's descendants | 880 | * css_for_each_descendant_post - post-order walk of a css's descendants |
877 | * @pos: the cgroup * to use as the loop cursor | 881 | * @pos: the css * to use as the loop cursor |
878 | * @cgroup: cgroup whose descendants to walk | 882 | * @css: css whose descendants to walk |
879 | * | 883 | * |
880 | * Similar to cgroup_for_each_descendant_pre() but performs post-order | 884 | * Similar to css_for_each_descendant_pre() but performs post-order |
881 | * traversal instead. Note that the walk visibility guarantee described in | 885 | * traversal instead. Note that the walk visibility guarantee described in |
882 | * pre-order walk doesn't apply the same to post-order walks. | 886 | * pre-order walk doesn't apply the same to post-order walks. |
883 | */ | 887 | */ |
884 | #define cgroup_for_each_descendant_post(pos, cgroup) \ | 888 | #define css_for_each_descendant_post(pos, css) \ |
885 | for (pos = cgroup_next_descendant_post(NULL, (cgroup)); (pos); \ | 889 | for ((pos) = css_next_descendant_post(NULL, (css)); (pos); \ |
886 | pos = cgroup_next_descendant_post((pos), (cgroup))) | 890 | (pos) = css_next_descendant_post((pos), (css))) |
887 | 891 | ||
888 | /* A cgroup_iter should be treated as an opaque object */ | 892 | /* A cgroup_iter should be treated as an opaque object */ |
889 | struct cgroup_iter { | 893 | struct cgroup_iter { |