aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/cgroup.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-12-12 21:12:21 -0500
committerTejun Heo <tj@kernel.org>2011-12-12 21:12:21 -0500
commit2f7ee5691eecb67c8108b92001a85563ea336ac5 (patch)
tree18cf60ea8a463f4a6cd59c68926ba4357ae8ff4c /include/linux/cgroup.h
parent134d33737f9015761c3832f6b268fae6274aac7f (diff)
cgroup: introduce cgroup_taskset and use it in subsys->can_attach(), cancel_attach() and attach()
Currently, there's no way to pass multiple tasks to cgroup_subsys methods necessitating the need for separate per-process and per-task methods. This patch introduces cgroup_taskset which can be used to pass multiple tasks and their associated cgroups to cgroup_subsys methods. Three methods - can_attach(), cancel_attach() and attach() - are converted to use cgroup_taskset. This unifies passed parameters so that all methods have access to all information. Conversions in this patchset are identical and don't introduce any behavior change. -v2: documentation updated as per Paul Menage's suggestion. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Paul Menage <paul@paulmenage.org> Acked-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Balbir Singh <bsingharora@gmail.com> Cc: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: James Morris <jmorris@namei.org>
Diffstat (limited to 'include/linux/cgroup.h')
-rw-r--r--include/linux/cgroup.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 1b7f9d525013..34256ad9e553 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -457,6 +457,28 @@ void cgroup_exclude_rmdir(struct cgroup_subsys_state *css);
457void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css); 457void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css);
458 458
459/* 459/*
460 * Control Group taskset, used to pass around set of tasks to cgroup_subsys
461 * methods.
462 */
463struct cgroup_taskset;
464struct task_struct *cgroup_taskset_first(struct cgroup_taskset *tset);
465struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset);
466struct cgroup *cgroup_taskset_cur_cgroup(struct cgroup_taskset *tset);
467int cgroup_taskset_size(struct cgroup_taskset *tset);
468
469/**
470 * cgroup_taskset_for_each - iterate cgroup_taskset
471 * @task: the loop cursor
472 * @skip_cgrp: skip if task's cgroup matches this, %NULL to iterate through all
473 * @tset: taskset to iterate
474 */
475#define cgroup_taskset_for_each(task, skip_cgrp, tset) \
476 for ((task) = cgroup_taskset_first((tset)); (task); \
477 (task) = cgroup_taskset_next((tset))) \
478 if (!(skip_cgrp) || \
479 cgroup_taskset_cur_cgroup((tset)) != (skip_cgrp))
480
481/*
460 * Control Group subsystem type. 482 * Control Group subsystem type.
461 * See Documentation/cgroups/cgroups.txt for details 483 * See Documentation/cgroups/cgroups.txt for details
462 */ 484 */
@@ -467,14 +489,14 @@ struct cgroup_subsys {
467 int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); 489 int (*pre_destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp);
468 void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp); 490 void (*destroy)(struct cgroup_subsys *ss, struct cgroup *cgrp);
469 int (*can_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 491 int (*can_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
470 struct task_struct *tsk); 492 struct cgroup_taskset *tset);
471 int (*can_attach_task)(struct cgroup *cgrp, struct task_struct *tsk); 493 int (*can_attach_task)(struct cgroup *cgrp, struct task_struct *tsk);
472 void (*cancel_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 494 void (*cancel_attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
473 struct task_struct *tsk); 495 struct cgroup_taskset *tset);
474 void (*pre_attach)(struct cgroup *cgrp); 496 void (*pre_attach)(struct cgroup *cgrp);
475 void (*attach_task)(struct cgroup *cgrp, struct task_struct *tsk); 497 void (*attach_task)(struct cgroup *cgrp, struct task_struct *tsk);
476 void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp, 498 void (*attach)(struct cgroup_subsys *ss, struct cgroup *cgrp,
477 struct cgroup *old_cgrp, struct task_struct *tsk); 499 struct cgroup_taskset *tset);
478 void (*fork)(struct cgroup_subsys *ss, struct task_struct *task); 500 void (*fork)(struct cgroup_subsys *ss, struct task_struct *task);
479 void (*exit)(struct cgroup_subsys *ss, struct cgroup *cgrp, 501 void (*exit)(struct cgroup_subsys *ss, struct cgroup *cgrp,
480 struct cgroup *old_cgrp, struct task_struct *task); 502 struct cgroup *old_cgrp, struct task_struct *task);