hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/include/linux/cgroup.h
....@@ -24,8 +24,11 @@
2424 #include <linux/user_namespace.h>
2525 #include <linux/refcount.h>
2626 #include <linux/kernel_stat.h>
27
+#include <linux/android_kabi.h>
2728
2829 #include <linux/cgroup-defs.h>
30
+
31
+struct kernel_clone_args;
2932
3033 #ifdef CONFIG_CGROUPS
3134
....@@ -58,19 +61,20 @@
5861 struct list_head *tcset_head;
5962
6063 struct list_head *task_pos;
61
- struct list_head *tasks_head;
62
- struct list_head *mg_tasks_head;
63
- struct list_head *dying_tasks_head;
6464
6565 struct list_head *cur_tasks_head;
6666 struct css_set *cur_cset;
6767 struct css_set *cur_dcset;
6868 struct task_struct *cur_task;
6969 struct list_head iters_node; /* css_set->task_iters */
70
+
71
+ ANDROID_KABI_RESERVE(1);
7072 };
7173
74
+extern struct file_system_type cgroup_fs_type;
7275 extern struct cgroup_root cgrp_dfl_root;
73
-extern struct css_set init_css_set;
76
+extern struct ext_css_set init_ext_css_set;
77
+#define init_css_set init_ext_css_set.cset
7478
7579 #define SUBSYS(_x) extern struct cgroup_subsys _x ## _cgrp_subsys;
7680 #include <linux/cgroup_subsys.h>
....@@ -98,6 +102,8 @@
98102
99103 bool css_has_online_children(struct cgroup_subsys_state *css);
100104 struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
105
+struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgroup,
106
+ struct cgroup_subsys *ss);
101107 struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup,
102108 struct cgroup_subsys *ss);
103109 struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
....@@ -120,9 +126,12 @@
120126 struct pid *pid, struct task_struct *tsk);
121127
122128 void cgroup_fork(struct task_struct *p);
123
-extern int cgroup_can_fork(struct task_struct *p);
124
-extern void cgroup_cancel_fork(struct task_struct *p);
125
-extern void cgroup_post_fork(struct task_struct *p);
129
+extern int cgroup_can_fork(struct task_struct *p,
130
+ struct kernel_clone_args *kargs);
131
+extern void cgroup_cancel_fork(struct task_struct *p,
132
+ struct kernel_clone_args *kargs);
133
+extern void cgroup_post_fork(struct task_struct *p,
134
+ struct kernel_clone_args *kargs);
126135 void cgroup_exit(struct task_struct *p);
127136 void cgroup_release(struct task_struct *p);
128137 void cgroup_free(struct task_struct *p);
....@@ -302,6 +311,11 @@
302311 /*
303312 * Inline functions.
304313 */
314
+
315
+static inline u64 cgroup_id(struct cgroup *cgrp)
316
+{
317
+ return cgrp->kn->id;
318
+}
305319
306320 /**
307321 * css_get - obtain a reference on the specified css
....@@ -564,7 +578,7 @@
564578 {
565579 if (cgrp->root != ancestor->root || cgrp->level < ancestor->level)
566580 return false;
567
- return cgrp->ancestor_ids[ancestor->level] == ancestor->id;
581
+ return cgrp->ancestor_ids[ancestor->level] == cgroup_id(ancestor);
568582 }
569583
570584 /**
....@@ -615,7 +629,7 @@
615629 /* returns ino associated with a cgroup */
616630 static inline ino_t cgroup_ino(struct cgroup *cgrp)
617631 {
618
- return cgrp->kn->id.ino;
632
+ return kernfs_ino(cgrp->kn);
619633 }
620634
621635 /* cft/css accessors for cftype->write() operation */
....@@ -688,18 +702,14 @@
688702 current->no_cgroup_migration = 0;
689703 }
690704
691
-static inline union kernfs_node_id *cgroup_get_kernfs_id(struct cgroup *cgrp)
692
-{
693
- return &cgrp->kn->id;
694
-}
695
-
696
-void cgroup_path_from_kernfs_id(const union kernfs_node_id *id,
697
- char *buf, size_t buflen);
705
+void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen);
698706 #else /* !CONFIG_CGROUPS */
699707
700708 struct cgroup_subsys_state;
701709 struct cgroup;
702710
711
+static inline u64 cgroup_id(struct cgroup *cgrp) { return 1; }
712
+static inline void css_get(struct cgroup_subsys_state *css) {}
703713 static inline void css_put(struct cgroup_subsys_state *css) {}
704714 static inline int cgroup_attach_task_all(struct task_struct *from,
705715 struct task_struct *t) { return 0; }
....@@ -707,9 +717,12 @@
707717 struct dentry *dentry) { return -EINVAL; }
708718
709719 static inline void cgroup_fork(struct task_struct *p) {}
710
-static inline int cgroup_can_fork(struct task_struct *p) { return 0; }
711
-static inline void cgroup_cancel_fork(struct task_struct *p) {}
712
-static inline void cgroup_post_fork(struct task_struct *p) {}
720
+static inline int cgroup_can_fork(struct task_struct *p,
721
+ struct kernel_clone_args *kargs) { return 0; }
722
+static inline void cgroup_cancel_fork(struct task_struct *p,
723
+ struct kernel_clone_args *kargs) {}
724
+static inline void cgroup_post_fork(struct task_struct *p,
725
+ struct kernel_clone_args *kargs) {}
713726 static inline void cgroup_exit(struct task_struct *p) {}
714727 static inline void cgroup_release(struct task_struct *p) {}
715728 static inline void cgroup_free(struct task_struct *p) {}
....@@ -718,10 +731,6 @@
718731 static inline int cgroup_init(void) { return 0; }
719732 static inline void cgroup_init_kthreadd(void) {}
720733 static inline void cgroup_kthread_ready(void) {}
721
-static inline union kernfs_node_id *cgroup_get_kernfs_id(struct cgroup *cgrp)
722
-{
723
- return NULL;
724
-}
725734
726735 static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
727736 {
....@@ -744,8 +753,8 @@
744753 return true;
745754 }
746755
747
-static inline void cgroup_path_from_kernfs_id(const union kernfs_node_id *id,
748
- char *buf, size_t buflen) {}
756
+static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
757
+{}
749758 #endif /* !CONFIG_CGROUPS */
750759
751760 #ifdef CONFIG_CGROUPS
....@@ -909,7 +918,7 @@
909918 void cgroup_freeze(struct cgroup *cgrp, bool freeze);
910919 void cgroup_freezer_migrate_task(struct task_struct *task, struct cgroup *src,
911920 struct cgroup *dst);
912
-void cgroup_freezer_frozen_exit(struct task_struct *task);
921
+
913922 static inline bool cgroup_task_freeze(struct task_struct *task)
914923 {
915924 bool ret;
....@@ -944,4 +953,22 @@
944953
945954 #endif /* !CONFIG_CGROUPS */
946955
956
+#ifdef CONFIG_CGROUP_BPF
957
+static inline void cgroup_bpf_get(struct cgroup *cgrp)
958
+{
959
+ percpu_ref_get(&cgrp->bpf.refcnt);
960
+}
961
+
962
+static inline void cgroup_bpf_put(struct cgroup *cgrp)
963
+{
964
+ percpu_ref_put(&cgrp->bpf.refcnt);
965
+}
966
+
967
+#else /* CONFIG_CGROUP_BPF */
968
+
969
+static inline void cgroup_bpf_get(struct cgroup *cgrp) {}
970
+static inline void cgroup_bpf_put(struct cgroup *cgrp) {}
971
+
972
+#endif /* CONFIG_CGROUP_BPF */
973
+
947974 #endif /* _LINUX_CGROUP_H */