diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-09 15:59:24 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-09 15:59:24 -0500 |
| commit | db0c2bf69aa095d4a6de7b1145f29fe9a7c0f6a3 (patch) | |
| tree | 8f38957c01b18edddd44d49ecc3beeac08a20b4e | |
| parent | ac69e0928054ff29a5049902fb477f9c7605c773 (diff) | |
| parent | 0d19ea866562e46989412a0676412fa0983c9ce7 (diff) | |
Merge branch 'for-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
* 'for-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: (21 commits)
cgroup: fix to allow mounting a hierarchy by name
cgroup: move assignement out of condition in cgroup_attach_proc()
cgroup: Remove task_lock() from cgroup_post_fork()
cgroup: add sparse annotation to cgroup_iter_start() and cgroup_iter_end()
cgroup: mark cgroup_rmdir_waitq and cgroup_attach_proc() as static
cgroup: only need to check oldcgrp==newgrp once
cgroup: remove redundant get/put of task struct
cgroup: remove redundant get/put of old css_set from migrate
cgroup: Remove unnecessary task_lock before fetching css_set on migration
cgroup: Drop task_lock(parent) on cgroup_fork()
cgroups: remove redundant get/put of css_set from css_set_check_fetched()
resource cgroups: remove bogus cast
cgroup: kill subsys->can_attach_task(), pre_attach() and attach_task()
cgroup, cpuset: don't use ss->pre_attach()
cgroup: don't use subsys->can_attach_task() or ->attach_task()
cgroup: introduce cgroup_taskset and use it in subsys->can_attach(), cancel_attach() and attach()
cgroup: improve old cgroup handling in cgroup_attach_proc()
cgroup: always lock threadgroup during migration
threadgroup: extend threadgroup_lock() to cover exit and exec
threadgroup: rename signal->threadgroup_fork_lock to ->group_rwsem
...
Fix up conflict in kernel/cgroup.c due to commit e0197aae59e5: "cgroups:
fix a css_set not found bug in cgroup_attach_proc" that already
mentioned that the bug is fixed (differently) in Tejun's cgroup
patchset. This one, in other words.
| -rw-r--r-- | Documentation/cgroups/cgroups.txt | 51 | ||||
| -rw-r--r-- | block/blk-cgroup.c | 45 | ||||
| -rw-r--r-- | include/linux/cgroup.h | 31 | ||||
| -rw-r--r-- | include/linux/init_task.h | 9 | ||||
| -rw-r--r-- | include/linux/sched.h | 73 | ||||
| -rw-r--r-- | kernel/cgroup.c | 401 | ||||
| -rw-r--r-- | kernel/cgroup_freezer.c | 16 | ||||
| -rw-r--r-- | kernel/cpuset.c | 105 | ||||
| -rw-r--r-- | kernel/events/core.c | 13 | ||||
| -rw-r--r-- | kernel/fork.c | 8 | ||||
| -rw-r--r-- | kernel/res_counter.c | 3 | ||||
| -rw-r--r-- | kernel/sched/core.c | 31 | ||||
| -rw-r--r-- | kernel/signal.c | 10 | ||||
| -rw-r--r-- | mm/memcontrol.c | 16 | ||||
| -rw-r--r-- | security/device_cgroup.c | 7 |
15 files changed, 470 insertions, 349 deletions
diff --git a/Documentation/cgroups/cgroups.txt b/Documentation/cgroups/cgroups.txt index 9c452ef2328c..a7c96ae5557c 100644 --- a/Documentation/cgroups/cgroups.txt +++ b/Documentation/cgroups/cgroups.txt | |||
| @@ -594,53 +594,44 @@ rmdir() will fail with it. From this behavior, pre_destroy() can be | |||
| 594 | called multiple times against a cgroup. | 594 | called multiple times against a cgroup. |
| 595 | 595 | ||
| 596 | int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 596 | int can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 597 | struct task_struct *task) | 597 | struct cgroup_taskset *tset) |
| 598 | (cgroup_mutex held by caller) | 598 | (cgroup_mutex held by caller) |
| 599 | 599 | ||
| 600 | Called prior to moving a task into a cgroup; if the subsystem | 600 | Called prior to moving one or more tasks into a cgroup; if the |
| 601 | returns an error, this will abort the attach operation. If a NULL | 601 | subsystem returns an error, this will abort the attach operation. |
| 602 | task is passed, then a successful result indicates that *any* | 602 | @tset contains the tasks to be attached and is guaranteed to have at |
| 603 | unspecified task can be moved into the cgroup. Note that this isn't | 603 | least one task in it. |
| 604 | called on a fork. If this method returns 0 (success) then this should | 604 | |
| 605 | remain valid while the caller holds cgroup_mutex and it is ensured that either | 605 | If there are multiple tasks in the taskset, then: |
| 606 | - it's guaranteed that all are from the same thread group | ||
| 607 | - @tset contains all tasks from the thread group whether or not | ||
| 608 | they're switching cgroups | ||
| 609 | - the first task is the leader | ||
| 610 | |||
| 611 | Each @tset entry also contains the task's old cgroup and tasks which | ||
| 612 | aren't switching cgroup can be skipped easily using the | ||
| 613 | cgroup_taskset_for_each() iterator. Note that this isn't called on a | ||
| 614 | fork. If this method returns 0 (success) then this should remain valid | ||
| 615 | while the caller holds cgroup_mutex and it is ensured that either | ||
| 606 | attach() or cancel_attach() will be called in future. | 616 | attach() or cancel_attach() will be called in future. |
| 607 | 617 | ||
| 608 | int can_attach_task(struct cgroup *cgrp, struct task_struct *tsk); | ||
| 609 | (cgroup_mutex held by caller) | ||
| 610 | |||
| 611 | As can_attach, but for operations that must be run once per task to be | ||
| 612 | attached (possibly many when using cgroup_attach_proc). Called after | ||
| 613 | can_attach. | ||
| 614 | |||
| 615 | void cancel_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 618 | void cancel_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 616 | struct task_struct *task, bool threadgroup) | 619 | struct cgroup_taskset *tset) |
| 617 | (cgroup_mutex held by caller) | 620 | (cgroup_mutex held by caller) |
| 618 | 621 | ||
| 619 | Called when a task attach operation has failed after can_attach() has succeeded. | 622 | Called when a task attach operation has failed after can_attach() has succeeded. |
| 620 | A subsystem whose can_attach() has some side-effects should provide this | 623 | A subsystem whose can_attach() has some side-effects should provide this |
| 621 | function, so that the subsystem can implement a rollback. If not, not necessary. | 624 | function, so that the subsystem can implement a rollback. If not, not necessary. |
| 622 | This will be called only about subsystems whose can_attach() operation have | 625 | This will be called only about subsystems whose can_attach() operation have |
| 623 | succeeded. | 626 | succeeded. The parameters are identical to can_attach(). |
| 624 | |||
| 625 | void pre_attach(struct cgroup *cgrp); | ||
| 626 | (cgroup_mutex held by caller) | ||
| 627 | |||
| 628 | For any non-per-thread attachment work that needs to happen before | ||
| 629 | attach_task. Needed by cpuset. | ||
| 630 | 627 | ||
| 631 | void attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | 628 | void attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 632 | struct cgroup *old_cgrp, struct task_struct *task) | 629 | struct cgroup_taskset *tset) |
| 633 | (cgroup_mutex held by caller) | 630 | (cgroup_mutex held by caller) |
| 634 | 631 | ||
| 635 | Called after the task has been attached to the cgroup, to allow any | 632 | Called after the task has been attached to the cgroup, to allow any |
| 636 | post-attachment activity that requires memory allocations or blocking. | 633 | post-attachment activity that requires memory allocations or blocking. |
| 637 | 634 | The parameters are identical to can_attach(). | |
| 638 | void attach_task(struct cgroup *cgrp, struct task_struct *tsk); | ||
| 639 | (cgroup_mutex held by caller) | ||
| 640 | |||
| 641 | As attach, but for operations that must be run once per task to be attached, | ||
| 642 | like can_attach_task. Called before attach. Currently does not support any | ||
| 643 | subsystem that might need the old_cgrp for every thread in the group. | ||
| 644 | 635 | ||
| 645 | void fork(struct cgroup_subsy *ss, struct task_struct *task) | 636 | void fork(struct cgroup_subsy *ss, struct task_struct *task) |
| 646 | 637 | ||
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 8f630cec906e..b8c143d68ee0 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
| @@ -30,8 +30,10 @@ EXPORT_SYMBOL_GPL(blkio_root_cgroup); | |||
| 30 | 30 | ||
| 31 | static struct cgroup_subsys_state *blkiocg_create(struct cgroup_subsys *, | 31 | static struct cgroup_subsys_state *blkiocg_create(struct cgroup_subsys *, |
| 32 | struct cgroup *); | 32 | struct cgroup *); |
| 33 | static int blkiocg_can_attach_task(struct cgroup *, struct task_struct *); | 33 | static int blkiocg_can_attach(struct cgroup_subsys *, struct cgroup *, |
| 34 | static void blkiocg_attach_task(struct cgroup *, struct task_struct *); | 34 | struct cgroup_taskset *); |
| 35 | static void blkiocg_attach(struct cgroup_subsys *, struct cgroup *, | ||
| 36 | struct cgroup_taskset *); | ||
| 35 | static void blkiocg_destroy(struct cgroup_subsys *, struct cgroup *); | 37 | static void blkiocg_destroy(struct cgroup_subsys *, struct cgroup *); |
| 36 | static int blkiocg_populate(struct cgroup_subsys *, struct cgroup *); | 38 | static int blkiocg_populate(struct cgroup_subsys *, struct cgroup *); |
| 37 | 39 | ||
| @@ -44,8 +46,8 @@ static int blkiocg_populate(struct cgroup_subsys *, struct cgroup *); | |||
| 44 | struct cgroup_subsys blkio_subsys = { | 46 | struct cgroup_subsys blkio_subsys = { |
| 45 | .name = "blkio", | 47 | .name = "blkio", |
| 46 | .create = blkiocg_create, | 48 | .create = blkiocg_create, |
| 47 | .can_attach_task = blkiocg_can_attach_task, | 49 | .can_attach = blkiocg_can_attach, |
| 48 | .attach_task = blkiocg_attach_task, | 50 | .attach = blkiocg_attach, |
| 49 | .destroy = blkiocg_destroy, | 51 | .destroy = blkiocg_destroy, |
| 50 | .populate = blkiocg_populate, | 52 | .populate = blkiocg_populate, |
| 51 | #ifdef CONFIG_BLK_CGROUP | 53 | #ifdef CONFIG_BLK_CGROUP |
| @@ -1626,30 +1628,39 @@ done: | |||
| 1626 | * of the main cic data structures. For now we allow a task to change | 1628 | * of the main cic data structures. For now we allow a task to change |
| 1627 | * its cgroup only if it's the only owner of its ioc. | 1629 | * its cgroup only if it's the only owner of its ioc. |
| 1628 | */ | 1630 | */ |
| 1629 | static int blkiocg_can_attach_task(struct cgroup *cgrp, struct task_struct *tsk) | 1631 | static int blkiocg_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 1632 | struct cgroup_taskset *tset) | ||
| 1630 | { | 1633 | { |
| 1634 | struct task_struct *task; | ||
| 1631 | struct io_context *ioc; | 1635 | struct io_context *ioc; |
| 1632 | int ret = 0; | 1636 | int ret = 0; |
| 1633 | 1637 | ||
| 1634 | /* task_lock() is needed to avoid races with exit_io_context() */ | 1638 | /* task_lock() is needed to avoid races with exit_io_context() */ |
| 1635 | task_lock(tsk); | 1639 | cgroup_taskset_for_each(task, cgrp, tset) { |
| 1636 | ioc = tsk->io_context; | 1640 | task_lock(task); |
| 1637 | if (ioc && atomic_read(&ioc->nr_tasks) > 1) | 1641 | ioc = task->io_context; |
| 1638 | ret = -EINVAL; | 1642 | if (ioc && atomic_read(&ioc->nr_tasks) > 1) |
| 1639 | task_unlock(tsk); | 1643 | ret = -EINVAL; |
| 1640 | 1644 | task_unlock(task); | |
| 1645 | if (ret) | ||
| 1646 | break; | ||
| 1647 | } | ||
| 1641 | return ret; | 1648 | return ret; |
| 1642 | } | 1649 | } |
| 1643 | 1650 | ||
| 1644 | static void blkiocg_attach_task(struct cgroup *cgrp, struct task_struct *tsk) | 1651 | static void blkiocg_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, |
| 1652 | struct cgroup_taskset *tset) | ||
| 1645 | { | 1653 | { |
| 1654 | struct task_struct *task; | ||
| 1646 | struct io_context *ioc; | 1655 | struct io_context *ioc; |
| 1647 | 1656 | ||
| 1648 | task_lock(tsk); | 1657 | cgroup_taskset_for_each(task, cgrp, tset) { |
| 1649 | ioc = tsk->io_context; | 1658 | task_lock(task); |
| 1650 | if (ioc) | 1659 | ioc = task->io_context; |
| 1651 | ioc->cgroup_changed = 1; | 1660 | if (ioc) |
| 1652 | task_unlock(tsk); | 1661 | ioc->cgroup_changed = 1; |
| 1662 | task_unlock(task); | ||
| 1663 | } | ||
| 1653 | } | 1664 | } |
| 1654 | 1665 | ||
| 1655 | void blkio_policy_register(struct blkio_policy_type *blkiop) | 1666 | void blkio_policy_register(struct blkio_policy_type *blkiop) |
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index a17becc36ca1..e9b602151caf 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
| @@ -457,6 +457,28 @@ void cgroup_exclude_rmdir(struct cgroup_subsys_state *css); | |||
| 457 | void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css); | 457 | void cgroup_release_and_wakeup_rmdir(struct cgroup_subsys_state *css); |
| 458 | 458 | ||
| 459 | |||
