#ifdef CONFIG_CGROUPS /* Control Group info protected by css_set_lock */ structcss_set __rcu *cgroups; /* cg_list protected by css_set_lock and tsk->alloc_lock */ structlist_headcg_list; #endif
/* 由系统维护的每进程 / 每 cgroup 的状态 */ structcgroup_subsys_state { /* * The cgroup that this subsystem is attached to. Useful * for subsystems that want to know about the cgroup * hierarchy structure */ structcgroup *cgroup;
/* * State maintained by the cgroup system to allow subsystems * to be "busy". Should be accessed via css_get(), * css_tryget() and css_put(). */ atomic_t refcnt;
unsignedlong flags; /* ID for this css, if possible */ structcss_id __rcu *id;
/* Used to put @cgroup->dentry on the last css_put() */ structwork_structdput_work; }
structcgroup { unsignedlong flags; /* "unsigned long" so bitops work */
/* * count users of this cgroup. >0 means busy, but doesn't * necessarily indicate the number of tasks in the cgroup */ atomic_t count;
int id; /* ida 分配的层级内的 ID 号 */
/* sibling, children, parent 利用兄弟孩子表示法将层级的 cgroup 构成一颗树。 * We link our 'sibling' struct into our parent's 'children'. * Our children link their 'sibling' into our 'children'. */ structlist_headsibling;/* my parent's children */ structlist_headchildren;/* my children */ structlist_headfiles;/* my files */
/* * This is a copy of dentry->d_name, and it's needed because * we can't use dentry->d_name in cgroup_path(). * * You must acquire rcu_read_lock() to access cgrp->name, and * the only place that can change it is rename(), which is * protected by parent dir's i_mutex. * * Normally you should use cgroup_name() wrapper rather than * access it directly. */ structcgroup_name __rcu *name;
/* * List of cg_cgroup_links pointing at css_sets with * tasks in this cgroup. Protected by css_set_lock */ structlist_headcss_sets;
structlist_headallcg_node;/* cgroupfs_root->allcg_list */ structlist_headcft_q_node;/* used during cftype add/rm */
/* * Linked list running through all cgroups that can * potentially be reaped by the release agent. Protected by * release_list_lock */ structlist_headrelease_list;
/* * list of pidlists, up to two for each namespace (one for procs, one * for tasks); created on demand. */ structlist_headpidlists; structmutexpidlist_mutex;
/* For RCU-protected deletion */ structrcu_headrcu_head; structwork_structfree_work;
/* Link to parent, and list entry in parent's children. Protected by cgroup_lock() */ structcgroupfs_root *root; structlist_headsibling; /* used when use_id == true */ structidridr; spinlock_t id_lock;
/* list of cftype_sets */ structlist_headcftsets;
/* base cftypes, automatically [de]registered with subsys itself */ structcftype *base_cftypes; structcftype_setbase_cftset;
/* should be defined only by modular subsystems */ structmodule *module; };
结构体是各子系统的抽象,其中包含各子系统操作的交集。 在实践具体子系统时候填充抽象中定义且需要的部分 (面向对象的 C 在 kernel 中大量使用).