Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbdHNSdF (ORCPT ); Mon, 14 Aug 2017 14:33:05 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:50526 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdHNSc7 (ORCPT ); Mon, 14 Aug 2017 14:32:59 -0400 From: Roman Gushchin To: CC: Roman Gushchin , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , David Rientjes , Tejun Heo , , , , Subject: [v5 4/4] mm, oom, docs: describe the cgroup-aware OOM killer Date: Mon, 14 Aug 2017 19:32:13 +0100 Message-ID: <20170814183213.12319-5-guro@fb.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170814183213.12319-1-guro@fb.com> References: <20170814183213.12319-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:ff3d] X-ClientProxiedBy: VI1P194CA0014.EURP194.PROD.OUTLOOK.COM (2603:10a6:800:be::24) To BL2PR15MB1076.namprd15.prod.outlook.com (2603:10b6:201:17::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e8472f1-d031-4da4-7d42-08d4e342dc9f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BL2PR15MB1076; X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1076;3:O+gr8sOap+EPrEJQHXA2MWVFoQenmbPkHwq5hdGRSU58Ibqb0melIfbfngJVr5lbKUamDydX4HfuIya/IOCH7hwnoGF4iTDmZTd20CrNIMnFoU7D5Ux7TKi6K1zlsH+HKvP9mzBrbZZ9G+O9m/yJJArgbhh4ztA9PTbl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iGJlMLOAHFXXdriKxwDIQWwnKKn6yXHyFWaFsq2hQnDGJS4pg8qWmDpdj9XlLfp8SrY+d9eu0HimsIZXLbYDOH9467o3YETMFKG4V3dyM11pen0bWiVogjcun3DsgBHWZHPQY2NWWB91Eu/Qdiqi2L6OajEVxtkxTIQDMJbgqLfxarTadfualeiVBkBrCv 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)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(3002001)(920507026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123558100)(20161123555025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BL2PR15MB1076;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BL2PR15MB1076; X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1076;4:TP0qrvK18ipwegFpqqNwtpG10lcY5XRQVdi4prlW3CDZfJJvPvQEn1IzmpeCMfy0WKwCUHwFjL7wwk4GoJy2/ltkbxljpygs5Cac0pvT0ol2WQS/dTwqDlHqSPNw7Ir9w0KXsUlqnsPtETFQsO3TmNtY4M2Mbx9RITNhnTbCyfCiSuxVfCYFtd6+sbtYE5/SCphn57UX/wy2BvlfwAid8mUgqrBNIaXPQYJ/ku7DtEFyFdTaJEle4wJ2EWjWUm4HE/OcdL1mLJKGskojyX597O4lVPp5YURiFEO6hOQhArX70BY92Z5PPrJDJVx70XLi3+6D1WKnmg3SXKAQCWIp/IuKEQVZQB5dlp5CkHB4sROvzf6rTZr7w3E5jcM2dl2YV8sU65G9+VJkkCN/S5o1lWjlJa3q0qunf/cGDD/Rm/JkVm5NPDTbzZFNe4dkefBK X-Forefront-PRVS: 039975700A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(189002)(199003)(54906002)(6506006)(2906002)(76176999)(50986999)(4326008)(42186005)(8676002)(2361001)(50226002)(33646002)(50466002)(7416002)(53416004)(105586002)(106356001)(6116002)(1076002)(5660300001)(48376002)(2351001)(81166006)(81156014)(6486002)(101416001)(68736007)(34040400001)(478600001)(6666003)(110136004)(7736002)(69596002)(53936002)(97736004)(36756003)(6916009)(5003940100001)(189998001)(86362001)(2950100002)(47776003)(6512007)(305945005)(7350300001)(25786009)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR15MB1076;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR15MB1076;23:BDEVhE8ZVlnlwHwHLND2KKmLvnwvIENiP8djZd+K/?= =?us-ascii?Q?qz+BTtnKxjsDp1d8GTNC55Vd5DY0Hsleqv2GzRiqTpvW8RMjgpHuOy3GIjIs?= =?us-ascii?Q?NijfUjEekKCfbJ1s4UPo/r//CkBzYWPr+fKgdMml7ieA5i/99cJyVUunE2ha?= =?us-ascii?Q?LM4zy9xCaKj+jFO1GOHIUbg2aHIEf1UcOzR4e4nSk89+Xnk7024bUk+5uIdP?= =?us-ascii?Q?NGGSWkV98bpa/ouTm7+OH9Cr4q6j5TUR04GiJE6iI/Q8AH6FL3njTTGKBN+E?= =?us-ascii?Q?24P3kbGnkTUk0rrrjqlO9Ej9am49E2bwvMfVJ/MDsMxccCszwgbmU+3JiEF1?= =?us-ascii?Q?BfzAsw+b+TjcIIGi7WPGUIQ6VXTgnrGt1+ARyOnqPmxzsgD4OkaTUHiAxhOh?= =?us-ascii?Q?zqSGxpWWReaL1akcuZkRrTygxgFaiDp+izj81EP6IiRkB8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ant-OriginalArrivalTime: 14 Aug 2017 18:32:45.5805 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR15MB1076 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-08-14_16:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3861 Lines: 107 Update cgroups v2 docs. Signed-off-by: Roman Gushchin Cc: Michal Hocko Cc: Vladimir Davydov Cc: Johannes Weiner Cc: Tetsuo Handa 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 | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Documentation/cgroup-v2.txt b/Documentation/cgroup-v2.txt index dec5afdaa36d..22108f31e09d 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. Cgroup-aware OOM Killer 5-3. IO 5-3-1. IO Interface Files 5-3-2. Writeback @@ -1002,6 +1003,37 @@ 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_kill_all_tasks + + A read-write single value file which exits on non-root + cgroups. The default is "0". + + Defines whether the OOM killer should treat the cgroup + as a single entity during the victim selection. + + If set, OOM killer will kill all belonging tasks in + corresponding cgroup is selected as an OOM victim. + + Be default, OOM killer respect /proc/pid/oom_score_adj value + -1000, and will never kill the task, unless oom_kill_all_tasks + is set. + + memory.oom_priority + + A read-write single value file which exits on non-root + cgroups. The default is "0". + + An integer number within the [-10000, 10000] range, + which defines the order in which the OOM killer selects victim + memory cgroups. + + OOM killer prefers memory cgroups with larger priority if they + are populated with elegible tasks. + + The oom_priority value is compared within sibling cgroups. + + The root cgroup has the oom_priority 0, which cannot be changed. + memory.events A read-only flat-keyed file which exists on non-root cgroups. The following entries are defined. Unless specified @@ -1206,6 +1238,36 @@ POSIX_FADV_DONTNEED to relinquish the ownership of memory areas belonging to the affected files to ensure correct memory ownership. +Cgroup-aware OOM Killer +~~~~~~~~~~~~~~~~~~~~~~~ + +Cgroup v2 memory controller implements a cgroup-aware OOM killer. +It means that it treats memory cgroups as first class OOM entities. + +Under OOM conditions the memory controller tries to make the best +choise of a victim, hierarchically looking for the largest memory +consumer. By default, it will look for the biggest task in the +biggest leaf cgroup. + +Be default, all cgroups have oom_priority 0, and OOM killer will +chose the largest cgroup recursively on each level. For non-root +cgroups it's possible to change the oom_priority, and it will cause +the OOM killer to look athe the priority value first, and compare +sizes only of cgroups with equal priority. + +But a user can change this behavior by enabling the per-cgroup +oom_kill_all_tasks option. If set, it causes the OOM killer treat +the whole cgroup as an indivisible memory consumer. In case if it's +selected as on OOM victim, all belonging tasks will be killed. + +Tasks in the root cgroup are treated as independent memory consumers, +and are compared with other memory consumers (e.g. leaf cgroups). +The root cgroup doesn't support the oom_kill_all_tasks feature. + +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. + IO -- -- 2.13.5