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 /Documentation/cgroups | |
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 'Documentation/cgroups')
-rw-r--r-- | Documentation/cgroups/cgroups.txt | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt index 9e04196c4d78..b06eea217403 100644 --- a/Documentation/cgroups/cgroups.txt +++ b/Documentation/cgroups/cgroups.txt | |||
@@ -553,16 +553,16 @@ call to cgroup_unload_subsys(). It should also set its_subsys.module = | |||
553 | THIS_MODULE in its .c file. | 553 | THIS_MODULE in its .c file. |
554 | 554 | ||
555 | Each subsystem may export the following methods. The only mandatory | 555 | Each subsystem may export the following methods. The only mandatory |
556 | methods are create/destroy. Any others that are null are presumed to | 556 | methods are css_alloc/free. Any others that are null are presumed to |
557 | be successful no-ops. | 557 | be successful no-ops. |
558 | 558 | ||
559 | struct cgroup_subsys_state *create(struct cgroup *cgrp) | 559 | struct cgroup_subsys_state *css_alloc(struct cgroup *cgrp) |
560 | (cgroup_mutex held by caller) | 560 | (cgroup_mutex held by caller) |
561 | 561 | ||
562 | Called to create a subsystem state object for a cgroup. The | 562 | Called to allocate a subsystem state object for a cgroup. The |
563 | subsystem should allocate its subsystem state object for the passed | 563 | subsystem should allocate its subsystem state object for the passed |
564 | cgroup, returning a pointer to the new object on success or a | 564 | cgroup, returning a pointer to the new object on success or a |
565 | negative error code. On success, the subsystem pointer should point to | 565 | ERR_PTR() value. On success, the subsystem pointer should point to |
566 | a structure of type cgroup_subsys_state (typically embedded in a | 566 | a structure of type cgroup_subsys_state (typically embedded in a |
567 | larger subsystem-specific object), which will be initialized by the | 567 | larger subsystem-specific object), which will be initialized by the |
568 | cgroup system. Note that this will be called at initialization to | 568 | cgroup system. Note that this will be called at initialization to |
@@ -571,24 +571,33 @@ identified by the passed cgroup object having a NULL parent (since | |||
571 | it's the root of the hierarchy) and may be an appropriate place for | 571 | it's the root of the hierarchy) and may be an appropriate place for |
572 | initialization code. | 572 | initialization code. |
573 | 573 | ||
574 | void destroy(struct cgroup *cgrp) | 574 | int css_online(struct cgroup *cgrp) |
575 | (cgroup_mutex held by caller) | 575 | (cgroup_mutex held by caller) |
576 | 576 | ||
577 | The cgroup system is about to destroy the passed cgroup; the subsystem | 577 | Called after @cgrp successfully completed all allocations and made |
578 | should do any necessary cleanup and free its subsystem state | 578 | visible to cgroup_for_each_child/descendant_*() iterators. The |
579 | object. By the time this method is called, the cgroup has already been | 579 | subsystem may choose to fail creation by returning -errno. This |
580 | unlinked from the file system and from the child list of its parent; | 580 | callback can be used to implement reliable state sharing and |
581 | cgroup->parent is still valid. (Note - can also be called for a | 581 | propagation along the hierarchy. See the comment on |
582 | newly-created cgroup if an error occurs after this subsystem's | 582 | cgroup_for_each_descendant_pre() for details. |
583 | create() method has been called for the new cgroup). | 583 | |
584 | 584 | void css_offline(struct cgroup *cgrp); | |
585 | int pre_destroy(struct cgroup *cgrp); | 585 | |
586 | 586 | This is the counterpart of css_online() and called iff css_online() | |
587 | Called before checking the reference count on each subsystem. This may | 587 | has succeeded on @cgrp. This signifies the beginning of the end of |
588 | be useful for subsystems which have some extra references even if | 588 | @cgrp. @cgrp is being removed and the subsystem should start dropping |
589 | there are not tasks in the cgroup. If pre_destroy() returns error code, | 589 | all references it's holding on @cgrp. When all references are dropped, |
590 | rmdir() will fail with it. From this behavior, pre_destroy() can be | 590 | cgroup removal will proceed to the next step - css_free(). After this |
591 | called multiple times against a cgroup. | 591 | callback, @cgrp should be considered dead to the subsystem. |
592 | |||
593 | void css_free(struct cgroup *cgrp) | ||
594 | (cgroup_mutex held by caller) | ||
595 | |||
596 | The cgroup system is about to free @cgrp; the subsystem should free | ||
597 | its subsystem state object. By the time this method is called, @cgrp | ||
598 | is completely unused; @cgrp->parent is still valid. (Note - can also | ||
599 | be called for a newly-created cgroup if an error occurs after this | ||
600 | subsystem's create() method has been called for the new cgroup). | ||
592 | 601 | ||
593 | int can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) | 602 | int can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) |
594 | (cgroup_mutex held by caller) | 603 | (cgroup_mutex held by caller) |