Re: [PATCH 1/3] cgroup: fix locking in cgroupstats_build()
On Fri, Feb 14, 2014 at 04:54:28PM +0800, Li Zefan wrote: > css_set_lock has been converted to css_set_rwsem, and rwsem can't > nested inside rcu_read_lock. > > Signed-off-by: Li Zefan Applied 1-3 to cgroup/for-3.15. Thanks! -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/3] cgroup: fix locking in cgroupstats_build()
css_set_lock has been converted to css_set_rwsem, and rwsem can't nested inside rcu_read_lock. Signed-off-by: Li Zefan --- kernel/cgroup.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index af4ecc3..0e794ca 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2997,6 +2997,8 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) kernfs_type(kn) != KERNFS_DIR) return -EINVAL; + mutex_lock(_mutex); + /* * We aren't being called from kernfs and there's no guarantee on * @kn->priv's validity. For this and css_tryget_from_dir(), @@ -3004,10 +3006,12 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) */ rcu_read_lock(); cgrp = rcu_dereference(kn->priv); - if (!cgrp) { + if (!cgrp || cgroup_is_dead(cgrp)) { rcu_read_unlock(); + mutex_unlock(_mutex); return -ENOENT; } + rcu_read_unlock(); css_task_iter_start(>dummy_css, ); while ((tsk = css_task_iter_next())) { @@ -3032,7 +3036,7 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) } css_task_iter_end(); - rcu_read_unlock(); + mutex_unlock(_mutex); return 0; } -- 1.8.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/3] cgroup: fix locking in cgroupstats_build()
css_set_lock has been converted to css_set_rwsem, and rwsem can't nested inside rcu_read_lock. Signed-off-by: Li Zefan lize...@huawei.com --- kernel/cgroup.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index af4ecc3..0e794ca 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2997,6 +2997,8 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) kernfs_type(kn) != KERNFS_DIR) return -EINVAL; + mutex_lock(cgroup_mutex); + /* * We aren't being called from kernfs and there's no guarantee on * @kn-priv's validity. For this and css_tryget_from_dir(), @@ -3004,10 +3006,12 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) */ rcu_read_lock(); cgrp = rcu_dereference(kn-priv); - if (!cgrp) { + if (!cgrp || cgroup_is_dead(cgrp)) { rcu_read_unlock(); + mutex_unlock(cgroup_mutex); return -ENOENT; } + rcu_read_unlock(); css_task_iter_start(cgrp-dummy_css, it); while ((tsk = css_task_iter_next(it))) { @@ -3032,7 +3036,7 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry) } css_task_iter_end(it); - rcu_read_unlock(); + mutex_unlock(cgroup_mutex); return 0; } -- 1.8.0.2 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 1/3] cgroup: fix locking in cgroupstats_build()
On Fri, Feb 14, 2014 at 04:54:28PM +0800, Li Zefan wrote: css_set_lock has been converted to css_set_rwsem, and rwsem can't nested inside rcu_read_lock. Signed-off-by: Li Zefan lize...@huawei.com Applied 1-3 to cgroup/for-3.15. Thanks! -- tejun -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/