Skip to content

Commit d19e058

Browse files
Li ZefanLinus Torvalds
Li Zefan
authored and
Linus Torvalds
committed
cgroup: fix and update documentation
Misc fixes and updates, make the doc consistent with current cgroup implementation. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b5a0e01 commit d19e058

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

Documentation/cgroups.txt

+33-33
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CONTENTS:
2828
4. Questions
2929

3030
1. Control Groups
31-
==========
31+
=================
3232

3333
1.1 What are cgroups ?
3434
----------------------
@@ -143,10 +143,10 @@ proliferation of such cgroups.
143143

144144
Also lets say that the administrator would like to give enhanced network
145145
access temporarily to a student's browser (since it is night and the user
146-
wants to do online gaming :) OR give one of the students simulation
146+
wants to do online gaming :)) OR give one of the students simulation
147147
apps enhanced CPU power,
148148

149-
With ability to write pids directly to resource classes, its just a
149+
With ability to write pids directly to resource classes, it's just a
150150
matter of :
151151

152152
# echo pid > /mnt/network/<new_class>/tasks
@@ -227,10 +227,13 @@ Each cgroup is represented by a directory in the cgroup file system
227227
containing the following files describing that cgroup:
228228

229229
- tasks: list of tasks (by pid) attached to that cgroup
230-
- notify_on_release flag: run /sbin/cgroup_release_agent on exit?
230+
- releasable flag: cgroup currently removeable?
231+
- notify_on_release flag: run the release agent on exit?
232+
- release_agent: the path to use for release notifications (this file
233+
exists in the top cgroup only)
231234

232235
Other subsystems such as cpusets may add additional files in each
233-
cgroup dir
236+
cgroup dir.
234237

235238
New cgroups are created using the mkdir system call or shell
236239
command. The properties of a cgroup, such as its flags, are
@@ -257,7 +260,7 @@ performance.
257260
To allow access from a cgroup to the css_sets (and hence tasks)
258261
that comprise it, a set of cg_cgroup_link objects form a lattice;
259262
each cg_cgroup_link is linked into a list of cg_cgroup_links for
260-
a single cgroup on its cont_link_list field, and a list of
263+
a single cgroup on its cgrp_link_list field, and a list of
261264
cg_cgroup_links for a single css_set on its cg_link_list.
262265

263266
Thus the set of tasks in a cgroup can be listed by iterating over
@@ -271,9 +274,6 @@ for cgroups, with a minimum of additional kernel code.
271274
1.4 What does notify_on_release do ?
272275
------------------------------------
273276

274-
*** notify_on_release is disabled in the current patch set. It will be
275-
*** reactivated in a future patch in a less-intrusive manner
276-
277277
If the notify_on_release flag is enabled (1) in a cgroup, then
278278
whenever the last task in the cgroup leaves (exits or attaches to
279279
some other cgroup) and the last child cgroup of that cgroup
@@ -360,8 +360,8 @@ Now you want to do something with this cgroup.
360360

361361
In this directory you can find several files:
362362
# ls
363-
notify_on_release release_agent tasks
364-
(plus whatever files are added by the attached subsystems)
363+
notify_on_release releasable tasks
364+
(plus whatever files added by the attached subsystems)
365365

366366
Now attach your shell to this cgroup:
367367
# /bin/echo $$ > tasks
@@ -404,19 +404,13 @@ with a subsystem id which will be assigned by the cgroup system.
404404
Other fields in the cgroup_subsys object include:
405405

406406
- subsys_id: a unique array index for the subsystem, indicating which
407-
entry in cgroup->subsys[] this subsystem should be
408-
managing. Initialized by cgroup_register_subsys(); prior to this
409-
it should be initialized to -1
407+
entry in cgroup->subsys[] this subsystem should be managing.
410408

411-
- hierarchy: an index indicating which hierarchy, if any, this
412-
subsystem is currently attached to. If this is -1, then the
413-
subsystem is not attached to any hierarchy, and all tasks should be
414-
considered to be members of the subsystem's top_cgroup. It should
415-
be initialized to -1.
409+
- name: should be initialized to a unique subsystem name. Should be
410+
no longer than MAX_CGROUP_TYPE_NAMELEN.
416411

