aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
authorCliff Wickman <cpw@sgi.com>2008-02-07 03:14:42 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:22 -0500
commit31a7df01fd0cd786f60873a921aecafac148c290 (patch)
tree221f00c864c50e7dc4719cb4de09292040567c55 /include/linux/cgroup.h
parentdfc05c259e424e4160c66eab728f55cc4b53fd75 (diff)
cgroups: mechanism to process each task in a cgroup
Provide cgroup_scan_tasks(), which iterates through every task in a cgroup, calling a test function and a process function for each. And call the process function without holding the css_set_lock lock. The idea is David Rientjes', predicting that such a function will make it much easier in the future to extend things that require access to each task in a cgroup without holding the lock, [akpm@linux-foundation.org: cleanup] [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Cliff Wickman <cpw@sgi.com> Cc: Paul Menage <menage@google.com> Cc: Paul Jackson <pj@sgi.com> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index d8e92223a79c..8675c691d3e2 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -14,6 +14,7 @@
14#include <linux/nodemask.h> 14#include <linux/nodemask.h>
15#include <linux/rcupdate.h> 15#include <linux/rcupdate.h>
16#include <linux/cgroupstats.h> 16#include <linux/cgroupstats.h>
17#include <linux/prio_heap.h>
17 18
18#ifdef CONFIG_CGROUPS 19#ifdef CONFIG_CGROUPS
19 20
@@ -207,6 +208,14 @@ struct cftype {
207 int (*release) (struct inode *inode, struct file *file); 208 int (*release) (struct inode *inode, struct file *file);
208}; 209};
209 210
211struct cgroup_scanner {
212 struct cgroup *cg;
213 int (*test_task)(struct task_struct *p, struct cgroup_scanner *scan);
214 void (*process_task)(struct task_struct *p,
215 struct cgroup_scanner *scan);
216 struct ptr_heap *heap;
217};
218
210/* Add a new file to the given cgroup directory. Should only be 219/* Add a new file to the given cgroup directory. Should only be
211 * called by subsystems from within a populate() method */ 220 * called by subsystems from within a populate() method */
212int cgroup_add_file(struct cgroup *cont, struct cgroup_subsys *subsys, 221int cgroup_add_file(struct cgroup *cont, struct cgroup_subsys *subsys,
@@ -299,11 +308,16 @@ struct cgroup_iter {
299 * returns NULL or until you want to end the iteration 308 * returns NULL or until you want to end the iteration
300 * 309 *
301 * 3) call cgroup_iter_end() to destroy the iterator. 310 * 3) call cgroup_iter_end() to destroy the iterator.
311 *
312 * Or, call cgroup_scan_tasks() to iterate through every task in a cpuset.
313 * - cgroup_scan_tasks() holds the css_set_lock when calling the test_task()
314 * callback, but not while calling the process_task() callback.
302 */ 315 */
303void cgroup_iter_start(struct cgroup *cont, struct cgroup_iter *it); 316void cgroup_iter_start(struct cgroup *cont, struct cgroup_iter *it);
304struct task_struct *cgroup_iter_next(struct cgroup *cont, 317struct task_struct *cgroup_iter_next(struct cgroup *cont,
305 struct cgroup_iter *it); 318 struct cgroup_iter *it);
306void cgroup_iter_end(struct cgroup *cont, struct cgroup_iter *it); 319void cgroup_iter_end(struct cgroup *cont, struct cgroup_iter *it);
320int cgroup_scan_tasks(struct cgroup_scanner *scan);
307 321
308#else /* !CONFIG_CGROUPS */ 322#else /* !CONFIG_CGROUPS */
309 323