aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-20 21:11:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-20 21:11:21 -0400
commit0d9cabdccedb79ee5f27b77ff51f29a9e7d23275 (patch)
tree8bfb64c3672d058eb90aec3c3a9c4f61cef9097c /include/linux
parent701085b219016d38f105b031381b9cee6200253a (diff)
parent3ce3230a0cff484e5130153f244d4fb8a56b3a8b (diff)
Merge branch 'for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup changes from Tejun Heo: "Out of the 8 commits, one fixes a long-standing locking issue around tasklist walking and others are cleanups." * 'for-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: Walk task list under tasklist_lock in cgroup_enable_task_cg_list cgroup: Remove wrong comment on cgroup_enable_task_cg_list() cgroup: remove cgroup_subsys argument from callbacks cgroup: remove extra calls to find_existing_css_set cgroup: replace tasklist_lock with rcu_read_lock cgroup: simplify double-check locking in cgroup_attach_proc cgroup: move struct cgroup_pidlist out from the header file cgroup: remove cgroup_attach_task_current_cg()
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/cgroup.h70
1 files changed, 12 insertions, 58 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index e9b602151caf..501adb1b2f43 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -160,38 +160,6 @@ enum {
160 CGRP_CLONE_CHILDREN, 160 CGRP_CLONE_CHILDREN,
161}; 161};
162 162
163/* which pidlist file are we talking about? */
164enum cgroup_filetype {
165 CGROUP_FILE_PROCS,
166 CGROUP_FILE_TASKS,
167};
168
169/*
170 * A pidlist is a list of pids that virtually represents the contents of one
171 * of the cgroup files ("procs" or "tasks"). We keep a list of such pidlists,
172 * a pair (one each for procs, tasks) for each pid namespace that's relevant
173 * to the cgroup.
174 */
175struct cgroup_pidlist {
176 /*
177 * used to find which pidlist is wanted. doesn't change as long as
178 * this particular list stays in the list.
179 */
180 struct { enum cgroup_filetype type; struct pid_namespace *ns; } key;
181 /* array of xids */
182 pid_t *list;
183 /* how many elements the above list has */
184 int length;
185 /* how many files are using the current array */
186 int use_count;
187 /* each of these stored in a list by its cgroup */
188 struct list_head links;
189 /* pointer to the cgroup we belong to, for list removal purposes */
190 struct cgroup *owner;
191 /* protects the other fields */
192 struct rw_semaphore mutex;
193};
194
195struct cgroup { 163struct cgroup {
196 unsigned long flags; /* "unsigned long" so bitops work */ 164 unsigned long flags; /* "unsigned long" so bitops work */
197 165
@@ -484,23 +452,18 @@ int cgroup_taskset_size(struct cgroup_taskset *tset);
484 */ 452 */
485 453
486struct cgroup_subsys { 454struct cgroup_subsys {
487 struct cgroup_subsys_state *(*create)(struct cgroup_subsys *ss, 455 struct cgroup_subsys_state *(*create)(struct cgroup *cgrp);
488 struct cgroup *cgrp); 456 int (*pre_destroy)(struct cgroup *cgrp);
489 int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); 457 void (*destroy)(struct cgroup *cgrp);
490 void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); 458 int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
491 int (*can_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 459 void (*cancel_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
492 struct cgroup_taskset *tset); 460 void (*attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
493 void (*cancel_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 461 void (*fork)(struct task_struct *task);
494 struct cgroup_taskset *tset); 462 void (*exit)(struct cgroup *cgrp, struct cgroup *old_cgrp,
495 void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 463 struct task_struct *task);
496 struct cgroup_taskset *tset); 464 int (*populate)(struct cgroup_subsys *ss, struct cgroup *cgrp);
497 void (*fork)(struct cgroup_subsys *ss, struct task_struct *task); 465 void (*post_clone)(struct cgroup *cgrp);
498 void (*exit)(struct cgroup_subsys *ss, struct cgroup *cgrp, 466 void (*bind)(struct cgroup *root);
499 struct cgroup *old_cgrp, struct task_struct *task);
500 int (*populate)(struct cgroup_subsys *ss,
501 struct cgroup *cgrp);
502 void (*post_clone)(struct cgroup_subsys *ss, struct cgroup *cgrp);
503 void (*bind)(struct cgroup_subsys *ss, struct cgroup *root);
504 467
505 int subsys_id; 468 int subsys_id;
506 int active; 469 int active;
@@ -602,11 +565,6 @@ int cgroup_scan_tasks(struct cgroup_scanner *scan);
602int cgroup_attach_task(struct cgroup *, struct task_struct *); 565int cgroup_attach_task(struct cgroup *, struct task_struct *);
603int cgroup_attach_task_all(struct task_struct *from, struct task_struct *); 566int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
604 567
605static inline int cgroup_attach_task_current_cg(struct task_struct *tsk)
606{
607 return cgroup_attach_task_all(current, tsk);
608}
609
610/* 568/*
611 * CSS ID is ID for cgroup_subsys_state structs under subsys. This only works 569 * CSS ID is ID for cgroup_subsys_state structs under subsys. This only works
612 * if cgroup_subsys.use_id == true. It can be used for looking up and scanning. 570 * if cgroup_subsys.use_id == true. It can be used for looking up and scanning.
@@ -669,10 +627,6 @@ static inline int cgroup_attach_task_all(struct task_struct *from,
669{ 627{
670 return 0; 628 return 0;
671} 629}
672static inline int cgroup_attach_task_current_cg(struct task_struct *t)
673{
674 return 0;
675}
676 630
677#endif /* !CONFIG_CGROUPS */ 631#endif /* !CONFIG_CGROUPS */
678 632