Skip to content

Commit 9cd6357

Browse files
committed
Merge tag 'cgroup-for-6.4-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fixes from Tejun Heo: - Fix css_set reference leaks on fork failures - Fix CPU hotplug locking in cgroup_transfer_tasks() which is used by cgroup1 cpuset - Doc update * tag 'cgroup-for-6.4-rc5-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: Documentation: Clarify usage of memory limits cgroup: always put cset in cgroup_css_set_put_fork cgroup: fix missing cpus_read_{lock,unlock}() in cgroup_transfer_tasks()
2 parents 8d15d5e + 5647e53 commit 9cd6357

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,23 +1213,25 @@ PAGE_SIZE multiple when read back.
12131213
A read-write single value file which exists on non-root
12141214
cgroups. The default is "max".
12151215

1216-
Memory usage throttle limit. This is the main mechanism to
1217-
control memory usage of a cgroup. If a cgroup's usage goes
1216+
Memory usage throttle limit. If a cgroup's usage goes
12181217
over the high boundary, the processes of the cgroup are
12191218
throttled and put under heavy reclaim pressure.
12201219

12211220
Going over the high limit never invokes the OOM killer and
1222-
under extreme conditions the limit may be breached.
1221+
under extreme conditions the limit may be breached. The high
1222+
limit should be used in scenarios where an external process
1223+
monitors the limited cgroup to alleviate heavy reclaim
1224+
pressure.
12231225

12241226
memory.max
12251227
A read-write single value file which exists on non-root
12261228
cgroups. The default is "max".
12271229

1228-
Memory usage hard limit. This is the final protection
1229-
mechanism. If a cgroup's memory usage reaches this limit and
1230-
can't be reduced, the OOM killer is invoked in the cgroup.
1231-
Under certain circumstances, the usage may go over the limit
1232-
temporarily.
1230+
Memory usage hard limit. This is the main mechanism to limit
1231+
memory usage of a cgroup. If a cgroup's memory usage reaches
1232+
this limit and can't be reduced, the OOM killer is invoked in
1233+
the cgroup. Under certain circumstances, the usage may go
1234+
over the limit temporarily.
12331235

12341236
In default configuration regular 0-order allocations always
12351237
succeed unless OOM killer chooses current task as a victim.
@@ -1238,10 +1240,6 @@ PAGE_SIZE multiple when read back.
12381240
Caller could retry them differently, return into userspace
12391241
as -ENOMEM or silently ignore in cases like disk readahead.
12401242

1241-
This is the ultimate protection mechanism. As long as the
1242-
high limit is used and monitored properly, this limit's
1243-
utility is limited to providing the final safety net.
1244-
12451243
memory.reclaim
12461244
A write-only nested-keyed file which exists for all cgroups.
12471245

kernel/cgroup/cgroup-v1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
108108

109109
cgroup_lock();
110110

111-
percpu_down_write(&cgroup_threadgroup_rwsem);
111+
cgroup_attach_lock(true);
112112

113113
/* all tasks in @from are being moved, all csets are source */
114114
spin_lock_irq(&css_set_lock);
@@ -144,7 +144,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from)
144144
} while (task && !ret);
145145
out_err:
146146
cgroup_migrate_finish(&mgctx);
147-
percpu_up_write(&cgroup_threadgroup_rwsem);
147+
cgroup_attach_unlock(true);
148148
cgroup_unlock();
149149
return ret;
150150
}

kernel/cgroup/cgroup.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6486,19 +6486,18 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
64866486
static void cgroup_css_set_put_fork(struct kernel_clone_args *kargs)
64876487
__releases(&cgroup_threadgroup_rwsem) __releases(&cgroup_mutex)
64886488
{
6489+
struct cgroup *cgrp = kargs->cgrp;
6490+
struct css_set *cset = kargs->cset;
6491+
64896492
cgroup_threadgroup_change_end(current);
64906493

6491-
if (kargs->flags & CLONE_INTO_CGROUP) {
6492-
struct cgroup *cgrp = kargs->cgrp;
6493-
struct css_set *cset = kargs->cset;
6494+
if (cset) {
6495+
put_css_set(cset);
6496+
kargs->cset = NULL;
6497+
}
64946498

6499+
if (kargs->flags & CLONE_INTO_CGROUP) {
64956500
cgroup_unlock();
6496-
6497-
if (cset) {
6498-
put_css_set(cset);
6499-
kargs->cset = NULL;
6500-
}
6501-
65026501
if (cgrp) {
65036502
cgroup_put(cgrp);
65046503
kargs->cgrp = NULL;

0 commit comments

Comments
 (0)