]> git.itanic.dy.fi Git - linux-stable/commitdiff
cgroup: Use cgroup_attach_{lock,unlock}() from cgroup_attach_task_all()
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fri, 26 Aug 2022 02:48:29 +0000 (11:48 +0900)
committerTejun Heo <tj@kernel.org>
Fri, 26 Aug 2022 21:14:34 +0000 (11:14 -1000)
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>
kernel/cgroup/cgroup-internal.h
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup.c

index 36b740cb3d59ef1ee111912c516de1c3f281e008..2c7ecca226be8b8a7c2ff3503de6beb8e5858919 100644 (file)
@@ -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,
                       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,
                                             bool *locked)
        __acquires(&cgroup_threadgroup_rwsem);
index ff6a8099eb2a2f591a3ebab42c667a80e51bf82c..52bb5a74a23b98f8721466126ec84a8059c6a3f7 100644 (file)
@@ -59,8 +59,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
        int retval = 0;
 
        mutex_lock(&cgroup_mutex);
-       cpus_read_lock();
-       percpu_down_write(&cgroup_threadgroup_rwsem);
+       cgroup_attach_lock(true);
        for_each_root(root) {
                struct cgroup *from_cgrp;
 
@@ -72,8 +71,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
                if (retval)
                        break;
        }
-       percpu_up_write(&cgroup_threadgroup_rwsem);
-       cpus_read_unlock();
+       cgroup_attach_unlock(true);
        mutex_unlock(&cgroup_mutex);
 
        return retval;
index 65497a1a44fa85105513d06244593e3c23dd7692..0005de2e2ed9aebccb96218a4b033fba9630d86b 100644 (file)
@@ -2393,7 +2393,7 @@ EXPORT_SYMBOL_GPL(task_cgroup_path);
  * write-locking cgroup_threadgroup_rwsem. This allows ->attach() to assume that
  * CPU hotplug is disabled on entry.
  */
-static void cgroup_attach_lock(bool lock_threadgroup)
+void cgroup_attach_lock(bool lock_threadgroup)
 {
        cpus_read_lock();
        if (lock_threadgroup)
@@ -2404,7 +2404,7 @@ static void cgroup_attach_lock(bool lock_threadgroup)
  * cgroup_attach_unlock - Undo cgroup_attach_lock()
  * @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)
                percpu_up_write(&cgroup_threadgroup_rwsem);