doc: cgroup: update note about conditions when oom killer is invoked
Subsystems (3)
PATCH 1/1 doc: cgroup: update note about conditions when oom killer is invoked
Starting from v4.19 commit 29ef680ae7c2 ("memcg, oom: move out_of_memory back to the charge path") cgroup oom killer is no longer invoked only from page faults. Now it implements the same semantics as global OOM killer:
allocation context invokes OOM killer and keeps retrying until success.
--- Documentation/admin-guide/cgroup-v2.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +8 -9
@@ -1172,6 +1172,13 @@ PAGE_SIZE multiple when read back. Under certain circumstances, the usage may go over the limit temporarily. + In default configuration regular 0-order allocation always + succeed unless OOM killer choose current task as a victim. + + Some kinds of allocations don't invoke the OOM killer. + Caller could retry them differently, return into userspace + as -ENOMEM or silently ignore in cases like disk readahead. + This is the ultimate protection mechanism. As long as the high limit is used and monitored properly, this limit's utility is limited to providing the final safety net.
@@ -1228,17 +1235,9 @@ PAGE_SIZE multiple when read back. The number of time the cgroup's memory usage was reached the limit and allocation was about to fail. - Depending on context result could be invocation of OOM - killer and retrying allocation or failing allocation. - - Failed allocation in its turn could be returned into - userspace as -ENOMEM or silently ignored in cases like - disk readahead. For now OOM in memory cgroup kills - tasks iff shortage has happened inside page fault. - This event is not raised if the OOM killer is not considered as an option, e.g. for failed high-order - allocations. + allocations or if caller asked to not retry attempts. oom_kill The number of processes belonging to this cgroup
Randy Dunlap
reviewerHi,
Quoted 15 lines · Konstantin Khlebnikov
Starting from v4.19 commit
29ef680ae7c2("memcg, oom: moveout_of_memoryback to the charge path") cgroup oom killer is no longer invoked only from page faults. Now it implements the same semantics as global OOM killer:
allocation context invokes OOM killer and keeps retrying until success.Signed-off-by Konstantin Khlebnikov <[email protected]>--- Documentation/admin-guide/cgroup-v2.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)Documentation/admin-guide/cgroup-v2.rst +0
-0
Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1175
Quoted 4 lines
Documentation/admin-guide/cgroup-v2.rst +1
-0@@ -1172,6 +1172,13 @@ PAGE_SIZE multiple when read back. Under certain circumstances, the usage may go over the limit temporarily. + In default configuration regular 0-order allocation always
allocations
Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1176
Quoted 1 line
Documentation/admin-guide/cgroup-v2.rst +1
-0+ succeed unless OOM killer choose current task as a victim.
chooses
Quoted 18 lines
Documentation/admin-guide/cgroup-v2.rst +5
-5+ + Some kinds of allocations don't invoke the OOM killer. + Caller could retry them differently, return into userspace + as -ENOMEM or silently ignore in cases like disk readahead. + This is the ultimate protection mechanism. As long as the high limit is used and monitored properly, this limit's utility is limited to providing the final safety net.@@ -1228,17 +1235,9 @@ PAGE_SIZE multiple when read back. The number of time the cgroup's memory usage was reached the limit and allocation was about to fail. - Depending on context result could be invocation of OOM - killer and retrying allocation or failing allocation. - - Failed allocation in its turn could be returned into - userspace as -ENOMEM or silently ignored in cases like
Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1243
Quoted 10 lines
Documentation/admin-guide/cgroup-v2.rst +1
-4- disk readahead. For now OOM in memory cgroup kills - tasks iff shortage has happened inside page fault. - This event is not raised if the OOM killer is not considered as an option, e.g. for failed high-order - allocations. + allocations or if caller asked to not retry attempts. oom_kill The number of processes belonging to this cgroup
thanks for updating the docs.
Signature · 1 line
~Randy
Quoted 6 lines · Konstantin Khlebnikov
Starting from v4.19 commit
29ef680ae7c2("memcg, oom: moveout_of_memoryback to the charge path") cgroup oom killer is no longer invoked only from page faults. Now it implements the same semantics as global OOM killer:
allocation context invokes OOM killer and keeps retrying until success.Signed-off-by Konstantin Khlebnikov <[email protected]>
Quoted 9 lines
--- Documentation/admin-guide/cgroup-v2.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)Documentation/admin-guide/cgroup-v2.rst +0
-0
Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1180
Quoted 9 lines
Documentation/admin-guide/cgroup-v2.rst +6
-0@@ -1172,6 +1172,13 @@ PAGE_SIZE multiple when read back. Under certain circumstances, the usage may go over the limit temporarily. + In default configuration regular 0-order allocation always + succeed unless OOM killer choose current task as a victim. + + Some kinds of allocations don't invoke the OOM killer. + Caller could retry them differently, return into userspace + as -ENOMEM or silently ignore in cases like disk readahead.
I would probably add -EFAULT but the less error codes we document the better.
Quoted 23 lines
Documentation/admin-guide/cgroup-v2.rst +2
-9+ This is the ultimate protection mechanism. As long as the high limit is used and monitored properly, this limit's utility is limited to providing the final safety net.@@ -1228,17 +1235,9 @@ PAGE_SIZE multiple when read back. The number of time the cgroup's memory usage was reached the limit and allocation was about to fail. - Depending on context result could be invocation of OOM - killer and retrying allocation or failing allocation. - - Failed allocation in its turn could be returned into - userspace as -ENOMEM or silently ignored in cases like - disk readahead. For now OOM in memory cgroup kills - tasks iff shortage has happened inside page fault. - This event is not raised if the OOM killer is not considered as an option, e.g. for failed high-order - allocations. + allocations or if caller asked to not retry attempts. oom_kill The number of processes belonging to this cgroup
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 22 lines · Michal Hocko
Quoted 6 lines · Konstantin Khlebnikov
Starting from v4.19 commit
29ef680ae7c2("memcg, oom: moveout_of_memoryback to the charge path") cgroup oom killer is no longer invoked only from page faults. Now it implements the same semantics as global OOM killer:
allocation context invokes OOM killer and keeps retrying until success.Signed-off-by Konstantin Khlebnikov <[email protected]>Acked-by Michal Hocko <[email protected]>Quoted 12 lines
--- Documentation/admin-guide/cgroup-v2.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)Documentation/admin-guide/cgroup-v2.rst +0
-0@@ -1172,6 +1172,13 @@ PAGE_SIZE multiple when read back. Under certain circumstances, the usage may go over the limit temporarily.
Quoted 9 lines
Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1180
Quoted 6 lines
Documentation/admin-guide/cgroup-v2.rst +6
-0+ In default configuration regular 0-order allocation always + succeed unless OOM killer choose current task as a victim. + + Some kinds of allocations don't invoke the OOM killer. + Caller could retry them differently, return into userspace + as -ENOMEM or silently ignore in cases like disk readahead.I would probably add
-EFAULTbut the less error codes we document the better.
Yeah, EFAULT was a most obscure result of memory shortage. Fortunately with new behaviour this shouldn't happens a lot.
Actually where it is still possible? THP always fallback to 0-order. I mean EFAULT could appear inside kernel only if task is killed so nobody would see it.
Quoted 25 lines
Quoted 24 lines
Documentation/admin-guide/cgroup-v2.rst +2
-9+ This is the ultimate protection mechanism. As long as the high limit is used and monitored properly, this limit's utility is limited to providing the final safety net.@@ -1228,17 +1235,9 @@ PAGE_SIZE multiple when read back. The number of time the cgroup's memory usage was reached the limit and allocation was about to fail. - Depending on context result could be invocation of OOM - killer and retrying allocation or failing allocation. - - Failed allocation in its turn could be returned into - userspace as -ENOMEM or silently ignored in cases like - disk readahead. For now OOM in memory cgroup kills - tasks iff shortage has happened inside page fault. - This event is not raised if the OOM killer is not considered as an option, e.g. for failed high-order - allocations. + allocations or if caller asked to not retry attempts. oom_kill The number of processes belonging to this cgroup
Quoted 34 lines · Konstantin Khlebnikov
Quoted 14 lines · Michal Hocko
Quoted 6 lines · Konstantin Khlebnikov
Starting from v4.19 commit
29ef680ae7c2("memcg, oom: moveout_of_memoryback to the charge path") cgroup oom killer is no longer invoked only from page faults. Now it implements the same semantics as global OOM killer:
allocation context invokes OOM killer and keeps retrying until success.Signed-off-by Konstantin Khlebnikov <[email protected]>Acked-by Michal Hocko <[email protected]>Quoted 4 lines
--- Documentation/admin-guide/cgroup-v2.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)Quoted 16 lines
Documentation/admin-guide/cgroup-v2.rst PAGE_SIZE multiple when read back. · line 1179
Quoted 13 lines
Documentation/admin-guide/cgroup-v2.rst +6
-0@@ -1172,6 +1172,13 @@ PAGE_SIZE multiple when read back. Under certain circumstances, the usage may go over the limit temporarily. + In default configuration regular 0-order allocation always + succeed unless OOM killer choose current task as a victim. + + Some kinds of allocations don't invoke the OOM killer. + Caller could retry them differently, return into userspace + as -ENOMEM or silently ignore in cases like disk readahead.I would probably add
-EFAULTbut the less error codes we document the better.
Quoted 2 lines
Yeah, EFAULT was a most obscure result of memory shortage. Fortunately with new behaviour this shouldn't happens a lot.
Yes, it shouldn't really happen very often. gup was the most prominent example but this one should be taken care of by triggering the OOM killer. But I wouldn't bet my hat there are no potential cases anymore.
Quoted 3 lines
Actually where it is still possible? THP always fallback to 0-order. I mean EFAULT could appear inside kernel only if task is killed so nobody would see it.
Yes fatal_signal_pending paths are ok. And no I do not have any specific examples. But as you've said EFAULT was a real surprise so I thought it would be nice to still keep a reference for it around. Even when it is unlikely.
Signature · 2 lines
Michal Hocko SUSE Labs