From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roman Gushchin Subject: [v11 6/6] mm, oom, docs: describe the cgroup-aware OOM killer Date: Thu, 5 Oct 2017 14:04:54 +0100 Message-ID: <20171005130454.5590-7-guro@fb.com> References: <20171005130454.5590-1-guro@fb.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=CmrXeXt3KZUA2oaEEW2kw+ZTtpKE65GsU9ihFRLVXno=; b=Lg8o6HaLimbp7DCgCiaJ6twmwJPnlZEt0OEz3wSrmSvnU6JSR3bFi5TDVs07c1+WP/rc UcAoU4l2fYJwcOM2KjmMEgy3RHF2ObJS9F/7Ai/g5c6BdgCJeTbJ+mTUT3fU7f2VtI7D sWMwj76wODm98MDIY0o89LyoQToa9PgX3Ts= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=CmrXeXt3KZUA2oaEEW2kw+ZTtpKE65GsU9ihFRLVXno=; b=TWhb7vU5nSqeIRaz09a6C9efVYGTCzpITVbpiD1PcBpodKERD4nlmPvbboewOSJn9tHP2LooUSCrZIqgrhNTJv5NIFUyt4NOptzEO2gcPA5Y4B/tJ+QGMVIAYkiPX+8afm9z0z9xyMIwuj4F6+TWPxA4LIKRs3F8Sxm3fRrT2Eo= In-Reply-To: <20171005130454.5590-1-guro@fb.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-mm@kvack.org Cc: Roman Gushchin , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , Andrew Morton , David Rientjes , Tejun Heo , kernel-team@fb.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Document the cgroup-aware OOM killer. Signed-off-by: Roman Gushchin Cc: Michal Hocko Cc: Vladimir Davydov Cc: Johannes Weiner Cc: Tetsuo Handa Cc: Andrew Morton Cc: David Rientjes Cc: Tejun Heo Cc: kernel-team@fb.com Cc: cgroups@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- Documentation/cgroup-v2.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index 3f8216912df0..28429e62b0ea 100644 --- a/Documentation/cgroup-v2.txt +++ b/Documentation/cgroup-v2.txt @@ -48,6 +48,7 @@ v1 is available under Documentation/cgroup-v1/. 5-2-1. Memory Interface Files 5-2-2. Usage Guidelines 5-2-3. Memory Ownership + 5-2-4. OOM Killer 5-3. IO 5-3-1. IO Interface Files 5-3-2. Writeback @@ -1043,6 +1044,28 @@ PAGE_SIZE multiple when read back. high limit is used and monitored properly, this limit's utility is limited to providing the final safety net. + memory.oom_group + + A read-write single value file which exists on non-root + cgroups. The default is "0". + + If set, OOM killer will consider the memory cgroup as an + indivisible memory consumers and compare it with other memory + consumers by it's memory footprint. + If such memory cgroup is selected as an OOM victim, all + processes belonging to it or it's descendants will be killed. + + This applies to system-wide OOM conditions and reaching + the hard memory limit of the cgroup and their ancestor. + If OOM condition happens in a descendant cgroup with it's own + memory limit, the memory cgroup can't be considered + as an OOM victim, and OOM killer will not kill all belonging + tasks. + + Also, OOM killer respects the /proc/pid/oom_score_adj value -1000, + and will never kill the unkillable task, even if memory.oom_group + is set. + memory.events A read-only flat-keyed file which exists on non-root cgroups. The following entries are defined. Unless specified @@ -1246,6 +1269,34 @@ to be accessed repeatedly by other cgroups, it may make sense to use POSIX_FADV_DONTNEED to relinquish the ownership of memory areas belonging to the affected files to ensure correct memory ownership. +OOM Killer +~~~~~~~~~~ + +Cgroup v2 memory controller implements a cgroup-aware OOM killer. +It means that it treats cgroups as first class OOM entities. + +Under OOM conditions the memory controller tries to make the best +choice of a victim, looking for a memory cgroup with the largest +memory footprint, considering leaf cgroups and cgroups with the +memory.oom_group option set, which are considered to be an indivisible +memory consumers. + +By default, OOM killer will kill the biggest task in the selected +memory cgroup. A user can change this behavior by enabling +the per-cgroup memory.oom_group option. If set, it causes +the OOM killer to kill all processes attached to the cgroup, +except processes with oom_score_adj set to -1000. + +This affects both system- and cgroup-wide OOMs. For a cgroup-wide OOM +the memory controller considers only cgroups belonging to the sub-tree +of the OOM'ing cgroup. + +The root cgroup is treated as a leaf memory cgroup, so it's compared +with other leaf memory cgroups and cgroups with oom_group option set. + +If there are no cgroups with the enabled memory controller, +the OOM killer is using the "traditional" process-based approach. + IO -- -- 2.13.6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f197.google.com (mail-wr0-f197.google.com [209.85.128.197]) by kanga.kvack.org (Postfix) with ESMTP id B2B386B0261 for ; Thu, 5 Oct 2017 09:06:02 -0400 (EDT) Received: by mail-wr0-f197.google.com with SMTP id y44so3823607wry.3 for ; Thu, 05 Oct 2017 06:06:02 -0700 (PDT) Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id s6si748121eda.14.2017.10.05.06.06.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 06:06:01 -0700 (PDT) From: Roman Gushchin Subject: [v11 6/6] mm, oom, docs: describe the cgroup-aware OOM killer Date: Thu, 5 Oct 2017 14:04:54 +0100 Message-ID: <20171005130454.5590-7-guro@fb.com> In-Reply-To: <20171005130454.5590-1-guro@fb.com> References: <20171005130454.5590-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: Roman Gushchin , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , Andrew Morton , David Rientjes , Tejun Heo , kernel-team@fb.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Document the cgroup-aware OOM killer. Signed-off-by: Roman Gushchin Cc: Michal Hocko Cc: Vladimir Davydov Cc: Johannes Weiner Cc: Tetsuo Handa Cc: Andrew Morton Cc: David Rientjes Cc: Tejun Heo Cc: kernel-team@fb.com Cc: cgroups@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- Documentation/cgroup-v2.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index 3f8216912df0..28429e62b0ea 100644 --- a/Documentation/cgroup-v2.txt +++ b/Documentation/cgroup-v2.txt @@ -48,6 +48,7 @@ v1 is available under Documentation/cgroup-v1/. 5-2-1. Memory Interface Files 5-2-2. Usage Guidelines 5-2-3. Memory Ownership + 5-2-4. OOM Killer 5-3. IO 5-3-1. IO Interface Files 5-3-2. Writeback @@ -1043,6 +1044,28 @@ PAGE_SIZE multiple when read back. high limit is used and monitored properly, this limit's utility is limited to providing the final safety net. + memory.oom_group + + A read-write single value file which exists on non-root + cgroups. The default is "0". + + If set, OOM killer will consider the memory cgroup as an + indivisible memory consumers and compare it with other memory + consumers by it's memory footprint. + If such memory cgroup is selected as an OOM victim, all + processes belonging to it or it's descendants will be killed. + + This applies to system-wide OOM conditions and reaching + the hard memory limit of the cgroup and their ancestor. + If OOM condition happens in a descendant cgroup with it's own + memory limit, the memory cgroup can't be considered + as an OOM victim, and OOM killer will not kill all belonging + tasks. + + Also, OOM killer respects the /proc/pid/oom_score_adj value -1000, + and will never kill the unkillable task, even if memory.oom_group + is set. + memory.events A read-only flat-keyed file which exists on non-root cgroups. The following entries are defined. Unless specified @@ -1246,6 +1269,34 @@ to be accessed repeatedly by other cgroups, it may make sense to use POSIX_FADV_DONTNEED to relinquish the ownership of memory areas belonging to the affected files to ensure correct memory ownership. +OOM Killer +~~~~~~~~~~ + +Cgroup v2 memory controller implements a cgroup-aware OOM killer. +It means that it treats cgroups as first class OOM entities. + +Under OOM conditions the memory controller tries to make the best +choice of a victim, looking for a memory cgroup with the largest +memory footprint, considering leaf cgroups and cgroups with the +memory.oom_group option set, which are considered to be an indivisible +memory consumers. + +By default, OOM killer will kill the biggest task in the selected +memory cgroup. A user can change this behavior by enabling +the per-cgroup memory.oom_group option. If set, it causes +the OOM killer to kill all processes attached to the cgroup, +except processes with oom_score_adj set to -1000. + +This affects both system- and cgroup-wide OOMs. For a cgroup-wide OOM +the memory controller considers only cgroups belonging to the sub-tree +of the OOM'ing cgroup. + +The root cgroup is treated as a leaf memory cgroup, so it's compared +with other leaf memory cgroups and cgroups with oom_group option set. + +If there are no cgroups with the enabled memory controller, +the OOM killer is using the "traditional" process-based approach. + IO -- -- 2.13.6 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbdJENGI (ORCPT ); Thu, 5 Oct 2017 09:06:08 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:51862 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751469AbdJENGC (ORCPT ); Thu, 5 Oct 2017 09:06:02 -0400 From: Roman Gushchin To: CC: Roman Gushchin , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , Andrew Morton , David Rientjes , Tejun Heo , , , , Subject: [v11 6/6] mm, oom, docs: describe the cgroup-aware OOM killer Date: Thu, 5 Oct 2017 14:04:54 +0100 Message-ID: <20171005130454.5590-7-guro@fb.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171005130454.5590-1-guro@fb.com> References: <20171005130454.5590-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:4726] X-ClientProxiedBy: AM3PR07CA0101.eurprd07.prod.outlook.com (2603:10a6:207:7::11) To DM3PR15MB1081.namprd15.prod.outlook.com (2603:10b6:0:12::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a6d90e4-b113-47a6-dea4-08d50bf1c4fa X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:DM3PR15MB1081; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;3:G9/TQxFW7vOa2JaWW6BpEcsjcUKNvY16yP/Uzd1Ak7r0gH27SGBCEThyK8gszLqf8DbOGITp1glgHc9xmtx5ZYP0G5F6fKsonn+LvtE1Bb4AhwNpCQM+Lh7KhNjoszAZPYwyBHon0hV882Ipo1XPeYVp06WWLbLy12FhdMAtMXyo2a41lNk1OeAX4sHOII4kM7L2LjhEQlZEe96XEhPqoqmTuwmtLlKtHh1tRhBPVsdWuxKvzGJj27FiklZJMXns;25:v3ASdV4dIB66pyx+389hgmRklHZr8OD+amyrKFStA6l0u1fv8cRa5ZrCWfu3Qv0UBEHjkvUGD3ZAUQ/tAjkIOj58sBilJ/xrDjhh9qgsh7285SOIjUaCjsBnyLjr5ucB52QFGavqO7k/PFY/TCtlX7/uaFFOTLZvRwBvUEc+oPHd7PQArlCkZxEv2rkPdWmjvN++8RS+zAcV+hT0N9Bw2XxFZCnHbWsg1Mr21ZokFbScs1q8p6RA2BMzv62KGWc1LPJyv/YIwTXP3cxn+Hpzu3nkrY9bF6UnMzo2hqDZ0FdpzqbVaulbGMmU9VUA7XycAAA74piMpZ+3ij0PMRb/bg==;31:vsmPYoW0k4zpx2Rkee7Nyt1cm0357UWHwR8KTJtVRlHx/NgbesQcDSrfGTe8t0Oq2fo/fUWnJfzLdzYWgyxtbOzqhnNWl7OeqbmdfyPk1VayyPR6XjXU9RF1yRoagm1HnL73VzqWTHFGdUjxyIAu3P0Br7fcDSazVbzVe17BnLIHpcZLYGCM8FgktOWw5JBlV8Z5bKaL9LIMGzHpe6hoLjM7P4/SyWO4IYuZRkSdGxY= X-MS-TrafficTypeDiagnostic: DM3PR15MB1081: X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;20:7XsG8kGY2iH1AZC1+cDj35nu1HOdOy995Z/9LV4QPDuBUghxySWq+YCSisHJeAMiryhXWadQZE01YOM8L5IgN5mp5AXNseRe+iEQDtsITtU8PcfYFyU02/A959XtXid5NyZfFpLzMtMxWPPzL9JPdFZxzT8NecCPfQ+yki+prFiBNr7berpklc4F3of/GEOG84SVrAXv1gQl2YGxqIKUM3Y5bzzDzFYmZYsdiIwEy9pBufRR5U61GBQ3Sjrm8ZzXzNjTIbUNrgwtdsyyFJxRYVSXJo1/hlYl+46iR+nitixXGlLU9MXPjHqj4fM4MOIGDK0XIGxR0TfYsBCgUeDyqA/NrZLFPRi+FkifqoeVIVnxXziESQyXuvi2KxCYJRquFq4Njj/W+Bbbtz9MZMRDlHJALinY9+kQ6Jc08/SRs5Pm34gjMwvrqddLI8njmamPGkfbLkjh+/d1uQyNvKdmoxxiqm8IbYuc/dQbx8qsyrmkvqgO13FarOnTcCEm2FWl X-Exchange-Antispam-Report-Test: UriScan:(60795455431006)(9452136761055)(67672495146484)(211936372134217)(153496737603132); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(920507026)(6041248)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM3PR15MB1081;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM3PR15MB1081; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;4:AN9V9NI8hlFMF7gXHSdqCyEfNzS+CD6TzFd3geVE9EAqsK3Wd+TlWRjj46LC+5hFNbB66cBYll0WUNTaY8fbXuV3vFjRTIxRD7UJq8kuckF7a08jQkVZow2IN90ESle/j4iKsmUX1mRHkZdayMNNjdvxPT1wxcYCGAD6IEwWJ/WWNcdMN5k0QiSiPKHT4ZJaqN2PN1qqcBvLUG5bROOV7tBFqIRLT2yepyoqY+JqWfFZ7zbA+id/nMbck8FPRG4Ph6tcKleWUNqYoamtOMeGcphRl3q/QQhQQ0tI+hkaysr5o6A3wtwtGX3K8i0lmNL52SJA2VB4c1f+I/iKFdY/AXR6hM34GFCRPKpZM0rMcuyE76JdM1JSHbEBEyxbBq8Je+sRXavj0Fsj5Dqm/VlASChnH71n73tKhY9ZreqZpUFGGVTvy97B8xE1bFA+/q4f X-Forefront-PRVS: 04519BA941 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(346002)(199003)(189002)(5890100001)(2351001)(53416004)(6666003)(2361001)(478600001)(2950100002)(4326008)(39060400002)(36756003)(76176999)(50986999)(68736007)(8676002)(50226002)(33646002)(105586002)(189998001)(106356001)(305945005)(81156014)(6486002)(101416001)(81166006)(8936002)(7736002)(6916009)(6512007)(1076002)(69596002)(47776003)(50466002)(5003940100001)(48376002)(6506006)(34040400001)(86362001)(16586007)(575784001)(5660300001)(6116002)(97736004)(316002)(54906003)(53936002)(7416002)(25786009)(2906002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB1081;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR15MB1081;23:v9mn4mEPwiBy5rHu1aSOGAhsPYRtV6JZV/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bCKL9d/55FfixH1c=;7:jBvKE2TAzJCcYATg80F63o4cxRn7z/fBc0TecofwnTx24ki+WeL6R9Rg5ayWwngcb6dGG6mXfozFkkfL4ofuN+1gCaXke9yoeJxo4Cp2G834uHb48jDBUYnCkRhauY1KdBvPkJjmA03MwniW0ZLFCYIJoWC+bQxTgWVX6kL2gpacRsrp870BuKIyUY17JsJVfZCXaxfY7oN7mJXK7qhWw5u3I7O+p+3iuIXSjKkKFQc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;20:1Zy6wGVFKiJF2IwqaJ0CeIw6brU7RoB/IbTQwjU24LG0rUlDmRk0jXQkH7mhTA0G0e35zWmO928LYsp3YsxwH8DrqnJQn7kR53JBSdV4fxjXUHHg1A9Vekt3tQvk1rZbC9MPAFkMW3fNf12+YcQIL0rlNVLf+Gl5qCyAe7jsHcg= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2017 13:05:34.0716 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR15MB1081 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-05_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document the cgroup-aware OOM killer. Signed-off-by: Roman Gushchin Cc: Michal Hocko Cc: Vladimir Davydov Cc: Johannes Weiner Cc: Tetsuo Handa Cc: Andrew Morton Cc: David Rientjes Cc: Tejun Heo Cc: kernel-team@fb.com Cc: cgroups@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- Documentation/cgroup-v2.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index 3f8216912df0..28429e62b0ea 100644 --- a/Documentation/cgroup-v2.txt +++ b/Documentation/cgroup-v2.txt @@ -48,6 +48,7 @@ v1 is available under Documentation/cgroup-v1/. 5-2-1. Memory Interface Files 5-2-2. Usage Guidelines 5-2-3. Memory Ownership + 5-2-4. OOM Killer 5-3. IO 5-3-1. IO Interface Files 5-3-2. Writeback @@ -1043,6 +1044,28 @@ PAGE_SIZE multiple when read back. high limit is used and monitored properly, this limit's utility is limited to providing the final safety net. + memory.oom_group + + A read-write single value file which exists on non-root + cgroups. The default is "0". + + If set, OOM killer will consider the memory cgroup as an + indivisible memory consumers and compare it with other memory + consumers by it's memory footprint. + If such memory cgroup is selected as an OOM victim, all + processes belonging to it or it's descendants will be killed. + + This applies to system-wide OOM conditions and reaching + the hard memory limit of the cgroup and their ancestor. + If OOM condition happens in a descendant cgroup with it's own + memory limit, the memory cgroup can't be considered + as an OOM victim, and OOM killer will not kill all belonging + tasks. + + Also, OOM killer respects the /proc/pid/oom_score_adj value -1000, + and will never kill the unkillable task, even if memory.oom_group + is set. + memory.events A read-only flat-keyed file which exists on non-root cgroups. The following entries are defined. Unless specified @@ -1246,6 +1269,34 @@ to be accessed repeatedly by other cgroups, it may make sense to use POSIX_FADV_DONTNEED to relinquish the ownership of memory areas belonging to the affected files to ensure correct memory ownership. +OOM Killer +~~~~~~~~~~ + +Cgroup v2 memory controller implements a cgroup-aware OOM killer. +It means that it treats cgroups as first class OOM entities. + +Under OOM conditions the memory controller tries to make the best +choice of a victim, looking for a memory cgroup with the largest +memory footprint, considering leaf cgroups and cgroups with the +memory.oom_group option set, which are considered to be an indivisible +memory consumers. + +By default, OOM killer will kill the biggest task in the selected +memory cgroup. A user can change this behavior by enabling +the per-cgroup memory.oom_group option. If set, it causes +the OOM killer to kill all processes attached to the cgroup, +except processes with oom_score_adj set to -1000. + +This affects both system- and cgroup-wide OOMs. For a cgroup-wide OOM +the memory controller considers only cgroups belonging to the sub-tree +of the OOM'ing cgroup. + +The root cgroup is treated as a leaf memory cgroup, so it's compared +with other leaf memory cgroups and cgroups with oom_group option set. + +If there are no cgroups with the enabled memory controller, +the OOM killer is using the "traditional" process-based approach. + IO -- -- 2.13.6