417-
- name: should be initialized to a unique subsystem name prior to
418-
calling cgroup_register_subsystem. Should be no longer than
419-
MAX_CGROUP_TYPE_NAMELEN
412+
- early_init: indicate if the subsystem needs early initialization
413+
at system boot.
420414

421415
Each cgroup object created by the system has an array of pointers,
422416
indexed by subsystem id; this pointer is entirely managed by the
@@ -434,8 +428,6 @@ situation.
434428
See kernel/cgroup.c for more details.
435429

436430
Subsystems can take/release the cgroup_mutex via the functions
437-
cgroup_lock()/cgroup_unlock(), and can
438-
take/release the callback_mutex via the functions
439431
cgroup_lock()/cgroup_unlock().
440432

441433
Accessing a task's cgroup pointer may be done in the following ways:
@@ -444,7 +436,7 @@ Accessing a task's cgroup pointer may be done in the following ways:
444436
- inside an rcu_read_lock() section via rcu_dereference()
445437

446438
3.3 Subsystem API
447-
--------------------------
439+
-----------------
448440

449441
Each subsystem should:
450442

@@ -455,7 +447,8 @@ Each subsystem may export the following methods. The only mandatory
455447
methods are create/destroy. Any others that are null are presumed to
456448
be successful no-ops.
457449

458-
struct cgroup_subsys_state *create(struct cgroup *cont)
450+
struct cgroup_subsys_state *create(struct cgroup_subsys *ss,
451+
struct cgroup *cgrp)
459452
(cgroup_mutex held by caller)
460453

461454
Called to create a subsystem state object for a cgroup. The
@@ -470,7 +463,7 @@ identified by the passed cgroup object having a NULL parent (since
470463
it's the root of the hierarchy) and may be an appropriate place for
471464
initialization code.
472465

473-
void destroy(struct cgroup *cont)
466+
void destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
474467
(cgroup_mutex held by caller)
475468

476469
The cgroup system is about to destroy the passed cgroup; the subsystem
@@ -481,7 +474,14 @@ cgroup->parent is still valid. (Note - can also be called for a
481474
newly-created cgroup if an error occurs after this subsystem's
482475
create() method has been called for the new cgroup).
483476

484-
int can_attach(struct cgroup_subsys *ss, struct cgroup *cont,
477+
void pre_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp);
478+
(cgroup_mutex held by caller)
479+
480+
Called before checking the reference count on each subsystem. This may
481+
be useful for subsystems which have some extra references even if
482+
there are not tasks in the cgroup.
483+
484+
int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
485485
struct task_struct *task)
486486
(cgroup_mutex held by caller)
487487

@@ -492,8 +492,8 @@ unspecified task can be moved into the cgroup. Note that this isn't
492492
called on a fork. If this method returns 0 (success) then this should
493493
remain valid while the caller holds cgroup_mutex.
494494

495-
void attach(struct cgroup_subsys *ss, struct cgroup *cont,
496-
struct cgroup *old_cont, struct task_struct *task)
495+
void attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
496+
struct cgroup *old_cgrp, struct task_struct *task)
497497

498498
Called after the task has been attached to the cgroup, to allow any
499499
post-attachment activity that requires memory allocations or blocking.
@@ -505,9 +505,9 @@ registration for all existing tasks.
505505

506506
void exit(struct cgroup_subsys *ss, struct task_struct *task)
507507

508-
Called during task exit
508+
Called during task exit.
509509

510-
int populate(struct cgroup_subsys *ss, struct cgroup *cont)
510+
int populate(struct cgroup_subsys *ss, struct cgroup *cgrp)
511511

512512
Called after creation of a cgroup to allow a subsystem to populate
513513
the cgroup directory with file entries. The subsystem should make
@@ -516,7 +516,7 @@ include/linux/cgroup.h for details). Note that although this
516516
method can return an error code, the error code is currently not
517517
always handled well.
518518

519-
void post_clone(struct cgroup_subsys *ss, struct cgroup *cont)
519+
void post_clone(struct cgroup_subsys *ss, struct cgroup *cgrp)
520520

521521
Called at the end of cgroup_clone() to do any paramater
522522
initialization which might be required before a task could attach. For

0 commit comments

Comments
 (0)