]>
Commit | Line | Data |
---|---|---|
0a268dbd TH |
1 | #ifndef __CGROUP_INTERNAL_H |
2 | #define __CGROUP_INTERNAL_H | |
3 | ||
4 | #include <linux/cgroup.h> | |
5 | #include <linux/kernfs.h> | |
6 | #include <linux/workqueue.h> | |
7 | #include <linux/list.h> | |
8 | ||
9 | /* | |
10 | * A cgroup can be associated with multiple css_sets as different tasks may | |
11 | * belong to different cgroups on different hierarchies. In the other | |
12 | * direction, a css_set is naturally associated with multiple cgroups. | |
13 | * This M:N relationship is represented by the following link structure | |
14 | * which exists for each association and allows traversing the associations | |
15 | * from both sides. | |
16 | */ | |
17 | struct cgrp_cset_link { | |
18 | /* the cgroup and css_set this link associates */ | |
19 | struct cgroup *cgrp; | |
20 | struct css_set *cset; | |
21 | ||
22 | /* list of cgrp_cset_links anchored at cgrp->cset_links */ | |
23 | struct list_head cset_link; | |
24 | ||
25 | /* list of cgrp_cset_links anchored at css_set->cgrp_links */ | |
26 | struct list_head cgrp_link; | |
27 | }; | |
28 | ||
29 | extern struct mutex cgroup_mutex; | |
30 | extern spinlock_t css_set_lock; | |
31 | extern struct cgroup_subsys *cgroup_subsys[]; | |
32 | extern struct list_head cgroup_roots; | |
33 | extern struct file_system_type cgroup_fs_type; | |
34 | ||
35 | /* iterate across the hierarchies */ | |
36 | #define for_each_root(root) \ | |
37 | list_for_each_entry((root), &cgroup_roots, root_list) | |
38 | ||
39 | /** | |
40 | * for_each_subsys - iterate all enabled cgroup subsystems | |
41 | * @ss: the iteration cursor | |
42 | * @ssid: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end | |
43 | */ | |
44 | #define for_each_subsys(ss, ssid) \ | |
45 | for ((ssid) = 0; (ssid) < CGROUP_SUBSYS_COUNT && \ | |
46 | (((ss) = cgroup_subsys[ssid]) || true); (ssid)++) | |
47 | ||
48 | static inline bool cgroup_is_dead(const struct cgroup *cgrp) | |
49 | { | |
50 | return !(cgrp->self.flags & CSS_ONLINE); | |
51 | } | |
52 | ||
53 | static inline bool notify_on_release(const struct cgroup *cgrp) | |
54 | { | |
55 | return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); | |
56 | } | |
57 | ||
58 | bool cgroup_ssid_enabled(int ssid); | |
59 | bool cgroup_on_dfl(const struct cgroup *cgrp); | |
60 | ||
61 | struct cgroup_root *cgroup_root_from_kf(struct kernfs_root *kf_root); | |
62 | struct cgroup *task_cgroup_from_root(struct task_struct *task, | |
63 | struct cgroup_root *root); | |
64 | struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn, bool drain_offline); | |
65 | void cgroup_kn_unlock(struct kernfs_node *kn); | |
66 | int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen, | |
67 | struct cgroup_namespace *ns); | |
68 | ||
69 | int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask); | |
70 | ||
71 | bool cgroup_may_migrate_to(struct cgroup *dst_cgrp); | |
72 | void cgroup_migrate_finish(struct list_head *preloaded_csets); | |
73 | void cgroup_migrate_add_src(struct css_set *src_cset, | |
74 | struct cgroup *dst_cgrp, | |
75 | struct list_head *preloaded_csets); | |
76 | int cgroup_migrate_prepare_dst(struct list_head *preloaded_csets); | |
77 | int cgroup_migrate(struct task_struct *leader, bool threadgroup, | |
78 | struct cgroup_root *root); | |
79 | ||
80 | int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader, | |
81 | bool threadgroup); | |
82 | ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, | |
83 | size_t nbytes, loff_t off, bool threadgroup); | |
84 | ssize_t cgroup_procs_write(struct kernfs_open_file *of, char *buf, size_t nbytes, | |
85 | loff_t off); | |
86 | ||
87 | void cgroup_lock_and_drain_offline(struct cgroup *cgrp); | |
88 | ||
89 | /* | |
90 | * cgroup-v1.c | |
91 | */ | |
92 | extern spinlock_t release_agent_path_lock; | |
93 | extern struct cftype cgroup_legacy_base_files[]; | |
94 | extern const struct file_operations proc_cgroupstats_operations; | |
95 | ||
96 | bool cgroup_ssid_no_v1(int ssid); | |
97 | void cgroup_pidlist_destroy_all(struct cgroup *cgrp); | |
98 | int cgroup_rename(struct kernfs_node *kn, struct kernfs_node *new_parent, | |
99 | const char *new_name_str); | |
100 | void cgroup_release_agent(struct work_struct *work); | |
101 | void check_for_release(struct cgroup *cgrp); | |
102 | ||
103 | #endif /* __CGROUP_INTERNAL_H */ |