hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
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);
....@@ -303,6 +312,11 @@
303312 * Inline functions.
304313 */
305314
315
+static inline u64 cgroup_id(struct cgroup *cgrp)
316
+{
317
+ return cgrp->kn->id;
318
+}
319
+
306320 /**
307321 * css_get - obtain a reference on the specified css
308322 * @css: target css
....@@ -441,6 +455,7 @@
441455 extern spinlock_t css_set_lock;
442456 #define task_css_set_check(task, __c) \
443457 rcu_dereference_check((task)->cgroups, \
458
+ rcu_read_lock_sched_held() || \
444459 lockdep_is_held(&cgroup_mutex) || \
445460 lockdep_is_held(&css_set_lock) || \
446461 ((task)->flags & PF_EXITING) || (__c))
....@@ -564,7 +579,7 @@
564579 {
565580 if (cgrp->root != ancestor->root || cgrp->level < ancestor->level)
566581 return false;
567
- return cgrp->ancestor_ids[ancestor->level] == ancestor->id;
582
+ return cgrp->ancestor_ids[ancestor->level] == cgroup_id(ancestor);
568583 }
569584
570585 /**
....@@ -615,7 +630,7 @@
615630 /* returns ino associated with a cgroup */
616631 static inline ino_t cgroup_ino(struct cgroup *cgrp)
617632 {
618
- return cgrp->kn->id.ino;
633
+ return kernfs_ino(cgrp->kn);
619634 }
620635
621636 /* cft/css accessors for cftype->write() operation */
....@@ -688,18 +703,14 @@
688703 current->no_cgroup_migration = 0;
689704 }
690705
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);
706
+void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen);
698707 #else /* !CONFIG_CGROUPS */
699708
700709 struct cgroup_subsys_state;
701710 struct cgroup;
702711
712
+static inline u64 cgroup_id(struct cgroup *cgrp) { return 1; }
713
+static inline void css_get(struct cgroup_subsys_state *css) {}
703714 static inline void css_put(struct cgroup_subsys_state *css) {}
704715 static inline int cgroup_attach_task_all(struct task_struct *from,
705716 struct task_struct *t) { return 0; }
....@@ -707,9 +718,12 @@
707718 struct dentry *dentry) { return -EINVAL; }
708719
709720 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) {}
721
+static inline int cgroup_can_fork(struct task_struct *p,
722
+ struct kernel_clone_args *kargs) { return 0; }
723
+static inline void cgroup_cancel_fork(struct task_struct *p,
724
+ struct kernel_clone_args *kargs) {}
725
+static inline void cgroup_post_fork(struct task_struct *p,
726
+ struct kernel_clone_args *kargs) {}
713727 static inline void cgroup_exit(struct task_struct *p) {}
714728 static inline void cgroup_release(struct task_struct *p) {}
715729 static inline void cgroup_free(struct task_struct *p) {}
....@@ -718,10 +732,6 @@
718732 static inline int cgroup_init(void) { return 0; }
719733 static inline void cgroup_init_kthreadd(void) {}
720734 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
-}
725735
726736 static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
727737 {
....@@ -744,8 +754,8 @@
744754 return true;
745755 }
746756
747
-static inline void cgroup_path_from_kernfs_id(const union kernfs_node_id *id,
748
- char *buf, size_t buflen) {}
757
+static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)
758
+{}
749759 #endif /* !CONFIG_CGROUPS */
750760
751761 #ifdef CONFIG_CGROUPS
....@@ -781,11 +791,9 @@
781791
782792 cpuacct_charge(task, delta_exec);
783793
784
- rcu_read_lock();
785794 cgrp = task_dfl_cgroup(task);
786795 if (cgroup_parent(cgrp))
787796 __cgroup_account_cputime(cgrp, delta_exec);
788
- rcu_read_unlock();
789797 }
790798
791799 static inline void cgroup_account_cputime_field(struct task_struct *task,
....@@ -909,7 +917,7 @@
909917 void cgroup_freeze(struct cgroup *cgrp, bool freeze);
910918 void cgroup_freezer_migrate_task(struct task_struct *task, struct cgroup *src,
911919 struct cgroup *dst);
912
-void cgroup_freezer_frozen_exit(struct task_struct *task);
920
+
913921 static inline bool cgroup_task_freeze(struct task_struct *task)
914922 {
915923 bool ret;
....@@ -944,4 +952,22 @@
944952
945953 #endif /* !CONFIG_CGROUPS */
946954
955
+#ifdef CONFIG_CGROUP_BPF
956
+static inline void cgroup_bpf_get(struct cgroup *cgrp)
957
+{
958
+ percpu_ref_get(&cgrp->bpf.refcnt);
959
+}
960
+
961
+static inline void cgroup_bpf_put(struct cgroup *cgrp)
962
+{
963
+ percpu_ref_put(&cgrp->bpf.refcnt);
964
+}
965
+
966
+#else /* CONFIG_CGROUP_BPF */
967
+
968
+static inline void cgroup_bpf_get(struct cgroup *cgrp) {}
969
+static inline void cgroup_bpf_put(struct cgroup *cgrp) {}
970
+
971
+#endif /* CONFIG_CGROUP_BPF */
972
+
947973 #endif /* _LINUX_CGROUP_H */