^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __CGROUP_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __CGROUP_INTERNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/cgroup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/kernfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/workqueue.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/fs_parser.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define TRACE_CGROUP_PATH_LEN 1024
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) extern spinlock_t trace_cgroup_path_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) extern char trace_cgroup_path[TRACE_CGROUP_PATH_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) extern bool cgroup_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) extern void __init enable_debug_cgroup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * cgroup_path() takes a spin lock. It is good practice not to take
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * spin locks within trace point handlers, as they are mostly hidden
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * from normal view. As cgroup_path() can take the kernfs_rename_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * spin lock, it is best to not call that function from the trace event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * Note: trace_cgroup_##type##_enabled() is a static branch that will only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * be set when the trace event is enabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define TRACE_CGROUP_PATH(type, cgrp, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (trace_cgroup_##type##_enabled()) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) unsigned long flags; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) spin_lock_irqsave(&trace_cgroup_path_lock, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) flags); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) cgroup_path(cgrp, trace_cgroup_path, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) TRACE_CGROUP_PATH_LEN); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) trace_cgroup_##type(cgrp, trace_cgroup_path, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) spin_unlock_irqrestore(&trace_cgroup_path_lock, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) flags); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * The cgroup filesystem superblock creation/mount context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct cgroup_fs_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct kernfs_fs_context kfc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct cgroup_root *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct cgroup_namespace *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned int flags; /* CGRP_ROOT_* flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* cgroup1 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) bool cpuset_clone_children;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) bool none; /* User explicitly requested empty subsystem */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) bool all_ss; /* Seen 'all' option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u16 subsys_mask; /* Selected subsystems */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) char *name; /* Hierarchy name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) char *release_agent; /* Path for release notifications */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static inline struct cgroup_fs_context *cgroup_fc2context(struct fs_context *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct kernfs_fs_context *kfc = fc->fs_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) return container_of(kfc, struct cgroup_fs_context, kfc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct cgroup_pidlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct cgroup_file_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct cgroup_namespace *ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void *trigger;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) } psi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) bool started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct css_task_iter iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) } procs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct cgroup_pidlist *pidlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) } procs1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * A cgroup can be associated with multiple css_sets as different tasks may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * belong to different cgroups on different hierarchies. In the other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * direction, a css_set is naturally associated with multiple cgroups.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * This M:N relationship is represented by the following link structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * which exists for each association and allows traversing the associations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * from both sides.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct cgrp_cset_link {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /* the cgroup and css_set this link associates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct cgroup *cgrp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct css_set *cset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* list of cgrp_cset_links anchored at cgrp->cset_links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct list_head cset_link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /* list of cgrp_cset_links anchored at css_set->cgrp_links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct list_head cgrp_link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* used to track tasks and csets during migration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct cgroup_taskset {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* the src and dst cset list running through cset->mg_node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct list_head src_csets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct list_head dst_csets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* the number of tasks in the set */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int nr_tasks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /* the subsys currently being processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int ssid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * Fields for cgroup_taskset_*() iteration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * Before migration is committed, the target migration tasks are on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * ->mg_tasks of the csets on ->src_csets. After, on ->mg_tasks of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * the csets on ->dst_csets. ->csets point to either ->src_csets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * or ->dst_csets depending on whether migration is committed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * ->cur_csets and ->cur_task point to the current task position
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * during iteration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct list_head *csets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct css_set *cur_cset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct task_struct *cur_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /* migration context also tracks preloading */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct cgroup_mgctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * Preloaded source and destination csets. Used to guarantee
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * atomic success or failure on actual migration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct list_head preloaded_src_csets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct list_head preloaded_dst_csets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* tasks and csets to migrate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct cgroup_taskset tset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /* subsystems affected by migration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) u16 ss_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #define CGROUP_TASKSET_INIT(tset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) .src_csets = LIST_HEAD_INIT(tset.src_csets), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .dst_csets = LIST_HEAD_INIT(tset.dst_csets), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .csets = &tset.src_csets, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define CGROUP_MGCTX_INIT(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) LIST_HEAD_INIT(name.preloaded_src_csets), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) LIST_HEAD_INIT(name.preloaded_dst_csets), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) CGROUP_TASKSET_INIT(name.tset), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define DEFINE_CGROUP_MGCTX(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct cgroup_mgctx name = CGROUP_MGCTX_INIT(name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) extern struct mutex cgroup_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) extern spinlock_t css_set_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) extern struct cgroup_subsys *cgroup_subsys[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) extern struct list_head cgroup_roots;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) extern struct file_system_type cgroup_fs_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* iterate across the hierarchies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #define for_each_root(root) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) list_for_each_entry((root), &cgroup_roots, root_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * for_each_subsys - iterate all enabled cgroup subsystems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * @ss: the iteration cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * @ssid: the index of @ss, CGROUP_SUBSYS_COUNT after reaching the end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) #define for_each_subsys(ss, ssid) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) for ((ssid) = 0; (ssid) < CGROUP_SUBSYS_COUNT && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) (((ss) = cgroup_subsys[ssid]) || true); (ssid)++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static inline bool cgroup_is_dead(const struct cgroup *cgrp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return !(cgrp->self.flags & CSS_ONLINE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static inline bool notify_on_release(const struct cgroup *cgrp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return test_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) void put_css_set_locked(struct css_set *cset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static inline void put_css_set(struct css_set *cset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) * Ensure that the refcount doesn't hit zero while any readers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * can see it. Similar to atomic_dec_and_lock(), but for an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) * rwlock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (refcount_dec_not_one(&cset->refcount))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) spin_lock_irqsave(&css_set_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) put_css_set_locked(cset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) spin_unlock_irqrestore(&css_set_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * refcounted get/put for css_set objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static inline void get_css_set(struct css_set *cset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) refcount_inc(&cset->refcount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) bool cgroup_ssid_enabled(int ssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) bool cgroup_on_dfl(const struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) bool cgroup_is_thread_root(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) bool cgroup_is_threaded(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) struct cgroup_root *cgroup_root_from_kf(struct kernfs_root *kf_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct cgroup *task_cgroup_from_root(struct task_struct *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct cgroup_root *root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) struct cgroup *cgroup_kn_lock_live(struct kernfs_node *kn, bool drain_offline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void cgroup_kn_unlock(struct kernfs_node *kn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) int cgroup_path_ns_locked(struct cgroup *cgrp, char *buf, size_t buflen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct cgroup_namespace *ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) void cgroup_free_root(struct cgroup_root *root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void init_cgroup_root(struct cgroup_fs_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int cgroup_do_get_tree(struct fs_context *fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) void cgroup_migrate_finish(struct cgroup_mgctx *mgctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) void cgroup_migrate_add_src(struct css_set *src_cset, struct cgroup *dst_cgrp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct cgroup_mgctx *mgctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) int cgroup_migrate_prepare_dst(struct cgroup_mgctx *mgctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) int cgroup_migrate(struct task_struct *leader, bool threadgroup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct cgroup_mgctx *mgctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) bool threadgroup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) bool *locked,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct cgroup *dst_cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) __acquires(&cgroup_threadgroup_rwsem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) void cgroup_procs_write_finish(struct task_struct *task, bool locked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) __releases(&cgroup_threadgroup_rwsem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) void cgroup_lock_and_drain_offline(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) int cgroup_rmdir(struct kernfs_node *kn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct kernfs_root *kf_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) int __cgroup_task_count(const struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) int cgroup_task_count(const struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * rstat.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int cgroup_rstat_init(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) void cgroup_rstat_exit(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) void cgroup_rstat_boot(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) void cgroup_base_stat_cputime_show(struct seq_file *seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * namespace.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) extern const struct proc_ns_operations cgroupns_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * cgroup-v1.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) extern struct cftype cgroup1_base_files[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) extern const struct fs_parameter_spec cgroup1_fs_parameters[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int proc_cgroupstats_show(struct seq_file *m, void *v);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) bool cgroup1_ssid_disabled(int ssid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) void cgroup1_pidlist_destroy_all(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) void cgroup1_release_agent(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) void cgroup1_check_for_release(struct cgroup *cgrp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) int cgroup1_get_tree(struct fs_context *fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) int cgroup1_reconfigure(struct fs_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #endif /* __CGROUP_INTERNAL_H */