hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/kernel/cgroup/cgroup-internal.h
....@@ -7,10 +7,13 @@
77 #include <linux/workqueue.h>
88 #include <linux/list.h>
99 #include <linux/refcount.h>
10
+#include <linux/fs_parser.h>
1011
1112 #define TRACE_CGROUP_PATH_LEN 1024
1213 extern spinlock_t trace_cgroup_path_lock;
1314 extern char trace_cgroup_path[TRACE_CGROUP_PATH_LEN];
15
+extern bool cgroup_debug;
16
+extern void __init enable_debug_cgroup(void);
1417
1518 /*
1619 * cgroup_path() takes a spin lock. It is good practice not to take
....@@ -25,14 +28,61 @@
2528 #define TRACE_CGROUP_PATH(type, cgrp, ...) \
2629 do { \
2730 if (trace_cgroup_##type##_enabled()) { \
28
- spin_lock(&trace_cgroup_path_lock); \
31
+ unsigned long flags; \
32
+ spin_lock_irqsave(&trace_cgroup_path_lock, \
33
+ flags); \
2934 cgroup_path(cgrp, trace_cgroup_path, \
3035 TRACE_CGROUP_PATH_LEN); \
3136 trace_cgroup_##type(cgrp, trace_cgroup_path, \
3237 ##__VA_ARGS__); \
33
- spin_unlock(&trace_cgroup_path_lock); \
38
+ spin_unlock_irqrestore(&trace_cgroup_path_lock, \
39
+ flags); \
3440 } \
3541 } while (0)
42
+
43
+/*
44
+ * The cgroup filesystem superblock creation/mount context.
45
+ */
46
+struct cgroup_fs_context {
47
+ struct kernfs_fs_context kfc;
48
+ struct cgroup_root *root;
49
+ struct cgroup_namespace *ns;
50
+ unsigned int flags; /* CGRP_ROOT_* flags */
51
+
52
+ /* cgroup1 bits */
53
+ bool cpuset_clone_children;
54
+ bool none; /* User explicitly requested empty subsystem */
55
+ bool all_ss; /* Seen 'all' option */
56
+ u16 subsys_mask; /* Selected subsystems */
57
+ char *name; /* Hierarchy name */
58
+ char *release_agent; /* Path for release notifications */
59
+};
60
+
61
+static inline struct cgroup_fs_context *cgroup_fc2context(struct fs_context *fc)
62
+{
63
+ struct kernfs_fs_context *kfc = fc->fs_private;
64
+
65
+ return container_of(kfc, struct cgroup_fs_context, kfc);
66
+}
67
+
68
+struct cgroup_pidlist;
69
+
70
+struct cgroup_file_ctx {
71
+ struct cgroup_namespace *ns;
72
+
73
+ struct {
74
+ void *trigger;
75
+ } psi;
76
+
77
+ struct {
78
+ bool started;
79
+ struct css_task_iter iter;
80
+ } procs;
81
+
82
+ struct {
83
+ struct cgroup_pidlist *pidlist;
84
+ } procs1;
85
+};
3686
3787 /*
3888 * A cgroup can be associated with multiple css_sets as different tasks may
....@@ -115,21 +165,10 @@
115165 #define DEFINE_CGROUP_MGCTX(name) \
116166 struct cgroup_mgctx name = CGROUP_MGCTX_INIT(name)
117167
118
-struct cgroup_sb_opts {
119
- u16 subsys_mask;
120
- unsigned int flags;
121
- char *release_agent;
122
- bool cpuset_clone_children;
123
- char *name;
124
- /* User explicitly requested empty subsystem */
125
- bool none;
126
-};
127
-
128168 extern struct mutex cgroup_mutex;
129169 extern spinlock_t css_set_lock;
130170 extern struct cgroup_subsys *cgroup_subsys[];
131171 extern struct list_head cgroup_roots;
132
-extern struct file_system_type cgroup_fs_type;
133172
134173 /* iterate across the hierarchies */
135174 #define for_each_root(root) \
....@@ -195,12 +234,10 @@
195234 struct cgroup_namespace *ns);
196235
197236 void cgroup_free_root(struct cgroup_root *root);
198
-void init_cgroup_root(struct cgroup_root *root, struct cgroup_sb_opts *opts);
237
+void init_cgroup_root(struct cgroup_fs_context *ctx);
199238 int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask);
200239 int rebind_subsystems(struct cgroup_root *dst_root, u16 ss_mask);
201
-struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags,
202
- struct cgroup_root *root, unsigned long magic,
203
- struct cgroup_namespace *ns);
240
+int cgroup_do_get_tree(struct fs_context *fc);
204241
205242 int cgroup_migrate_vet_dst(struct cgroup *dst_cgrp);
206243 void cgroup_migrate_finish(struct cgroup_mgctx *mgctx);
....@@ -212,9 +249,11 @@
212249
213250 int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
214251 bool threadgroup);
215
-struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup)
252
+struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
253
+ bool *locked,
254
+ struct cgroup *dst_cgrp);
216255 __acquires(&cgroup_threadgroup_rwsem);
217
-void cgroup_procs_write_finish(struct task_struct *task)
256
+void cgroup_procs_write_finish(struct task_struct *task, bool locked)
218257 __releases(&cgroup_threadgroup_rwsem);
219258
220259 void cgroup_lock_and_drain_offline(struct cgroup *cgrp);
....@@ -245,14 +284,15 @@
245284 */
246285 extern struct cftype cgroup1_base_files[];
247286 extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops;
287
+extern const struct fs_parameter_spec cgroup1_fs_parameters[];
248288
249289 int proc_cgroupstats_show(struct seq_file *m, void *v);
250290 bool cgroup1_ssid_disabled(int ssid);
251291 void cgroup1_pidlist_destroy_all(struct cgroup *cgrp);
252292 void cgroup1_release_agent(struct work_struct *work);
253293 void cgroup1_check_for_release(struct cgroup *cgrp);
254
-struct dentry *cgroup1_mount(struct file_system_type *fs_type, int flags,
255
- void *data, unsigned long magic,
256
- struct cgroup_namespace *ns);
294
+int cgroup1_parse_param(struct fs_context *fc, struct fs_parameter *param);
295
+int cgroup1_get_tree(struct fs_context *fc);
296
+int cgroup1_reconfigure(struct fs_context *ctx);
257297
258298 #endif /* __CGROUP_INTERNAL_H */