diff options
| -rw-r--r-- | kernel/cgroup.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 4c62513fe19f..a7b98ee35ef7 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -90,6 +90,14 @@ static DEFINE_MUTEX(cgroup_mutex); | |||
| 90 | static DEFINE_MUTEX(cgroup_root_mutex); | 90 | static DEFINE_MUTEX(cgroup_root_mutex); |
| 91 | 91 | ||
| 92 | /* | 92 | /* |
| 93 | * cgroup destruction makes heavy use of work items and there can be a lot | ||
| 94 | * of concurrent destructions. Use a separate workqueue so that cgroup | ||
| 95 | * destruction work items don't end up filling up max_active of system_wq | ||
| 96 | * which may lead to deadlock. | ||
| 97 | */ | ||
| 98 | static struct workqueue_struct *cgroup_destroy_wq; | ||
| 99 | |||
| 100 | /* | ||
| 93 | * Generate an array of cgroup subsystem pointers. At boot time, this is | 101 | * Generate an array of cgroup subsystem pointers. At boot time, this is |
| 94 | * populated with the built in subsystems, and modular subsystems are | 102 | * populated with the built in subsystems, and modular subsystems are |
| 95 | * registered after that. The mutable section of this array is protected by | 103 | * registered after that. The mutable section of this array is protected by |
| @@ -871,7 +879,7 @@ static void cgroup_free_rcu(struct rcu_head *head) | |||
| 871 | struct cgroup *cgrp = container_of(head, struct cgroup, rcu_head); | 879 | struct cgroup *cgrp = container_of(head, struct cgroup, rcu_head); |
| 872 | 880 | ||
| 873 | INIT_WORK(&cgrp->destroy_work, cgroup_free_fn); | 881 | INIT_WORK(&cgrp->destroy_work, cgroup_free_fn); |
| 874 | schedule_work(&cgrp->destroy_work); | 882 | queue_work(cgroup_destroy_wq, &cgrp->destroy_work); |
| 875 | } | 883 | } |
| 876 | 884 | ||
| 877 | static void cgroup_diput(struct dentry *dentry, struct inode *inode) | 885 | static void cgroup_diput(struct dentry *dentry, struct inode *inode) |
| @@ -4249,7 +4257,7 @@ static void css_free_rcu_fn(struct rcu_head *rcu_head) | |||
| 4249 | * css_put(). dput() requires process context which we don't have. | 4257 | * css_put(). dput() requires process context which we don't have. |
| 4250 | */ | 4258 | */ |
| 4251 | INIT_WORK(&css->destroy_work, css_free_work_fn); | 4259 | INIT_WORK(&css->destroy_work, css_free_work_fn); |
| 4252 | schedule_work(&css->destroy_work); | 4260 | queue_work(cgroup_destroy_wq, &css->destroy_work); |
| 4253 | } | 4261 | } |
| 4254 | 4262 | ||
| 4255 | static void css_release(struct percpu_ref *ref) | 4263 | static void css_release(struct percpu_ref *ref) |
| @@ -4539,7 +4547,7 @@ static void css_killed_ref_fn(struct percpu_ref *ref) | |||
| 4539 | container_of(ref, struct cgroup_subsys_state, refcnt); | 4547 | container_of(ref, struct cgroup_subsys_state, refcnt); |
| 4540 | 4548 | ||
| 4541 | INIT_WORK(&css->destroy_work, css_killed_work_fn); | 4549 | INIT_WORK(&css->destroy_work, css_killed_work_fn); |
| 4542 | schedule_work(&css->destroy_work); | 4550 | queue_work(cgroup_destroy_wq, &css->destroy_work); |
| 4543 | } | 4551 | } |
| 4544 | 4552 | ||
| 4545 | /** | 4553 | /** |
| @@ -5063,6 +5071,22 @@ out: | |||
| 5063 | return err; | 5071 | return err; |
| 5064 | } | 5072 | } |
| 5065 | 5073 | ||
| 5074 | static int __init cgroup_wq_init(void) | ||
| 5075 | { | ||
| 5076 | /* | ||
| 5077 | * There isn't much point in executing destruction path in | ||
| 5078 | * parallel. Good chunk is serialized with cgroup_mutex anyway. | ||
| 5079 | * Use 1 for @max_active. | ||
| 5080 | * | ||
| 5081 | * We would prefer to do this in cgroup_init() above, but that | ||
| 5082 | * is called before init_workqueues(): so leave this until after. | ||
| 5083 | */ | ||
| 5084 | cgroup_destroy_wq = alloc_workqueue("cgroup_destroy", 0, 1); | ||
| 5085 | BUG_ON(!cgroup_destroy_wq); | ||
| 5086 | return 0; | ||
| 5087 | } | ||
| 5088 | core_initcall(cgroup_wq_init); | ||
| 5089 | |||
| 5066 | /* | 5090 | /* |
| 5067 | * proc_cgroup_show() | 5091 | * proc_cgroup_show() |
| 5068 | * - Print task's cgroup paths into seq_file, one line for each hierarchy | 5092 | * - Print task's cgroup paths into seq_file, one line for each hierarchy |
