Linux Kernel
3.7.1
|
#include <linux/cgroup.h>
#include <linux/cred.h>
#include <linux/ctype.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/init_task.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/mutex.h>
#include <linux/mount.h>
#include <linux/pagemap.h>
#include <linux/proc_fs.h>
#include <linux/rcupdate.h>
#include <linux/sched.h>
#include <linux/backing-dev.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/magic.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/sort.h>
#include <linux/kmod.h>
#include <linux/module.h>
#include <linux/delayacct.h>
#include <linux/cgroupstats.h>
#include <linux/hash.h>
#include <linux/namei.h>
#include <linux/pid_namespace.h>
#include <linux/idr.h>
#include <linux/vmalloc.h>
#include <linux/eventfd.h>
#include <linux/poll.h>
#include <linux/flex_array.h>
#include <linux/kthread.h>
#include <linux/atomic.h>
#include <linux/cgroup_subsys.h>
Go to the source code of this file.
Data Structures | |
struct | cgroupfs_root |
struct | cfent |
struct | css_id |
struct | cgroup_event |
struct | cg_cgroup_link |
struct | cgroup_sb_opts |
struct | task_and_cgroup |
struct | cgroup_taskset |
struct | cgroup_seqfile_state |
struct | cgroup_pidlist |
Macros | |
#define | CSS_DEACT_BIAS INT_MIN |
#define | SUBSYS(_x) [_x ## _subsys_id] = &_x ## _subsys, |
#define | IS_SUBSYS_ENABLED(option) IS_BUILTIN(option) |
#define | MAX_CGROUP_ROOT_NAMELEN 64 |
#define | CSS_ID_MAX (65535) |
#define | dummytop (&rootnode.top_cgroup) |
#define | for_each_subsys(_root, _ss) list_for_each_entry(_ss, &_root->subsys_list, sibling) |
#define | for_each_active_root(_root) list_for_each_entry(_root, &roots, root_list) |
#define | CSS_SET_HASH_BITS 7 |
#define | CSS_SET_TABLE_SIZE (1 << CSS_SET_HASH_BITS) |
#define | CGROUP_LOCAL_BUFFER_SIZE 64 |
#define | PIDLIST_TOO_LARGE(c) ((c) * sizeof(pid_t) > (PAGE_SIZE * 2)) |
#define | PIDLIST_REALLOC_DIFFERENCE(old, new) ((old) - PAGE_SIZE >= (new)) |
#define | CGROUP_FILE_GENERIC_PREFIX "cgroup." |
Enumerations | |
enum | { ROOT_NOPREFIX, ROOT_XATTR } |
enum | cgroup_filetype { CGROUP_FILE_PROCS, CGROUP_FILE_TASKS } |
Variables | |
struct file_operations | proc_cgroup_operations |
#define CSS_SET_TABLE_SIZE (1 << CSS_SET_HASH_BITS) |
#define for_each_active_root | ( | _root | ) | list_for_each_entry(_root, &roots, root_list) |
#define for_each_subsys | ( | _root, | |
_ss | |||
) | list_for_each_entry(_ss, &_root->subsys_list, sibling) |
#define IS_SUBSYS_ENABLED | ( | option | ) | IS_BUILTIN(option) |
#define PIDLIST_REALLOC_DIFFERENCE | ( | old, | |
new | |||
) | ((old) - PAGE_SIZE >= (new)) |
enum cgroup_filetype |
__setup | ( | ) |
cgroup_add_cftypes - add an array of cftypes to a subsystem : target cgroup subsystem : zero-length name terminated array of cftypes
Register to . Files described by are created for all existing cgroups to which is attached and all future cgroups will have them too. This function can be called anytime whether is attached or not.
Returns 0 on successful registration, -errno on failure. Note that this function currently returns 0 as long as registration is successful even if some file creation attempts on existing cgroups fail.
int cgroup_attach_task | ( | struct cgroup * | cgrp, |
struct task_struct * | tsk | ||
) |
int cgroup_attach_task_all | ( | struct task_struct * | from, |
struct task_struct * | tsk | ||
) |
void cgroup_exit | ( | struct task_struct * | tsk, |
int | run_callbacks | ||
) |
cgroup_exit - detach cgroup from exiting task : pointer to task_struct of exiting process : run exit callbacks?
Description: Detach cgroup from and release it.
Note that cgroups marked notify_on_release force every task in them to take the global cgroup_mutex mutex when exiting. This could impact scaling on very large systems. Be reluctant to use notify_on_release cgroups where very high task exit scaling is required on large systems.
the_top_cgroup_hack:
Set the exiting tasks cgroup to the root cgroup (top_cgroup).
We call cgroup_exit() while the task is still competent to handle notify_on_release(), then leave the task attached to the root cgroup in each hierarchy for the remainder of its exit.
To do this properly, we would increment the reference count on top_cgroup, and near the very end of the kernel/exit.c do_exit() code we would add a second cgroup function call, to drop that reference. This would just create an unnecessary hot spot on the top_cgroup reference count, to no avail.
Normally, holding a reference to a cgroup without bumping its count is unsafe. The cgroup could go away, or someone could attach us to a different cgroup, decrementing the count on the first cgroup that we never incremented. But in this case, top_cgroup isn't going away, and either task has PF_EXITING set, which wards off any cgroup_attach_task() attempts, or task is a failed fork, never visible to cgroup_attach_task.
void cgroup_fork | ( | struct task_struct * | child | ) |
cgroup_fork - attach newly forked task to its parents cgroup. : pointer to task_struct of forking parent process.
Description: A task inherits its parent's cgroup at fork().
A pointer to the shared css_set was automatically copied in fork.c by dup_task_struct(). However, we ignore that copy, since it was not made under the protection of RCU or cgroup_mutex, so might no longer be a valid cgroup pointer. cgroup_attach_task() might have already changed current->cgroups, allowing the previously referenced cgroup group to be removed and freed.
At the point that cgroup_fork() is called, 'current' is the parent task, and the passed argument 'child' points to the child task.
void cgroup_fork_callbacks | ( | struct task_struct * | child | ) |
int cgroup_is_descendant | ( | const struct cgroup * | cgrp, |
struct task_struct * | task | ||
) |
cgroup_is_descendant - see if is a descendant of 's cgrp : the cgroup in question : the task in question
See if is a descendant of 's cgroup in the appropriate hierarchy.
If we are sending in dummytop, then presumably we are creating the top cgroup in the subsystem.
Called only by the ns (nsproxy) cgroup.
|
read |
int __init_or_module cgroup_load_subsys | ( | struct cgroup_subsys * | ss | ) |
cgroup_load_subsys: load and register a modular subsystem at runtime : the subsystem to load
This function should be called in a modular subsystem's initcall. If the subsystem is built as a module, it will be assigned a new subsys_id and set up for use. If the subsystem is built-in anyway, work is delegated to the simpler cgroup_init_subsys.
cgroup_lock_live_group - take cgroup_mutex and check that cgrp is alive. : the cgroup to be checked for liveness
On success, returns true; the lock should be later released with cgroup_unlock(). On failure returns false with no lock held.
void cgroup_post_fork | ( | struct task_struct * | child | ) |
cgroup_post_fork - called on a new task after adding it to the task list : the task in question
Adds the task to the list running through its css_set if necessary. Has to be after the task is visible on the task list in case we race with the first call to cgroup_iter_start() - to guarantee that the new task ends up on its list.
cgroup_rm_cftypes - remove an array of cftypes from a subsystem : target cgroup subsystem : zero-length name terminated array of cftypes
Unregister from . Files described by are removed from all existing cgroups to which is attached and all future cgroups won't have them either. This function can be called anytime whether is attached or not.
Returns 0 on successful unregistration, -ENOENT if is not registered with .
cgroup_scan_tasks - iterate though all the tasks in a cgroup : struct cgroup_scanner containing arguments for the scan
Arguments include pointers to callback functions test_task() and process_task(). Iterate through all the tasks in a cgroup, calling test_task() for each, and if it returns true, call process_task() for it also. The test_task pointer may be NULL, meaning always true (select all tasks). Effectively duplicates cgroup_iter_{start,next,end}() but does not lock css_set_lock for the call to process_task(). The struct cgroup_scanner may be embedded in any structure of the caller's creation. It is guaranteed that process_task() will act on every task that is a member of the cgroup for the duration of this call. This function may or may not call process_task() for tasks that exit or move to a different cgroup during the call, or are forked or move into the cgroup during the call.
Note that test_task() may be called with locks held, and may in some situations be called multiple times for the same task, so it should be cheap. If the heap pointer in the struct cgroup_scanner is non-NULL, a heap has been pre-allocated and will be used for heap operations (and its "gt" member will be overwritten), else a temporary heap will be used (allocation of which may cause this function to fail).
|
read |
cgroup_taskset_cur_cgroup - return the matching cgroup for the current task : taskset of interest
Return the cgroup for the current (last returned) task of . This function must be preceded by either cgroup_taskset_first() or cgroup_taskset_next().
|
read |
|
read |
cgroup_taskset_next - iterate to the next task in taskset : taskset of interest
Return the next task in . Iteration must have been initialized with cgroup_taskset_first().
int cgroup_taskset_size | ( | struct cgroup_taskset * | tset | ) |
cgroup_unlock - release lock on cgroup changes
Undo the lock taken in a previous cgroup_lock() call.
int cgroupstats_build | ( | struct cgroupstats * | stats, |
struct dentry * | dentry | ||
) |
|
read |
css_get_next - lookup next cgroup under specified hierarchy. : pointer to subsystem : current position of iteration. : pointer to css. search tree under this. : position of found object.
Search next css under the specified hierarchy of rootid. Calling under rcu_read_lock() is necessary. Returns NULL if it reaches the end.
bool css_is_ancestor | ( | struct cgroup_subsys_state * | child, |
const struct cgroup_subsys_state * | root | ||
) |
css_is_ancestor - test "root" css is an ancestor of "child" : the css to be tested. : the css supporsed to be an ancestor of the child.
Returns true if "root" is an ancestor of "child" in its hierarchy. Because this function reads css->id, the caller must hold rcu_read_lock(). But, considering usual usage, the csses should be valid objects after test. Assuming that the caller will do some action to the child if this returns returns true, the caller must take "child";s reference count. If "child" is valid object and this returns true, "root" is valid, too.
EXPORT_SYMBOL_GPL | ( | cgroup_lock_is_held | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_lock | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_unlock | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_path | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_taskset_first | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_taskset_next | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_taskset_cur_cgroup | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_taskset_size | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_attach_task_all | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_lock_live_group | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_add_cftypes | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_load_subsys | ) |
EXPORT_SYMBOL_GPL | ( | cgroup_unload_subsys | ) |
EXPORT_SYMBOL_GPL | ( | __css_tryget | ) |
EXPORT_SYMBOL_GPL | ( | __css_put | ) |
EXPORT_SYMBOL_GPL | ( | css_id | ) |
EXPORT_SYMBOL_GPL | ( | css_depth | ) |
EXPORT_SYMBOL_GPL | ( | free_css_id | ) |
EXPORT_SYMBOL_GPL | ( | css_lookup | ) |
struct file_operations proc_cgroup_operations |