aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/cgroups
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2011-05-26 19:25:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-26 20:12:34 -0400
commitf780bdb7c1c73009cb57adcf99ef50027d80bf3c (patch)
treed15668ffcc40a2aaa31723b87cfda0b166f84d57 /Documentation/cgroups
parent4714d1d32d97239fb5ae3e10521d3f133a899b66 (diff)
cgroups: add per-thread subsystem callbacks
Add cgroup subsystem callbacks for per-thread attachment in atomic contexts Add can_attach_task(), pre_attach(), and attach_task() as new callbacks for cgroups's subsystem interface. Unlike can_attach and attach, these are for per-thread operations, to be called potentially many times when attaching an entire threadgroup. Also, the old "bool threadgroup" interface is removed, as replaced by this. All subsystems are modified for the new interface - of note is cpuset, which requires from/to nodemasks for attach to be globally scoped (though per-cpuset would work too) to persist from its pre_attach to attach_task and attach. This is a pre-patch for cgroup-procs-writable.patch. Signed-off-by: Ben Blum <bblum@andrew.cmu.edu> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Matt Helsley <matthltc@us.ibm.com> Reviewed-by: Paul Menage <menage@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/cgroups')
-rw-r--r--Documentation/cgroups/cgroups.txt30
1 files changed, 22 insertions, 8 deletions
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt
index aedf1bd02fdd..b3bd3bdbe202 100644
--- a/Documentation/cgroups/cgroups.txt
+++ b/Documentation/cgroups/cgroups.txt
@@ -575,7 +575,7 @@ rmdir() will fail with it. From this behavior, pre_destroy() can be
575called multiple times against a cgroup. 575called multiple times against a cgroup.
576 576
577int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 577int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
578 struct task_struct *task, bool threadgroup) 578 struct task_struct *task)
579(cgroup_mutex held by caller) 579(cgroup_mutex held by caller)
580 580
581Called prior to moving a task into a cgroup; if the subsystem 581Called prior to moving a task into a cgroup; if the subsystem
@@ -584,9 +584,14 @@ task is passed, then a successful result indicates that *any*
584unspecified task can be moved into the cgroup. Note that this isn't 584unspecified task can be moved into the cgroup. Note that this isn't
585called on a fork. If this method returns 0 (success) then this should 585called on a fork. If this method returns 0 (success) then this should
586remain valid while the caller holds cgroup_mutex and it is ensured that either 586remain valid while the caller holds cgroup_mutex and it is ensured that either
587attach() or cancel_attach() will be called in future. If threadgroup is 587attach() or cancel_attach() will be called in future.
588true, then a successful result indicates that all threads in the given 588
589thread's threadgroup can be moved together. 589int can_attach_task(struct cgroup *cgrp, struct task_struct *tsk);
590(cgroup_mutex held by caller)
591
592As can_attach, but for operations that must be run once per task to be
593attached (possibly many when using cgroup_attach_proc). Called after
594can_attach.
590 595
591void cancel_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 596void cancel_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
592 struct task_struct *task, bool threadgroup) 597 struct task_struct *task, bool threadgroup)
@@ -598,15 +603,24 @@ function, so that the subsystem can implement a rollback. If not, not necessary.
598This will be called only about subsystems whose can_attach() operation have 603This will be called only about subsystems whose can_attach() operation have
599succeeded. 604succeeded.
600 605
606void pre_attach(struct cgroup *cgrp);
607(cgroup_mutex held by caller)
608
609For any non-per-thread attachment work that needs to happen before
610attach_task. Needed by cpuset.
611
601void attach(struct cgroup_subsys *ss, struct cgroup *cgrp, 612void attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
602 struct cgroup *old_cgrp, struct task_struct *task, 613 struct cgroup *old_cgrp, struct task_struct *task)
603 bool threadgroup)
604(cgroup_mutex held by caller) 614(cgroup_mutex held by caller)
605 615
606Called after the task has been attached to the cgroup, to allow any 616Called after the task has been attached to the cgroup, to allow any
607post-attachment activity that requires memory allocations or blocking. 617post-attachment activity that requires memory allocations or blocking.
608If threadgroup is true, the subsystem should take care of all threads 618
609in the specified thread's threadgroup. Currently does not support any 619void attach_task(struct cgroup *cgrp, struct task_struct *tsk);
620(cgroup_mutex held by caller)
621
622As attach, but for operations that must be run once per task to be attached,
623like can_attach_task. Called before attach. Currently does not support any
610subsystem that might need the old_cgrp for every thread in the group. 624subsystem that might need the old_cgrp for every thread in the group.
611 625
612void fork(struct cgroup_subsy *ss, struct task_struct *task) 626void fork(struct cgroup_subsy *ss, struct task_struct *task)