diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-02-20 15:01:09 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-02-20 15:01:09 -0500 |
commit | 6a4d07f85ba9da5b6eab6e60a493d459c4296176 (patch) | |
tree | 3753163556eb8ba095b5e30f41cbc54d2241c117 /kernel | |
parent | 2b73d207a5437bb930f72cf87e09ad12ad492e90 (diff) | |
parent | 532de3fc72adc2a6525c4d53c07bf81e1732083d (diff) |
Merge branch 'for-3.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fixes from Tejun Heo:
"Quite a few fixes this time.
Three locking fixes, all marked for -stable. A couple error path
fixes and some misc fixes. Hugh found a bug in memcg offlining
sequence and we thought we could fix that from cgroup core side but
that turned out to be insufficient and got reverted. A different fix
has been applied to -mm"
* 'for-3.14-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
cgroup: update cgroup_enable_task_cg_lists() to grab siglock
Revert "cgroup: use an ordered workqueue for cgroup destruction"
cgroup: protect modifications to cgroup_idr with cgroup_mutex
cgroup: fix locking in cgroup_cfts_commit()
cgroup: fix error return from cgroup_create()
cgroup: fix error return value in cgroup_mount()
cgroup: use an ordered workqueue for cgroup destruction
nfs: include xattr.h from fs/nfs/nfs3proc.c
cpuset: update MAINTAINERS entry
arm, pm, vmpressure: add missing slab.h includes
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 60 | ||||
-rw-r--r-- | kernel/power/console.c | 1 |
2 files changed, 33 insertions, 28 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index e2f46ba37f72..105f273b6f86 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -886,7 +886,9 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode) | |||
886 | * per-subsystem and moved to css->id so that lookups are | 886 | * per-subsystem and moved to css->id so that lookups are |
887 | * successful until the target css is released. | 887 | * successful until the target css is released. |
888 | */ | 888 | */ |
889 | mutex_lock(&cgroup_mutex); | ||
889 | idr_remove(&cgrp->root->cgroup_idr, cgrp->id); | 890 | idr_remove(&cgrp->root->cgroup_idr, cgrp->id); |
891 | mutex_unlock(&cgroup_mutex); | ||
890 | cgrp->id = -1; | 892 | cgrp->id = -1; |
891 | 893 | ||
892 | call_rcu(&cgrp->rcu_head, cgroup_free_rcu); | 894 | call_rcu(&cgrp->rcu_head, cgroup_free_rcu); |
@@ -1566,10 +1568,10 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
1566 | mutex_lock(&cgroup_mutex); | 1568 | mutex_lock(&cgroup_mutex); |
1567 | mutex_lock(&cgroup_root_mutex); | 1569 | mutex_lock(&cgroup_root_mutex); |
1568 | 1570 | ||
1569 | root_cgrp->id = idr_alloc(&root->cgroup_idr, root_cgrp, | 1571 | ret = idr_alloc(&root->cgroup_idr, root_cgrp, 0, 1, GFP_KERNEL); |
1570 | 0, 1, GFP_KERNEL); | 1572 | if (ret < 0) |
1571 | if (root_cgrp->id < 0) | ||
1572 | goto unlock_drop; | 1573 | goto unlock_drop; |
1574 | root_cgrp->id = ret; | ||
1573 | 1575 | ||
1574 | /* Check for name clashes with existing mounts */ | 1576 | /* Check for name clashes with existing mounts */ |
1575 | ret = -EBUSY; | 1577 | ret = -EBUSY; |
@@ -2763,10 +2765,7 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add) | |||
2763 | */ | 2765 | */ |
2764 | update_before = cgroup_serial_nr_next; | 2766 | update_before = cgroup_serial_nr_next; |
2765 | 2767 | ||
2766 | mutex_unlock(&cgroup_mutex); | ||
2767 | |||
2768 | /* add/rm files for all cgroups created before */ | 2768 | /* add/rm files for all cgroups created before */ |
2769 | rcu_read_lock(); | ||
2770 | css_for_each_descendant_pre(css, cgroup_css(root, ss)) { | 2769 | css_for_each_descendant_pre(css, cgroup_css(root, ss)) { |
2771 | struct cgroup *cgrp = css->cgroup; | 2770 | struct cgroup *cgrp = css->cgroup; |
2772 | 2771 | ||
@@ -2775,23 +2774,19 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add) | |||
2775 | 2774 | ||
2776 | inode = cgrp->dentry->d_inode; | 2775 | inode = cgrp->dentry->d_inode; |
2777 | dget(cgrp->dentry); | 2776 | dget(cgrp->dentry); |
2778 | rcu_read_unlock(); | ||
2779 | |||
2780 | dput(prev); | 2777 | dput(prev); |
2781 | prev = cgrp->dentry; | 2778 | prev = cgrp->dentry; |
2782 | 2779 | ||
2780 | mutex_unlock(&cgroup_mutex); | ||
2783 | mutex_lock(&inode->i_mutex); | 2781 | mutex_lock(&inode->i_mutex); |
2784 | mutex_lock(&cgroup_mutex); | 2782 | mutex_lock(&cgroup_mutex); |
2785 | if (cgrp->serial_nr < update_before && !cgroup_is_dead(cgrp)) | 2783 | if (cgrp->serial_nr < update_before && !cgroup_is_dead(cgrp)) |
2786 | ret = cgroup_addrm_files(cgrp, cfts, is_add); | 2784 | ret = cgroup_addrm_files(cgrp, cfts, is_add); |
2787 | mutex_unlock(&cgroup_mutex); | ||
2788 | mutex_unlock(&inode->i_mutex); | 2785 | mutex_unlock(&inode->i_mutex); |
2789 | |||
2790 | rcu_read_lock(); | ||
2791 | if (ret) | 2786 | if (ret) |
2792 | break; | 2787 | break; |
2793 | } | 2788 | } |
2794 | rcu_read_unlock(); | 2789 | mutex_unlock(&cgroup_mutex); |
2795 | dput(prev); | 2790 | dput(prev); |
2796 | deactivate_super(sb); | 2791 | deactivate_super(sb); |
2797 | return ret; | 2792 | return ret; |
@@ -2910,9 +2905,14 @@ static void cgroup_enable_task_cg_lists(void) | |||
2910 | * We should check if the process is exiting, otherwise | 2905 | * We should check if the process is exiting, otherwise |
2911 | * it will race with cgroup_exit() in that the list | 2906 | * it will race with cgroup_exit() in that the list |
2912 | * entry won't be deleted though the process has exited. | 2907 | * entry won't be deleted though the process has exited. |
2908 | * Do it while holding siglock so that we don't end up | ||
2909 | * racing against cgroup_exit(). | ||
2913 | */ | 2910 | */ |
2911 | spin_lock_irq(&p->sighand->siglock); | ||
2914 | if (!(p->flags & PF_EXITING) && list_empty(&p->cg_list)) | 2912 | if (!(p->flags & PF_EXITING) && list_empty(&p->cg_list)) |
2915 | list_add(&p->cg_list, &task_css_set(p)->tasks); | 2913 | list_add(&p->cg_list, &task_css_set(p)->tasks); |
2914 | spin_unlock_irq(&p->sighand->siglock); | ||
2915 | |||
2916 | task_unlock(p); | 2916 | task_unlock(p); |
2917 | } while_each_thread(g, p); | 2917 | } while_each_thread(g, p); |
2918 | read_unlock(&tasklist_lock); | 2918 | read_unlock(&tasklist_lock); |
@@ -4158,7 +4158,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4158 | struct cgroup *cgrp; | 4158 | struct cgroup *cgrp; |
4159 | struct cgroup_name *name; | 4159 | struct cgroup_name *name; |
4160 | struct cgroupfs_root *root = parent->root; | 4160 | struct cgroupfs_root *root = parent->root; |
4161 | int ssid, err = 0; | 4161 | int ssid, err; |
4162 | struct cgroup_subsys *ss; | 4162 | struct cgroup_subsys *ss; |
4163 | struct super_block *sb = root->sb; | 4163 | struct super_block *sb = root->sb; |
4164 | 4164 | ||
@@ -4168,19 +4168,13 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4168 | return -ENOMEM; | 4168 | return -ENOMEM; |
4169 | 4169 | ||
4170 | name = cgroup_alloc_name(dentry); | 4170 | name = cgroup_alloc_name(dentry); |
4171 | if (!name) | 4171 | if (!name) { |
4172 | err = -ENOMEM; | ||
4172 | goto err_free_cgrp; | 4173 | goto err_free_cgrp; |
4174 | } | ||
4173 | rcu_assign_pointer(cgrp->name, name); | 4175 | rcu_assign_pointer(cgrp->name, name); |
4174 | 4176 | ||
4175 | /* | 4177 | /* |
4176 | * Temporarily set the pointer to NULL, so idr_find() won't return | ||
4177 | * a half-baked cgroup. | ||
4178 | */ | ||
4179 | cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL); | ||
4180 | if (cgrp->id < 0) | ||
4181 | goto err_free_name; | ||
4182 | |||
4183 | /* | ||
4184 | * Only live parents can have children. Note that the liveliness | 4178 | * Only live parents can have children. Note that the liveliness |
4185 | * check isn't strictly necessary because cgroup_mkdir() and | 4179 | * check isn't strictly necessary because cgroup_mkdir() and |
4186 | * cgroup_rmdir() are fully synchronized by i_mutex; however, do it | 4180 | * cgroup_rmdir() are fully synchronized by i_mutex; however, do it |
@@ -4189,7 +4183,17 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4189 | */ | 4183 | */ |
4190 | if (!cgroup_lock_live_group(parent)) { | 4184 | if (!cgroup_lock_live_group(parent)) { |
4191 | err = -ENODEV; | 4185 | err = -ENODEV; |
4192 | goto err_free_id; | 4186 | goto err_free_name; |
4187 | } | ||
4188 | |||
4189 | /* | ||
4190 | * Temporarily set the pointer to NULL, so idr_find() won't return | ||
4191 | * a half-baked cgroup. | ||
4192 | */ | ||
4193 | cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL); | ||
4194 | if (cgrp->id < 0) { | ||
4195 | err = -ENOMEM; | ||
4196 | goto err_unlock; | ||
4193 | } | 4197 | } |
4194 | 4198 | ||
4195 | /* Grab a reference on the superblock so the hierarchy doesn't | 4199 | /* Grab a reference on the superblock so the hierarchy doesn't |
@@ -4221,7 +4225,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4221 | */ | 4225 | */ |
4222 | err = cgroup_create_file(dentry, S_IFDIR | mode, sb); | 4226 | err = cgroup_create_file(dentry, S_IFDIR | mode, sb); |
4223 | if (err < 0) | 4227 | if (err < 0) |
4224 | goto err_unlock; | 4228 | goto err_free_id; |
4225 | lockdep_assert_held(&dentry->d_inode->i_mutex); | 4229 | lockdep_assert_held(&dentry->d_inode->i_mutex); |
4226 | 4230 | ||
4227 | cgrp->serial_nr = cgroup_serial_nr_next++; | 4231 | cgrp->serial_nr = cgroup_serial_nr_next++; |
@@ -4257,12 +4261,12 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
4257 | 4261 | ||
4258 | return 0; | 4262 | return 0; |
4259 | 4263 | ||
4260 | err_unlock: | ||
4261 | mutex_unlock(&cgroup_mutex); | ||
4262 | /* Release the reference count that we took on the superblock */ | ||
4263 | deactivate_super(sb); | ||
4264 | err_free_id: | 4264 | err_free_id: |
4265 | idr_remove(&root->cgroup_idr, cgrp->id); | 4265 | idr_remove(&root->cgroup_idr, cgrp->id); |
4266 | /* Release the reference count that we took on the superblock */ | ||
4267 | deactivate_super(sb); | ||
4268 | err_unlock: | ||
4269 | mutex_unlock(&cgroup_mutex); | ||
4266 | err_free_name: | 4270 | err_free_name: |
4267 | kfree(rcu_dereference_raw(cgrp->name)); | 4271 | kfree(rcu_dereference_raw(cgrp->name)); |
4268 | err_free_cgrp: | 4272 | err_free_cgrp: |
diff --git a/kernel/power/console.c b/kernel/power/console.c index eacb8bd8cab4..aba9c545a0e3 100644 --- a/kernel/power/console.c +++ b/kernel/power/console.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/kbd_kern.h> | 9 | #include <linux/kbd_kern.h> |
10 | #include <linux/vt.h> | 10 | #include <linux/vt.h> |
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/slab.h> | ||
12 | #include "power.h" | 13 | #include "power.h" |
13 | 14 | ||
14 | #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) | 15 | #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) |