diff options
author | Cliff Wickman <cpw@sgi.com> | 2008-02-07 00:14:42 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-07 08:42:22 -0800 |
commit | 31a7df01fd0cd786f60873a921aecafac148c290 (patch) | |
tree | 221f00c864c50e7dc4719cb4de09292040567c55 /include | |
parent | dfc05c259e424e4160c66eab728f55cc4b53fd75 (diff) | |
download | kernel_samsung_tuna-31a7df01fd0cd786f60873a921aecafac148c290.zip kernel_samsung_tuna-31a7df01fd0cd786f60873a921aecafac148c290.tar.gz kernel_samsung_tuna-31a7df01fd0cd786f60873a921aecafac148c290.tar.bz2 |
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')
-rw-r--r-- | include/linux/cgroup.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index d8e9222..8675c69 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -14,6 +14,7 @@ #include <linux/nodemask.h> #include <linux/rcupdate.h> #include <linux/cgroupstats.h> +#include <linux/prio_heap.h> #ifdef CONFIG_CGROUPS @@ -207,6 +208,14 @@ struct cftype { int (*release) (struct inode *inode, struct file *file); }; +struct cgroup_scanner { + struct cgroup *cg; + int (*test_task)(struct task_struct *p, struct cgroup_scanner *scan); + void (*process_task)(struct task_struct *p, + struct cgroup_scanner *scan); + struct ptr_heap *heap; +}; + /* Add a new file to the given cgroup directory. Should only be * called by subsystems from within a populate() method */ int cgroup_add_file(struct cgroup *cont, struct cgroup_subsys *subsys, @@ -299,11 +308,16 @@ struct cgroup_iter { * returns NULL or until you want to end the iteration * * 3) call cgroup_iter_end() to destroy the iterator. + * + * Or, call cgroup_scan_tasks() to iterate through every task in a cpuset. + * - cgroup_scan_tasks() holds the css_set_lock when calling the test_task() + * callback, but not while calling the process_task() callback. */ void cgroup_iter_start(struct cgroup *cont, struct cgroup_iter *it); struct task_struct *cgroup_iter_next(struct cgroup *cont, struct cgroup_iter *it); void cgroup_iter_end(struct cgroup *cont, struct cgroup_iter *it); +int cgroup_scan_tasks(struct cgroup_scanner *scan); #else /* !CONFIG_CGROUPS */ |