xref: /DragonOS/kernel/src/cgroup/mod.rs (revision 7b0ef10895108a0de5ff5ef3d2f93f40cf2e33a5)
1 #![allow(dead_code, unused_variables, unused_imports)]
2 pub mod mem_cgroup;
3 
4 use alloc::{collections::LinkedList, rc::Weak, sync::Arc, vec::Vec};
5 
6 use alloc::boxed::Box;
7 
8 use crate::filesystem::vfs::IndexNode;
9 
10 pub struct Cgroup {
11     css: Weak<CgroupSubsysState>,
12     /// 当前所在的深度
13     level: u32,
14     /// 支持的最大深度
15     max_depth: u32,
16     /// 可见后代数量
17     nr_descendants: u32,
18     /// 正在死亡后代数量
19     nr_dying_descendants: u32,
20     /// 允许的最大后代数量
21     max_descendants: u32,
22     /// css_set的数量
23     nr_populated_csets: u32,
24     /// 子group中有任务的记数
25     nr_populated_domain_children: u32,
26     /// 线程子group中有任务的记数
27     nr_populated_threaded_children: u32,
28     /// 活跃线程子cgroup数量
29     nr_threaded_children: u32,
30     /// 关联cgroup的inode
31     kernfs_node: Box<dyn IndexNode>,
32 }
33 
34 /// 控制资源的统计信息
35 pub struct CgroupSubsysState {
36     cgroup: Arc<Cgroup>,
37     /// 兄弟节点
38     sibling: LinkedList<Arc<Cgroup>>,
39     /// 孩子节点
40     children: LinkedList<Arc<Cgroup>>,
41 }
42 
43 pub struct CgroupSubsys {}
44 
45 /// cgroup_sub_state 的集合
46 pub struct CssSet {
47     subsys: Vec<Arc<CgroupSubsysState>>,
48 }
49