include/linux/cgroup.h
Source file repositories/reference/linux-study-clean/include/linux/cgroup.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/cgroup.h- Extension
.h- Size
- 29619 bytes
- Lines
- 927
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched.hlinux/nodemask.hlinux/list.hlinux/rculist.hlinux/cgroupstats.hlinux/fs.hlinux/seq_file.hlinux/kernfs.hlinux/jump_label.hlinux/types.hlinux/notifier.hlinux/ns_common.hlinux/nsproxy.hlinux/user_namespace.hlinux/refcount.hlinux/kernel_stat.hlinux/cgroup-defs.hlinux/cgroup_namespace.hlinux/cgroup_subsys.hlinux/cgroup_refcnt.h
Detected Declarations
struct kernel_clone_argsstruct css_task_iterstruct cgroup_subsys_statestruct cgroupenum css_task_iter_flagsenum cgroup_lifetime_eventsfunction my_update_statefunction cgroup_idfunction rcu_read_lockfunction css_is_dyingfunction css_is_onlinefunction css_is_selffunction cgroup_is_deadfunction cgroup_getfunction cgroup_trygetfunction cgroup_putfunction cgroup_lockfunction cgroup_unlockfunction task_lockfunction task_css_checkfunction thefunction task_css_is_rootfunction cgroup_is_descendantfunction task_under_cgroup_hierarchyfunction cgroup_has_tasksfunction css_is_populatedfunction cgroup_is_populatedfunction cgroup_inofunction cgroup_namefunction cgroup_pathfunction pr_cont_cgroup_namefunction pr_cont_cgroup_pathfunction cgroup_init_kthreaddfunction cgroup_kthread_readyfunction cgroup_idfunction css_getfunction cgroupstats_buildfunction cgroup_forkfunction cgroup_cancel_forkfunction cgroup_initfunction cgroup_init_kthreaddfunction cgroup_psi_enabledfunction task_under_cgroup_hierarchyfunction cgroup_path_from_kernfs_idfunction cpuacct_chargefunction cgroup_account_cputimefunction cgroup_account_cputime_fieldfunction cgroup_account_cputime
Annotated Snippet
struct css_task_iter {
struct cgroup_subsys *ss;
unsigned int flags;
struct list_head *cset_pos;
struct list_head *cset_head;
struct list_head *tcset_pos;
struct list_head *tcset_head;
struct list_head *task_pos;
struct list_head *cur_tasks_head;
struct css_set *cur_cset;
struct css_set *cur_dcset;
struct task_struct *cur_task;
struct list_head iters_node; /* css_set->task_iters */
};
enum cgroup_lifetime_events {
CGROUP_LIFETIME_ONLINE,
CGROUP_LIFETIME_OFFLINE,
};
extern struct file_system_type cgroup_fs_type;
extern struct cgroup_root cgrp_dfl_root;
extern struct css_set init_css_set;
extern struct mutex cgroup_mutex;
extern spinlock_t css_set_lock;
extern struct blocking_notifier_head cgroup_lifetime_notifier;
#define SUBSYS(_x) extern struct cgroup_subsys _x ## _cgrp_subsys;
#include <linux/cgroup_subsys.h>
#undef SUBSYS
#define SUBSYS(_x) \
extern struct static_key_true _x ## _cgrp_subsys_enabled_key; \
extern struct static_key_true _x ## _cgrp_subsys_on_dfl_key;
#include <linux/cgroup_subsys.h>
#undef SUBSYS
/**
* cgroup_subsys_enabled - fast test on whether a subsys is enabled
* @ss: subsystem in question
*/
#define cgroup_subsys_enabled(ss) \
static_branch_likely(&ss ## _enabled_key)
/**
* cgroup_subsys_on_dfl - fast test on whether a subsys is on default hierarchy
* @ss: subsystem in question
*/
#define cgroup_subsys_on_dfl(ss) \
static_branch_likely(&ss ## _on_dfl_key)
bool cgroup_on_dfl(const struct cgroup *cgrp);
bool css_has_online_children(struct cgroup_subsys_state *css);
struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgroup,
struct cgroup_subsys *ss);
struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup,
struct cgroup_subsys *ss);
struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
struct cgroup_subsys *ss);
struct cgroup *cgroup_get_from_path(const char *path);
struct cgroup *cgroup_get_from_fd(int fd);
struct cgroup *cgroup_v1v2_get_from_fd(int fd);
int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
int cgroup_rm_cftypes(struct cftype *cfts);
void cgroup_file_notify(struct cgroup_file *cfile);
void cgroup_file_show(struct cgroup_file *cfile, bool show);
int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *tsk);
void cgroup_fork(struct task_struct *p);
extern int cgroup_can_fork(struct task_struct *p,
struct kernel_clone_args *kargs);
extern void cgroup_cancel_fork(struct task_struct *p,
struct kernel_clone_args *kargs);
extern void cgroup_post_fork(struct task_struct *p,
Annotation
- Immediate include surface: `linux/sched.h`, `linux/nodemask.h`, `linux/list.h`, `linux/rculist.h`, `linux/cgroupstats.h`, `linux/fs.h`, `linux/seq_file.h`, `linux/kernfs.h`.
- Detected declarations: `struct kernel_clone_args`, `struct css_task_iter`, `struct cgroup_subsys_state`, `struct cgroup`, `enum css_task_iter_flags`, `enum cgroup_lifetime_events`, `function my_update_state`, `function cgroup_id`, `function rcu_read_lock`, `function css_is_dying`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.