cgroup: Use cgroup_attach_{lock,unlock}() from cgroup_attach_task_all()
No behavior changes; preparing for potential locking changes in future. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Reviewed-by:Mukesh Ojha <quic_mojha@quicinc.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
265efc941f
commit
075b593f54
|
@ -250,6 +250,8 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup,
|
||||||
|
|
||||||
int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
|
int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
|
||||||
bool threadgroup);
|
bool threadgroup);
|
||||||
|
void cgroup_attach_lock(bool lock_threadgroup);
|
||||||
|
void cgroup_attach_unlock(bool lock_threadgroup);
|
||||||
struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
|
struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
|
||||||
bool *locked)
|
bool *locked)
|
||||||
__acquires(&cgroup_threadgroup_rwsem);
|
__acquires(&cgroup_threadgroup_rwsem);
|
||||||
|
|
|
@ -59,8 +59,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
mutex_lock(&cgroup_mutex);
|
mutex_lock(&cgroup_mutex);
|
||||||
cpus_read_lock();
|
cgroup_attach_lock(true);
|
||||||
percpu_down_write(&cgroup_threadgroup_rwsem);
|
|
||||||
for_each_root(root) {
|
for_each_root(root) {
|
||||||
struct cgroup *from_cgrp;
|
struct cgroup *from_cgrp;
|
||||||
|
|
||||||
|
@ -72,8 +71,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
|
||||||
if (retval)
|
if (retval)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
percpu_up_write(&cgroup_threadgroup_rwsem);
|
cgroup_attach_unlock(true);
|
||||||
cpus_read_unlock();
|
|
||||||
mutex_unlock(&cgroup_mutex);
|
mutex_unlock(&cgroup_mutex);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
|
@ -2393,7 +2393,7 @@ EXPORT_SYMBOL_GPL(task_cgroup_path);
|
||||||
* write-locking cgroup_threadgroup_rwsem. This allows ->attach() to assume that
|
* write-locking cgroup_threadgroup_rwsem. This allows ->attach() to assume that
|
||||||
* CPU hotplug is disabled on entry.
|
* CPU hotplug is disabled on entry.
|
||||||
*/
|
*/
|
||||||
static void cgroup_attach_lock(bool lock_threadgroup)
|
void cgroup_attach_lock(bool lock_threadgroup)
|
||||||
{
|
{
|
||||||
cpus_read_lock();
|
cpus_read_lock();
|
||||||
if (lock_threadgroup)
|
if (lock_threadgroup)
|
||||||
|
@ -2404,7 +2404,7 @@ static void cgroup_attach_lock(bool lock_threadgroup)
|
||||||
* cgroup_attach_unlock - Undo cgroup_attach_lock()
|
* cgroup_attach_unlock - Undo cgroup_attach_lock()
|
||||||
* @lock_threadgroup: whether to up_write cgroup_threadgroup_rwsem
|
* @lock_threadgroup: whether to up_write cgroup_threadgroup_rwsem
|
||||||
*/
|
*/
|
||||||
static void cgroup_attach_unlock(bool lock_threadgroup)
|
void cgroup_attach_unlock(bool lock_threadgroup)
|
||||||
{
|
{
|
||||||
if (lock_threadgroup)
|
if (lock_threadgroup)
|
||||||
percpu_up_write(&cgroup_threadgroup_rwsem);
|
percpu_up_write(&cgroup_threadgroup_rwsem);
|
||||||
|
|
Loading…
Reference in New Issue