]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - kernel/cgroup/cgroup-internal.h
cgroup: move cgroup v1 specific code to kernel/cgroup/cgroup-v1.c
[mirror_ubuntu-artful-kernel.git] / kernel / cgroup / cgroup-internal.h
CommitLineData
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 */
17struct 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
29extern struct mutex cgroup_mutex;
30extern spinlock_t css_set_lock;
31extern struct cgroup_subsys *cgroup_subsys[];
32extern struct list_head cgroup_roots;
33extern 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
48static inline bool cgroup_is_dead(const struct cgroup *cgrp)
49{
50 return !(cgrp->self.flags & CSS_ONLINE);
51}
52
53static inline bool notify_on_release(const struct cgroup *cgrp)
54{
55 return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
56}
57
58bool cgroup_ssid_enabled(int ssid);
59bool cgroup_on_dfl(const struct cgroup *cgrp);
60
61struct cgroup_root *cgroup_root_from_kf(struct kernfs_root *kf_root);
62struct cgroup *task_cgroup_from_root(struct task_struct *task,
63 struct cgroup_root *root);
64struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn, bool drain_offline);
65void cgroup_kn_unlock(struct kernfs_node *kn);
66int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
67 struct cgroup_namespace *ns);
68
69int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
70
71bool cgroup_may_migrate_to(struct cgroup *dst_cgrp);
72void cgroup_migrate_finish(struct list_head *preloaded_csets);
73void cgroup_migrate_add_src(struct css_set *src_cset,
74 struct cgroup *dst_cgrp,
75 struct list_head *preloaded_csets);
76int cgroup_migrate_prepare_dst(struct list_head *preloaded_csets);
77int cgroup_migrate(struct task_struct *leader, bool threadgroup,
78 struct cgroup_root *root);
79
80int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
81 bool threadgroup);
82ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
83 size_t nbytes, loff_t off, bool threadgroup);
84ssize_t cgroup_procs_write(struct kernfs_open_file *of, char *buf, size_t nbytes,
85 loff_t off);
86
87void cgroup_lock_and_drain_offline(struct cgroup *cgrp);
88
89/*
90 * cgroup-v1.c
91 */
92extern spinlock_t release_agent_path_lock;
93extern struct cftype cgroup_legacy_base_files[];
94extern const struct file_operations proc_cgroupstats_operations;
95
96bool cgroup_ssid_no_v1(int ssid);
97void cgroup_pidlist_destroy_all(struct cgroup *cgrp);
98int cgroup_rename(struct kernfs_node *kn, struct kernfs_node *new_parent,
99 const char *new_name_str);
100void cgroup_release_agent(struct work_struct *work);
101void check_for_release(struct cgroup *cgrp);
102
103#endif /* __CGROUP_INTERNAL_H */