History

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()

Linus Torvalds committed 3 years ago

Commit 9cd63572 parents 8d15d5e 5647e533 files · +20 −23Browse files

Unified · Split

3 files
  1. Documentation/admin-guide/cgroup-v2.rst +10 −12
  2. kernel/cgroup/cgroup-v1.c +2 −2
  3. kernel/cgroup/cgroup.c +8 −9
Documentation/admin-guide/cgroup-v2.rst+10−12
@@ -1213,23 +1213,25 @@ PAGE_SIZE multiple when read back. · 1212 unmodified lines
1213 A read-write single value file which exists on non-root1213 A read-write single value file which exists on non-root
1214 cgroups. The default is "max".1214 cgroups. The default is "max".
1215 1215
1216 Memory usage throttle limit. This is the main mechanism to1216 Memory usage throttle limit. If a cgroup's usage goes
1217 control memory usage of a cgroup. If a cgroup's usage goes
1218 over the high boundary, the processes of the cgroup are1217 over the high boundary, the processes of the cgroup are
1219 throttled and put under heavy reclaim pressure.1218 throttled and put under heavy reclaim pressure.
1220 1219
1221 Going over the high limit never invokes the OOM killer and1220 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.
1223 1225
1224 memory.max1226 memory.max
1225 A read-write single value file which exists on non-root1227 A read-write single value file which exists on non-root
1226 cgroups. The default is "max".1228 cgroups. The default is "max".
1227 1229
1228 Memory usage hard limit. This is the final protection1230 Memory usage hard limit. This is the main mechanism to limit
1229 mechanism. If a cgroup's memory usage reaches this limit and1231 memory usage of a cgroup. If a cgroup's memory usage reaches
1230 can't be reduced, the OOM killer is invoked in the cgroup.1232 this limit and can't be reduced, the OOM killer is invoked in
1231 Under certain circumstances, the usage may go over the limit1233 the cgroup. Under certain circumstances, the usage may go
1232 temporarily.1234 over the limit temporarily.
1233 1235
1234 In default configuration regular 0-order allocations always1236 In default configuration regular 0-order allocations always
1235 succeed unless OOM killer chooses current task as a victim.1237 succeed unless OOM killer chooses current task as a victim.
@@ -1238,10 +1240,6 @@ PAGE_SIZE multiple when read back. · 2 unmodified lines
1238 Caller could retry them differently, return into userspace1240 Caller could retry them differently, return into userspace
1239 as -ENOMEM or silently ignore in cases like disk readahead.1241 as -ENOMEM or silently ignore in cases like disk readahead.
1240 1242
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
1245 memory.reclaim1243 memory.reclaim
1246 A write-only nested-keyed file which exists for all cgroups.1244 A write-only nested-keyed file which exists for all cgroups.
1247 1245
kernel/cgroup/cgroup-v1.c+2−2
@@ -108,7 +108,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) · 107 unmodified lines
108 108
109 cgroup_lock();109 cgroup_lock();
110 110
111 percpu_down_write(&cgroup_threadgroup_rwsem);111 cgroup_attach_lock(true);
112 112
113 /* all tasks in @from are being moved, all csets are source */113 /* all tasks in @from are being moved, all csets are source */
114 spin_lock_irq(&css_set_lock);114 spin_lock_irq(&css_set_lock);
@@ -144,7 +144,7 @@ int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from) · 29 unmodified lines
144 } while (task && !ret);144 } while (task && !ret);
145out_err:145out_err:
146 cgroup_migrate_finish(&mgctx);146 cgroup_migrate_finish(&mgctx);
147 percpu_up_write(&cgroup_threadgroup_rwsem);147 cgroup_attach_unlock(true);
148 cgroup_unlock();148 cgroup_unlock();
149 return ret;149 return ret;
150}150}
kernel/cgroup/cgroup.c+8−9
@@ -6486,19 +6486,18 @@ err: · 6485 unmodified lines
6486static void cgroup_css_set_put_fork(struct kernel_clone_args *kargs)6486static void cgroup_css_set_put_fork(struct kernel_clone_args *kargs)
6487 __releases(&cgroup_threadgroup_rwsem) __releases(&cgroup_mutex)6487 __releases(&cgroup_threadgroup_rwsem) __releases(&cgroup_mutex)
6488{6488{
6489 struct cgroup *cgrp = kargs->cgrp;
6490 struct css_set *cset = kargs->cset;
6491
6489 cgroup_threadgroup_change_end(current);6492 cgroup_threadgroup_change_end(current);
6490 6493
6491 if (kargs->flags & CLONE_INTO_CGROUP) {6494 if (cset) {
6492 struct cgroup *cgrp = kargs->cgrp;6495 put_css_set(cset);
6493 struct css_set *cset = kargs->cset;6496 kargs->cset = NULL;
6497 }
6494 6498
6499 if (kargs->flags & CLONE_INTO_CGROUP) {
6495 cgroup_unlock();6500 cgroup_unlock();
6496
6497 if (cset) {
6498 put_css_set(cset);
6499 kargs->cset = NULL;
6500 }
6501
6502 if (cgrp) {6501 if (cgrp) {
6503 cgroup_put(cgrp);6502 cgroup_put(cgrp);
6504 kargs->cgrp = NULL;6503 kargs->cgrp = NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t