Skip to content

Commit 14309e1

Browse files
committed
cgroup: Use cgroup_attach_{lock,unlock}() from cgroup_attach_task_all()
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> commit 075b593 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> (cherry picked from commit 075b593) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent fc57b89 commit 14309e1

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

kernel/cgroup/cgroup-internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup,
250250

251251
int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader,
252252
bool threadgroup);
253+
void cgroup_attach_lock(bool lock_threadgroup);
254+
void cgroup_attach_unlock(bool lock_threadgroup);
253255
struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup,
254256
bool *locked)
255257
__acquires(&cgroup_threadgroup_rwsem);

kernel/cgroup/cgroup-v1.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
5959
int retval = 0;
6060

6161
mutex_lock(&cgroup_mutex);
62-
cpus_read_lock();
63-
percpu_down_write(&cgroup_threadgroup_rwsem);
62+
cgroup_attach_lock(true);
6463
for_each_root(root) {
6564
struct cgroup *from_cgrp;
6665

@@ -75,8 +74,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
7574
if (retval)
7675
break;
7776
}
78-
percpu_up_write(&cgroup_threadgroup_rwsem);
79-
cpus_read_unlock();
77+
cgroup_attach_unlock(true);
8078
mutex_unlock(&cgroup_mutex);
8179

8280
return retval;

kernel/cgroup/cgroup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,7 @@ EXPORT_SYMBOL_GPL(task_cgroup_path);
23832383
* write-locking cgroup_threadgroup_rwsem. This allows ->attach() to assume that
23842384
* CPU hotplug is disabled on entry.
23852385
*/
2386-
static void cgroup_attach_lock(bool lock_threadgroup)
2386+
void cgroup_attach_lock(bool lock_threadgroup)
23872387
{
23882388
cpus_read_lock();
23892389
if (lock_threadgroup)
@@ -2394,7 +2394,7 @@ static void cgroup_attach_lock(bool lock_threadgroup)
23942394
* cgroup_attach_unlock - Undo cgroup_attach_lock()
23952395
* @lock_threadgroup: whether to up_write cgroup_threadgroup_rwsem
23962396
*/
2397-
static void cgroup_attach_unlock(bool lock_threadgroup)
2397+
void cgroup_attach_unlock(bool lock_threadgroup)
23982398
{
23992399
if (lock_threadgroup)
24002400
percpu_up_write(&cgroup_threadgroup_rwsem);

0 commit comments

Comments
 (0)