diff options
author | Ben Blum <bblum@andrew.cmu.edu> | 2011-05-26 19:25:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-26 20:12:34 -0400 |
commit | f780bdb7c1c73009cb57adcf99ef50027d80bf3c (patch) | |
tree | d15668ffcc40a2aaa31723b87cfda0b166f84d57 /Documentation/cgroups/cgroups.txt | |
parent | 4714d1d32d97239fb5ae3e10521d3f133a899b66 (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/cgroups.txt')
-rw-r--r-- | Documentation/cgroups/cgroups.txt | 30 |
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 | |||
575 | called multiple times against a cgroup. | 575 | called multiple times against a cgroup. |
576 | 576 | ||
577 | int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 577 | int 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 | ||
581 | Called prior to moving a task into a cgroup; if the subsystem | 581 | Called 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* | |||
584 | unspecified task can be moved into the cgroup. Note that this isn't | 584 | unspecified task can be moved into the cgroup. Note that this isn't |
585 | called on a fork. If this method returns 0 (success) then this should | 585 | called on a fork. If this method returns 0 (success) then this should |
586 | remain valid while the caller holds cgroup_mutex and it is ensured that either | 586 | remain valid while the caller holds cgroup_mutex and it is ensured that either |
587 | attach() or cancel_attach() will be called in future. If threadgroup is | 587 | attach() or cancel_attach() will be called in future. |
588 | true, then a successful result indicates that all threads in the given | 588 | |
589 | thread's threadgroup can be moved together. | 589 | int can_attach_task(struct cgroup *cgrp, struct task_struct *tsk); |
590 | (cgroup_mutex held by caller) | ||
591 | |||
592 | As can_attach, but for operations that must be run once per task to be | ||
593 | attached (possibly many when using cgroup_attach_proc). Called after | ||
594 | can_attach. | ||
590 | 595 | ||
591 | void cancel_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 596 | void 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. | |||
598 | This will be called only about subsystems whose can_attach() operation have | 603 | This will be called only about subsystems whose can_attach() operation have |
599 | succeeded. | 604 | succeeded. |
600 | 605 | ||
606 | void pre_attach(struct cgroup *cgrp); | ||
607 | (cgroup_mutex held by caller) | ||
608 | |||
609 | For any non-per-thread attachment work that needs to happen before | ||
610 | attach_task. Needed by cpuset. | ||
611 | |||
601 | void attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 612 | void 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 | ||
606 | Called after the task has been attached to the cgroup, to allow any | 616 | Called after the task has been attached to the cgroup, to allow any |
607 | post-attachment activity that requires memory allocations or blocking. | 617 | post-attachment activity that requires memory allocations or blocking. |
608 | If threadgroup is true, the subsystem should take care of all threads | 618 | |
609 | in the specified thread's threadgroup. Currently does not support any | 619 | void attach_task(struct cgroup *cgrp, struct task_struct *tsk); |
620 | (cgroup_mutex held by caller) | ||
621 | |||
622 | As attach, but for operations that must be run once per task to be attached, | ||
623 | like can_attach_task. Called before attach. Currently does not support any | ||
610 | subsystem that might need the old_cgrp for every thread in the group. | 624 | subsystem that might need the old_cgrp for every thread in the group. |
611 | 625 | ||
612 | void fork(struct cgroup_subsy *ss, struct task_struct *task) | 626 | void fork(struct cgroup_subsy *ss, struct task_struct *task) |