diff options
author | Tejun Heo <tj@kernel.org> | 2012-11-19 11:13:38 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-11-19 11:13:38 -0500 |
commit | 92fb97487a7e41b222c1417cabd1d1ab7cc3a48c (patch) | |
tree | c220c622b9ac9b16535535d448e9cd29be72c77e /include/linux/cgroup.h | |
parent | b1929db42f8a649d9a9e397119f628c27fd4021f (diff) |
cgroup: rename ->create/post_create/pre_destroy/destroy() to ->css_alloc/online/offline/free()
Rename cgroup_subsys css lifetime related callbacks to better describe
what their roles are. Also, update documentation.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r-- | include/linux/cgroup.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 03d8a92786da..7a2189ca8327 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -82,7 +82,7 @@ struct cgroup_subsys_state { | |||
82 | /* bits in struct cgroup_subsys_state flags field */ | 82 | /* bits in struct cgroup_subsys_state flags field */ |
83 | enum { | 83 | enum { |
84 | CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */ | 84 | CSS_ROOT = (1 << 0), /* this CSS is the root of the subsystem */ |
85 | CSS_ONLINE = (1 << 1), /* between ->post_create() and ->pre_destroy() */ | 85 | CSS_ONLINE = (1 << 1), /* between ->css_online() and ->css_offline() */ |
86 | }; | 86 | }; |
87 | 87 | ||
88 | /* Caller must verify that the css is not for root cgroup */ | 88 | /* Caller must verify that the css is not for root cgroup */ |
@@ -439,10 +439,11 @@ int cgroup_taskset_size(struct cgroup_taskset *tset); | |||
439 | */ | 439 | */ |
440 | 440 | ||
441 | struct cgroup_subsys { | 441 | struct cgroup_subsys { |
442 | struct cgroup_subsys_state *(*create)(struct cgroup *cgrp); | 442 | struct cgroup_subsys_state *(*css_alloc)(struct cgroup *cgrp); |
443 | int (*post_create)(struct cgroup *cgrp); | 443 | int (*css_online)(struct cgroup *cgrp); |
444 | void (*pre_destroy)(struct cgroup *cgrp); | 444 | void (*css_offline)(struct cgroup *cgrp); |
445 | void (*destroy)(struct cgroup *cgrp); | 445 | void (*css_free)(struct cgroup *cgrp); |
446 | |||
446 | int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); | 447 | int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); |
447 | void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); | 448 | void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); |
448 | void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); | 449 | void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset); |
@@ -541,13 +542,13 @@ static inline struct cgroup* task_cgroup(struct task_struct *task, | |||
541 | * @cgroup: cgroup whose children to walk | 542 | * @cgroup: cgroup whose children to walk |
542 | * | 543 | * |
543 | * Walk @cgroup's children. Must be called under rcu_read_lock(). A child | 544 | * Walk @cgroup's children. Must be called under rcu_read_lock(). A child |
544 | * cgroup which hasn't finished ->post_create() or already has finished | 545 | * cgroup which hasn't finished ->css_online() or already has finished |
545 | * ->pre_destroy() may show up during traversal and it's each subsystem's | 546 | * ->css_offline() may show up during traversal and it's each subsystem's |
546 | * responsibility to verify that each @pos is alive. | 547 | * responsibility to verify that each @pos is alive. |
547 | * | 548 | * |
548 | * If a subsystem synchronizes against the parent in its ->post_create() | 549 | * If a subsystem synchronizes against the parent in its ->css_online() and |
549 | * and before starting iterating, a cgroup which finished ->post_create() | 550 | * before starting iterating, a cgroup which finished ->css_online() is |
550 | * is guaranteed to be visible in the future iterations. | 551 | * guaranteed to be visible in the future iterations. |
551 | */ | 552 | */ |
552 | #define cgroup_for_each_child(pos, cgroup) \ | 553 | #define cgroup_for_each_child(pos, cgroup) \ |
553 | list_for_each_entry_rcu(pos, &(cgroup)->children, sibling) | 554 | list_for_each_entry_rcu(pos, &(cgroup)->children, sibling) |
@@ -561,19 +562,19 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos, | |||
561 | * @cgroup: cgroup whose descendants to walk | 562 | * @cgroup: cgroup whose descendants to walk |
562 | * | 563 | * |
563 | * Walk @cgroup's descendants. Must be called under rcu_read_lock(). A | 564 | * Walk @cgroup's descendants. Must be called under rcu_read_lock(). A |
564 | * descendant cgroup which hasn't finished ->post_create() or already has | 565 | * descendant cgroup which hasn't finished ->css_online() or already has |
565 | * finished ->pre_destroy() may show up during traversal and it's each | 566 | * finished ->css_offline() may show up during traversal and it's each |
566 | * subsystem's responsibility to verify that each @pos is alive. | 567 | * subsystem's responsibility to verify that each @pos is alive. |
567 | * | 568 | * |
568 | * If a subsystem synchronizes against the parent in its ->post_create() | 569 | * If a subsystem synchronizes against the parent in its ->css_online() and |
569 | * and before starting iterating, and synchronizes against @pos on each | 570 | * before starting iterating, and synchronizes against @pos on each |
570 | * iteration, any descendant cgroup which finished ->post_create() is | 571 | * iteration, any descendant cgroup which finished ->css_offline() is |
571 | * guaranteed to be visible in the future iterations. | 572 | * guaranteed to be visible in the future iterations. |
572 | * | 573 | * |
573 | * In other words, the following guarantees that a descendant can't escape | 574 | * In other words, the following guarantees that a descendant can't escape |
574 | * state updates of its ancestors. | 575 | * state updates of its ancestors. |
575 | * | 576 | * |
576 | * my_post_create(@cgrp) | 577 | * my_online(@cgrp) |
577 | * { | 578 | * { |
578 | * Lock @cgrp->parent and @cgrp; | 579 | * Lock @cgrp->parent and @cgrp; |
579 | * Inherit state from @cgrp->parent; | 580 | * Inherit state from @cgrp->parent; |
@@ -606,7 +607,7 @@ struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos, | |||
606 | * iteration should lock and unlock both @pos->parent and @pos. | 607 | * iteration should lock and unlock both @pos->parent and @pos. |
607 | * | 608 | * |
608 | * Alternatively, a subsystem may choose to use a single global lock to | 609 | * Alternatively, a subsystem may choose to use a single global lock to |
609 | * synchronize ->post_create() and ->pre_destroy() against tree-walking | 610 | * synchronize ->css_online() and ->css_offline() against tree-walking |
610 | * operations. | 611 | * operations. |
611 | */ | 612 | */ |
612 | #define cgroup_for_each_descendant_pre(pos, cgroup) \ | 613 | #define cgroup_for_each_descendant_pre(pos, cgroup) \ |