Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbdHQMUY (ORCPT ); Thu, 17 Aug 2017 08:20:24 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:49831 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751578AbdHQMUU (ORCPT ); Thu, 17 Aug 2017 08:20:20 -0400 Date: Thu, 17 Aug 2017 13:16:47 +0100 From: Roman Gushchin To: David Rientjes CC: , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , Tejun Heo , , , , Subject: Re: [v5 4/4] mm, oom, docs: describe the cgroup-aware OOM killer Message-ID: <20170817121647.GA26107@castle.DHCP.thefacebook.com> References: <20170814183213.12319-1-guro@fb.com> <20170814183213.12319-5-guro@fb.com> <20170815141350.GA4510@castle.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.3 (2017-05-23) X-Originating-IP: [2620:10d:c092:200::1:7eb2] X-ClientProxiedBy: DB6PR0202CA0035.eurprd02.prod.outlook.com (2603:10a6:4:a5::21) To DM3PR15MB1084.namprd15.prod.outlook.com (2603:10b6:0:12::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 507ff6ae-36e6-4a0e-764a-08d4e569dc1f 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:DM3PR15MB1084; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1084;3:81Lxyf8ENL5mxJoludrg6r69gefrHUHfouKNje1PJ5UocV4HG2QUSBKlwcNIMSy0qVVwxYvI0PYhlhLOwmdLwQXO8dnw2t7IoutnhHBEHWq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dASaoFnfja3U2fnR8q0/LGQTBbYGELx3Z7ezZzhSW0ox8JAgPNrwXy3XpCEMVtQAKmjyBPqlAPHiGROaIdKb52MuAjkajKwxz767RwKvJFzQidyNDEvHPi8Ld5Y7tJA+QgybORbdm3f7+WfQAraq5rfJx12gQ/ltgRKJcxoj34ifnRx3Ftq16U2oArrXH31ED3+VT6/2vCUxRrAU6nO+OX5TRmJe3SEyb 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)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(920507026)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM3PR15MB1084;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM3PR15MB1084; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1084;4:Th2IizvJd0WqT8Ctt3emioKTuRyhSHO5rUVgo3S6PzVVXTI9UBheuRvbdNSvCqFHNIw7sI7YDX/yFS94C2IdfhDpK+KAPJHgufKg9IhBCNDUy+zdssUKpppllyVdBQLGqGeAVFtxrnMpsWTZnb1mMsKk4XciVJYOhlSFlL/iGbG9FkQUX+3JLBkKVW6SIRs7wylKybOmxnP0Pkk9BCqrpSR2POQ8QYm3p74GsRIiyzCFlRI8mxY8jjSj29KezzXf+lTe5Sxx4uJr0+SPlsk6bKM5QQpFgu4W6O2Pu29j/A1W1iCqLeoXv6W2vAxHiyCrDYPJSHKnd8ges7vHBd7f8sbesFEBvZ34aGrWlnK+sGBVhk2tU75PoKI/L2VknuWo0qwGx6P+szIOjbVihp0Yo43NGU2SCr1BKBd47xBFLp1w+OjJi6PI9IQ8GFlPhITu X-Forefront-PRVS: 0402872DA1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(189002)(199003)(81166006)(53936002)(81156014)(8676002)(25786009)(54906002)(9686003)(50466002)(55016002)(68736007)(83506001)(86362001)(575784001)(93886005)(97736004)(76176999)(50986999)(4001350100001)(54356999)(53546010)(2906002)(4326008)(1076002)(6116002)(23726003)(478600001)(6246003)(47776003)(106356001)(105586002)(110136004)(33656002)(101416001)(7350300001)(42186005)(5890100001)(7736002)(6666003)(2950100002)(6916009)(5660300001)(189998001)(229853002)(7416002)(305945005)(34040400001)(6506006)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB1084;H:castle.DHCP.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR15MB1084;23:gua8zTLaSi3S03+cl2lJXAHQKjoy1onJ7MaFw+J3Y?= =?us-ascii?Q?9OEBXr8ehAk0Vb5xB7F5IKTmhgZ76QyZgpIuCmdCJPiGsSxgvWviDDMb8gq4?= =?us-ascii?Q?yZrnTTpnLU44kUcHdSbgXAp7ewyCjC8+E82uogF73k4gxAAIKzCfNQfEnhl+?= =?us-ascii?Q?ZBN8hXGNetV21W9Vi42jcFm8TURFOclSthZepGLnaoADPQLgGLtaStU67fiS?= =?us-ascii?Q?zruIuMSty0FnJop3odmy08+ppZMfEHelY4h1JlmzZ4g31RxyY1/56VQ2OBwv?= =?us-ascii?Q?Q7GzxMOkgRZLeLyVsvKN818Wp2z2FQIM7hHD3mErlbmnr0Dc+14XbmHkecmK?= =?us-ascii?Q?7XGN1U65Ww7NGdWtjZtZVw3vQcL5ow3x0xCj3PzS9Jj2Wnj/5QGcC9GrSVc4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Aki5fi0lSqHIQFPBN?= =?us-ascii?Q?Co83K/32+sTOqQ2RL8gSqY=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1084;6:mlljGbQ4Ol+UAxV/NFay2LAfOjcQwue6GwIrfYXSRmhbICM+bF5dESRjgzawuJP+TkIjfqTp1xV+B6hEg18GAtv1gqM6IqyyWN3y4cBumkCIky+e653kYTVMlepckwlpBoxBU5e5ph4fMl8NRA64Oy3XJt18xnkqpU3FQNAza4TCu54v8Iraljuugo+KRBubVFGADMfw9cVARNjjmxMTfoZgiu3nlLEPrdkxraKgCM5sR4vrfQ+GPSz3h5r6cbB/qyr7n+CglCnaKHTTjYJfmFSwMXjnuJZiFUSYO1pIx8Q5iPNa7scr++I1tvlXQ7Tq3h+cxexDnYb4q2tygPBznA==;5:r9/C3VSpeu1LdWAbIsplMe1cGfUCoIRMrXt/y2+ITb+a9HxZLYzAoTXpTsGkiPTmQuKIJCKi+qlzLnyTurHIVFc7TATzzbFh3+cc8NzYbtR/FATKJhZg2AZ3dCfgYNlqFxCfzb23FykTlFyNQV1Abg==;24:BkZnnlwI6O+kaC/P8Og2thPwNZWgnZfxHDQ2se93nEMNCn9mPeHctHrJ4IvqFF/vqT4LO7lr+gREq+i8DM4+6j/56iwMNev5ZnYO1JWhq9U=;7:7xjChDBxlRLs8gDlI5HNMPWtaV7ysBieaQb0hve9A78UGWbbn2BjC5UZE+qIB3zZ7voZL3rwnA6P/QZtP79HmLJG+xMwxvdIWz9WXuqegggqt0HjpleTIys8Z/TqkxCpRDA6JUpq944rKusj0CB3I/ClDVHv3Y2sUjSjvmcI+WtcUTizwg6Q3xcr2JwYU9ymrIOIwOf9zyzYZv6g6ffj2xouGBsg8WUnGMFUBZszcSs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1084;20:H3makbUm0098m6K5C/g1T49VzfWVDBKb+TKGvB84wIoecHTdmc/knAHuZ65wL6Dqpw6uwRykIrpxkhvz8F1Pxb8L48uSMuQfvurvemaNd/uCL8nIQ1cZcPzu/UAMKafoeIVftY3Xcqk7Hdn0wej4d1dqSR9e4zwxN7x+stL29/M= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2017 12:16:57.7208 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR15MB1084 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-17_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4127 Lines: 122 Hi David! Please, find an updated version of docs patch below. Thanks! Roman -- >From 97805b3dcccb9420d2c4380e88e202164ead0e45 Mon Sep 17 00:00:00 2001 From: Roman Gushchin Date: Fri, 2 Jun 2017 11:29:14 +0100 Subject: [PATCH 4/4] mm, oom, docs: describe the cgroup-aware OOM killer 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..0e93c5b9cbd2 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 @@ -1002,6 +1003,34 @@ 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 exists on non-root + cgroups. The default is "0". + + If set, OOM killer will kill all processes attached to the cgroup + if selected as an OOM victim. + + Be default, the OOM killer respects the /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 exists 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 eligible 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 +1235,39 @@ 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, hierarchically looking for the largest memory +consumer. By default, it will look for the biggest task in the +biggest leaf memory cgroup. + +By default, all memory cgroups have oom_priority 0, and OOM killer +will choice the cgroup with the largest memory consuption 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 +at the priority value first, and compare sizes only of memory +cgroups with equal priority. + +A user can change this behavior by enabling the per-cgroup +oom_kill_all_tasks option. If set, OOM killer will kill all processes +attached to the cgroup if selected as an OOM victim. + +Tasks in the root cgroup are treated as independent memory consumers, +and are compared with other memory consumers (leaf memory 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. + +If there are no cgroups with the enabled memory controller, +the OOM killer is using the "traditional" process-based approach. + IO -- -- 2.13.5