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