Lines Matching refs:cgroup

46 A *cgroup* associates a set of tasks with a set of parameters for one
52 schedules a resource or applies per-cgroup limits, but it may be
59 state attached to each cgroup in the hierarchy. Each hierarchy has
60 an instance of the cgroup virtual filesystem associated with it.
66 instance of the cgroup virtual file system, specify and query to
67 which cgroup a task is assigned, and list the task PIDs assigned to
68 a cgroup. Those creations and assignments only affect the hierarchy
69 associated with that instance of the cgroup file system.
73 cgroup support to provide new attributes for cgroups, such as
74 accounting/limiting the resources which processes in a cgroup can
77 tasks in each cgroup.
87 up in the same group (cgroup) as their parent process.
89 The kernel cgroup patch provides the minimum essential kernel
141 # echo browser_pid > /sys/fs/cgroup/<restype>/<userclass>/tasks
144 a separate cgroup for every browser launched and associate it with
156 # echo pid > /sys/fs/cgroup/network/<new_class>/tasks
158 # echo pid > /sys/fs/cgroup/network/<orig_class>/tasks
160 Without this ability, the administrator would have to split the cgroup into
175 cgroup_subsys_state objects, one for each cgroup subsystem
177 the cgroup of which it's a member in each hierarchy, but this
182 task's actual cgroup assignments (in particular, moving between
187 - A cgroup hierarchy filesystem can be mounted for browsing and
190 - You can list all the tasks (by PID) attached to any cgroup.
200 In addition, a new file system of type "cgroup" may be mounted, to
202 kernel. When mounting a cgroup hierarchy, you may specify a
204 options. By default, mounting the cgroup filesystem attempts to
214 cgroup hierarchy, or to unbind a subsystem from an active cgroup
218 When a cgroup filesystem is unmounted, if there are any
219 child cgroups created below the top-level cgroup, that hierarchy
224 querying and modifying cgroups is via this cgroup file system.
226 Each task under /proc has an added file named 'cgroup' displaying,
227 for each active hierarchy, the subsystem names and the cgroup name
228 as the path relative to the root of the cgroup file system.
230 Each cgroup is represented by a directory in the cgroup file system
231 containing the following files describing that cgroup:
233 - tasks: list of tasks (by PID) attached to that cgroup. This list
235 moves the thread into this cgroup.
236 - cgroup.procs: list of thread group IDs in the cgroup. This list is
240 group into this cgroup.
243 exists in the top cgroup only)
246 cgroup dir.
249 command. The properties of a cgroup, such as its flags, are
257 children of that task, to a cgroup allows organizing the work load
259 any other cgroup, if allowed by the permissions on the necessary
260 cgroup file system directories.
262 When a task is moved from one cgroup to another, it gets a new
268 To allow access from a cgroup to the css_sets (and hence tasks)
271 a single cgroup on its cgrp_link_list field, and a list of
274 Thus the set of tasks in a cgroup can be listed by iterating over
275 each css_set that references the cgroup, and sub-iterating over
279 cgroup hierarchy provides for a familiar permission and name space
285 If the notify_on_release flag is enabled (1) in a cgroup, then
286 whenever the last task in the cgroup leaves (exits or attaches to
287 some other cgroup) and the last child cgroup of that cgroup
290 supplying the pathname (relative to the mount point of the cgroup
291 file system) of the abandoned cgroup. This enables automatic
293 notify_on_release in the root cgroup at system boot is disabled
296 a cgroup hierarchy's release_agent path is empty.
302 flag is enabled (1) in a cgroup, a new cpuset cgroup will copy its
308 To start a new job that is to be contained within a cgroup, using
309 the "cpuset" cgroup subsystem, the steps are something like:
311 1) mount -t tmpfs cgroup_root /sys/fs/cgroup
312 2) mkdir /sys/fs/cgroup/cpuset
313 3) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
314 4) Create the new cgroup by doing mkdir's and write's (or echo's) in
315 the /sys/fs/cgroup/cpuset virtual file system.
317 6) Attach that task to the new cgroup by writing its PID to the
318 /sys/fs/cgroup/cpuset tasks file for that cgroup.
321 For example, the following sequence of commands will setup a cgroup
323 and then start a subshell 'sh' in that cgroup:
325 mount -t tmpfs cgroup_root /sys/fs/cgroup
326 mkdir /sys/fs/cgroup/cpuset
327 mount -t cgroup cpuset -ocpuset /sys/fs/cgroup/cpuset
328 cd /sys/fs/cgroup/cpuset
335 # The subshell 'sh' is now running in cgroup Charlie
337 cat /proc/self/cgroup
345 Creating, modifying, using cgroups can be done through the cgroup
348 To mount a cgroup hierarchy with all available subsystems, type:
349 # mount -t cgroup xxx /sys/fs/cgroup
351 The "xxx" is not interpreted by the cgroup code, but will appear in
356 for each new cgroup created before that group can be used.
361 /sys/fs/cgroup and create directories for each cgroup resource or resource
364 # mount -t tmpfs cgroup_root /sys/fs/cgroup
365 # mkdir /sys/fs/cgroup/rg1
367 To mount a cgroup hierarchy with just the cpuset and memory
369 # mount -t cgroup -o cpuset,memory hier1 /sys/fs/cgroup/rg1
379 # mount -t cgroup -o cpuset,release_agent="/sbin/cpuset_release_agent" \
380 xxx /sys/fs/cgroup/rg1
385 when the hierarchy consists of a single (root) cgroup. Supporting
387 cgroup hierarchy is intended to be implemented in the future.
389 Then under /sys/fs/cgroup/rg1 you can find a tree that corresponds to the
390 tree of the cgroups in the system. For instance, /sys/fs/cgroup/rg1
391 is the cgroup that holds the whole system.
394 # echo "/sbin/new_release_agent" > /sys/fs/cgroup/rg1/release_agent
398 If you want to create a new cgroup under /sys/fs/cgroup/rg1:
399 # cd /sys/fs/cgroup/rg1
402 Now you want to do something with this cgroup.
407 cgroup.procs notify_on_release tasks
410 Now attach your shell to this cgroup:
413 You can also create cgroups inside your cgroup by using mkdir in this
417 To remove a cgroup, just use rmdir:
420 This will fail if the cgroup is in use (has cgroups inside, or
441 You can use the cgroup.procs file instead of the tasks file to move all
443 threadgroup to cgroup.procs causes all tasks in that threadgroup to be
444 attached to the cgroup. Writing 0 to cgroup.procs moves all tasks
447 Note: Since every task is always a member of exactly one cgroup in each
448 mounted hierarchy, to remove a task from its current cgroup you must
449 move it into a new cgroup (possibly the root cgroup) by writing to the
450 new cgroup's tasks file.
452 Note: Due to some restrictions enforced by some cgroup subsystems, moving
453 a process to another cgroup can fail.
481 Each kernel subsystem that wants to hook into the generic cgroup
483 various methods, which are callbacks from the cgroup system, along
484 with a subsystem ID which will be assigned by the cgroup system.
489 entry in cgroup->subsys[] this subsystem should be managing.
497 Each cgroup object created by the system has an array of pointers,
499 subsystem; the generic cgroup code will never touch this pointer.
504 There is a global mutex, cgroup_mutex, used by the cgroup
506 cgroup. It may also be taken to prevent cgroups from being
510 See kernel/cgroup.c for more details.
515 Accessing a task's cgroup pointer may be done in the following ways:
537 struct cgroup_subsys_state *css_alloc(struct cgroup *cgrp)
540 Called to allocate a subsystem state object for a cgroup. The
542 cgroup, returning a pointer to the new object on success or a
546 cgroup system. Note that this will be called at initialization to
548 identified by the passed cgroup object having a NULL parent (since
552 int css_online(struct cgroup *cgrp)
562 void css_offline(struct cgroup *cgrp);
569 cgroup removal will proceed to the next step - css_free(). After this
572 void css_free(struct cgroup *cgrp)
575 The cgroup system is about to free @cgrp; the subsystem should free
578 be called for a newly-created cgroup if an error occurs after this
579 subsystem's create() method has been called for the new cgroup).
581 int can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
584 Called prior to moving one or more tasks into a cgroup; if the
595 Each @tset entry also contains the task's old cgroup and tasks which
596 aren't switching cgroup can be skipped easily using the
607 when a subsystem is disabled on a cgroup through
608 "cgroup.subtree_control" but should remain enabled because other
609 subsystems depend on it. cgroup core makes such a css invisible by
616 void cancel_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
625 void attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
628 Called after the task has been attached to the cgroup, to allow any
634 Called when a task is forked into a cgroup.
644 void bind(struct cgroup *root)
647 Called when a cgroup subsystem is rebound to a different hierarchy
648 and root cgroup. Currently this will only involve movement between
655 cgroup filesystem supports certain types of extended attributes in its
662 Like in tmpfs, the extended attributes in cgroup filesystem are stored
667 The current known users for this feature are SELinux to limit cgroup usage
668 in containers and systemd for assorted meta data like main PID in a cgroup
669 (systemd creates a cgroup per service).
676 errors. If you use it in the cgroup file system, you won't be