diff options
Diffstat (limited to 'include/linux/cgroup.h')
| -rw-r--r-- | include/linux/cgroup.h | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 90bba9e62286..0008dee66514 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
| @@ -37,7 +37,7 @@ extern void cgroup_exit(struct task_struct *p, int run_callbacks); | |||
| 37 | extern int cgroupstats_build(struct cgroupstats *stats, | 37 | extern int cgroupstats_build(struct cgroupstats *stats, |
| 38 | struct dentry *dentry); | 38 | struct dentry *dentry); |
| 39 | 39 | ||
| 40 | extern struct file_operations proc_cgroup_operations; | 40 | extern const struct file_operations proc_cgroup_operations; |
| 41 | 41 | ||
| 42 | /* Define the enumeration of all cgroup subsystems */ | 42 | /* Define the enumeration of all cgroup subsystems */ |
| 43 | #define SUBSYS(_x) _x ## _subsys_id, | 43 | #define SUBSYS(_x) _x ## _subsys_id, |
| @@ -141,6 +141,38 @@ enum { | |||
| 141 | CGRP_WAIT_ON_RMDIR, | 141 | CGRP_WAIT_ON_RMDIR, |
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | /* which pidlist file are we talking about? */ | ||
| 145 | enum cgroup_filetype { | ||
| 146 | CGROUP_FILE_PROCS, | ||
| 147 | CGROUP_FILE_TASKS, | ||
| 148 | }; | ||
| 149 | |||
| 150 | /* | ||
| 151 | * A pidlist is a list of pids that virtually represents the contents of one | ||
| 152 | * of the cgroup files ("procs" or "tasks"). We keep a list of such pidlists, | ||
| 153 | * a pair (one each for procs, tasks) for each pid namespace that's relevant | ||
| 154 | * to the cgroup. | ||
| 155 | */ | ||
| 156 | struct cgroup_pidlist { | ||
| 157 | /* | ||
| 158 | * used to find which pidlist is wanted. doesn't change as long as | ||
| 159 | * this particular list stays in the list. | ||
| 160 | */ | ||
| 161 | struct { enum cgroup_filetype type; struct pid_namespace *ns; } key; | ||
| 162 | /* array of xids */ | ||
| 163 | pid_t *list; | ||
| 164 | /* how many elements the above list has */ | ||
| 165 | int length; | ||
| 166 | /* how many files are using the current array */ | ||
| 167 | int use_count; | ||
| 168 | /* each of these stored in a list by its cgroup */ | ||
| 169 | struct list_head links; | ||
| 170 | /* pointer to the cgroup we belong to, for list removal purposes */ | ||
| 171 | struct cgroup *owner; | ||
| 172 | /* protects the other fields */ | ||
| 173 | struct rw_semaphore mutex; | ||
| 174 | }; | ||
| 175 | |||
| 144 | struct cgroup { | 176 | struct cgroup { |
| 145 | unsigned long flags; /* "unsigned long" so bitops work */ | 177 | unsigned long flags; /* "unsigned long" so bitops work */ |
| 146 | 178 | ||
| @@ -179,11 +211,12 @@ struct cgroup { | |||
| 179 | */ | 211 | */ |
| 180 | struct list_head release_list; | 212 | struct list_head release_list; |
| 181 | 213 | ||
| 182 | /* pids_mutex protects pids_list and cached pid arrays. */ | 214 | /* |
| 183 | struct rw_semaphore pids_mutex; | 215 | * list of pidlists, up to two for each namespace (one for procs, one |
| 184 | 216 | * for tasks); created on demand. | |
| 185 | /* Linked list of struct cgroup_pids */ | 217 | */ |
| 186 | struct list_head pids_list; | 218 | struct list_head pidlists; |
| 219 | struct mutex pidlist_mutex; | ||
| 187 | 220 | ||
| 188 | /* For RCU-protected deletion */ | 221 | /* For RCU-protected deletion */ |
| 189 | struct rcu_head rcu_head; | 222 | struct rcu_head rcu_head; |
| @@ -227,6 +260,9 @@ struct css_set { | |||
| 227 | * during subsystem registration (at boot time). | 260 | * during subsystem registration (at boot time). |
| 228 | */ | 261 | */ |
| 229 | struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; | 262 | struct cgroup_subsys_state *subsys[CGROUP_SUBSYS_COUNT]; |
| 263 | |||
| 264 | /* For RCU-protected deletion */ | ||
| 265 | struct rcu_head rcu_head; | ||
| 230 | }; | 266 | }; |
| 231 | 267 | ||
| 232 | /* | 268 | /* |
| @@ -389,10 +425,11 @@ struct cgroup_subsys { | |||
| 389 | struct cgroup *cgrp); | 425 | struct cgroup *cgrp); |
| 390 | int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); | 426 | int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); |
| 391 | void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); | 427 | void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); |
| 392 | int (*can_attach)(struct cgroup_subsys *ss, | 428 | int (*can_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 393 | struct cgroup *cgrp, struct task_struct *tsk); | 429 | struct task_struct *tsk, bool threadgroup); |
| 394 | void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, | 430 | void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 395 | struct cgroup *old_cgrp, struct task_struct *tsk); | 431 | struct cgroup *old_cgrp, struct task_struct *tsk, |
| 432 | bool threadgroup); | ||
| 396 | void (*fork)(struct cgroup_subsys *ss, struct task_struct *task); | 433 | void (*fork)(struct cgroup_subsys *ss, struct task_struct *task); |
| 397 | void (*exit)(struct cgroup_subsys *ss, struct task_struct *task); | 434 | void (*exit)(struct cgroup_subsys *ss, struct task_struct *task); |
| 398 | int (*populate)(struct cgroup_subsys *ss, | 435 | int (*populate)(struct cgroup_subsys *ss, |
