aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
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 /kernel/cgroup.c
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 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 909a35510af5..38fb0ad1cb46 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1759,7 +1759,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
1759 1759
1760 for_each_subsys(root, ss) { 1760 for_each_subsys(root, ss) {
1761 if (ss->can_attach) { 1761 if (ss->can_attach) {
1762 retval = ss->can_attach(ss, cgrp, tsk, false); 1762 retval = ss->can_attach(ss, cgrp, tsk);
1763 if (retval) { 1763 if (retval) {
1764 /* 1764 /*
1765 * Remember on which subsystem the can_attach() 1765 * Remember on which subsystem the can_attach()
@@ -1771,6 +1771,13 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
1771 goto out; 1771 goto out;
1772 } 1772 }
1773 } 1773 }
1774 if (ss->can_attach_task) {
1775 retval = ss->can_attach_task(cgrp, tsk);
1776 if (retval) {
1777 failed_ss = ss;
1778 goto out;
1779 }
1780 }
1774 } 1781 }
1775 1782
1776 task_lock(tsk); 1783 task_lock(tsk);
@@ -1805,8 +1812,12 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
1805 write_unlock(&css_set_lock); 1812 write_unlock(&css_set_lock);
1806 1813
1807 for_each_subsys(root, ss) { 1814 for_each_subsys(root, ss) {
1815 if (ss->pre_attach)
1816 ss->pre_attach(cgrp);
1817 if (ss->attach_task)
1818 ss->attach_task(cgrp, tsk);
1808 if (ss->attach) 1819 if (ss->attach)
1809 ss->attach(ss, cgrp, oldcgrp, tsk, false); 1820 ss->attach(ss, cgrp, oldcgrp, tsk);
1810 } 1821 }
1811 set_bit(CGRP_RELEASABLE, &oldcgrp->flags); 1822 set_bit(CGRP_RELEASABLE, &oldcgrp->flags);
1812 synchronize_rcu(); 1823 synchronize_rcu();
@@ -1829,7 +1840,7 @@ out:
1829 */ 1840 */
1830 break; 1841 break;
1831 if (ss->cancel_attach) 1842 if (ss->cancel_attach)
1832 ss->cancel_attach(ss, cgrp, tsk, false); 1843 ss->cancel_attach(ss, cgrp, tsk);
1833 } 1844 }
1834 } 1845 }
1835 return retval; 1846 return retval;