From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754147AbdJSSxk (ORCPT ); Thu, 19 Oct 2017 14:53:40 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:52552 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753943AbdJSSx1 (ORCPT ); Thu, 19 Oct 2017 14:53:27 -0400 From: Roman Gushchin To: CC: Roman Gushchin , Michal Hocko , Vladimir Davydov , Tetsuo Handa , Andrew Morton , David Rientjes , Tejun Heo , , , , Subject: [RESEND v12 6/6] mm, oom, docs: describe the cgroup-aware OOM killer Date: Thu, 19 Oct 2017 19:52:18 +0100 Message-ID: <20171019185218.12663-7-guro@fb.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171019185218.12663-1-guro@fb.com> References: <20171019185218.12663-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:8cb4] X-ClientProxiedBy: VI1PR0102CA0074.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::15) To DM3PR15MB1081.namprd15.prod.outlook.com (2603:10b6:0:12::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88d0efa3-1829-491e-c347-08d51722a20f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254172)(4534020)(4602075)(4627075)(201703031133081)(201702281549075)(2017052603199)(201703131423095);SRVR:DM3PR15MB1081; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;3:EWmyqX2pH8GMLrceeg9TZoFtaeeGdK1dWDxMHsBWHU4rAXFxQw3EW0q9GY7lyiBpa9TlDwvHIt2AT34pDIqhoGDtW5MpFz0Gwumyd1kCzqwndW7b+fAxUNILaEaISAdpCXHCpWFNbd0sQYXDt9w4UVFWRTSA/ySAf1BmmbG6UNpwb6GiCcuFWXHs61fUkxivg/5Oh9j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grh4qy96D8rMfALXoMca2aARYi/It5vJsy3AiLgulwbpuRiBu++4LtopKo8qMxatXZzmcuus/kCridiSbRRWXelVy8BYE62s3Ec5TnrPKcOCGKUoREQgSNuZtkDspxzvsg8NL9XNHrJN+F0DZaKI 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)(11241501159)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(920507026)(6041248)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(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:9ng8ZTOd/AZp0DHotv05zMx0eFXF3euTv+euWSWOIXUfBodMZkEbeabi5Rp8nlDEVG8qkL0i417mUVxeP/3XaODf22NnqjlTwzftek14bXZJgoM+iMhi/XuUD54gwvgx9tHNfjIKlucam80DvHd6TaUuzoXkMmk0evhEGzdDdV7ox9kxYjXy6nRapxy7uwhMgdrP1Xbyf8XfobUYpaXQdjypfsxU1krwcG1VNUkvA6pgfTtJNTo0w+GsTwuR0LDeOGt7ZeXloM5/Ez7KlG4iWEy/YG55OD+isB6mrYYfmoHBc8ORZlrG42QKlpSov8e6/a7b7RuYL+vWjnwzNC2gnCVVVfGTwMu5v2ddgfY1oVuXw41Obrzi32mH6U393vYGERWvX2RSzlBp/ePjQN3mk9afPohcm3Snn+WiF0x/RMBpGy4YAV4pf3L5DcVoiLrH X-Forefront-PRVS: 0465429B7F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(346002)(376002)(189002)(199003)(53936002)(54906003)(48376002)(101416001)(6506006)(6486002)(316002)(4326008)(69596002)(50466002)(5003940100001)(2906002)(25786009)(6916009)(6512007)(6666003)(39060400002)(5890100001)(97736004)(2950100002)(189998001)(86362001)(50226002)(6116002)(305945005)(7416002)(81156014)(53416004)(478600001)(34040400001)(50986999)(16586007)(7736002)(68736007)(33646002)(36756003)(47776003)(5660300001)(105586002)(76176999)(2351001)(1076002)(106356001)(81166006)(8676002)(2361001)(8936002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB1081;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR15MB1081;23:QrlHXuw0w8+aZOTY8zZNjiMGFLeklezPULxszYqHi?= =?us-ascii?Q?cCa/mXByL9TCmJeYcKBcaR+uIx00YZIHZTMOpfByTWkrIWSEsFP+TUPhNOjD?= =?us-ascii?Q?L639rssrp+hOewyUMAWfnGKqPFMbC9it/juRKDIRkHZ/rIeauj4otvfOjAjt?= =?us-ascii?Q?UQ1ZMmw6uu1aP2ErYOFko1xbrJWIaRrTNALCEEEU+gyxX4XLJkwoy91Qu+wD?= =?us-ascii?Q?sOdQEVdyS9Cg0uKWEvypgbOb39wjEihZD0DuK2XBBiCHTGcRJreqKp4SfHRJ?= =?us-ascii?Q?UNjvvdoOcq8suQ9xJx6o/L0XOiynO1yF45eBZrSJniw2j4r5Y8UHeM4dSu2E?= =?us-ascii?Q?QiqsGbS/owCDv3soSOAG+X/7YU0t379ivLY+LPkzt9ftZNzi1vCvelLSq7qT?= =?us-ascii?Q?405HTJnK5+qodx7Ssww99vjmTgsDxWLlsATg/9vebIGgL5wK4y6Zkv5tHeCW?= =?us-ascii?Q?hCfcAvX41BjRuzuVsDgV9AN+LbCsJFxevHOt67NXAhmx/3uAdetLpVyRZLVz?= =?us-ascii?Q?PIcb4eDVyN6BgX12sklRhYSe26aAgUXM4hqo8owVf9SizSmy36Fn4otPDExm?= =?us-ascii?Q?S2+Yq5FahrNUf32PjCQSSxDkSPeb4yBm6++8NOzYA9YnOLHV/CgyoqDKyi4J?= =?us-ascii?Q?RizvnVL0YxS0BsmabkwwS+Hm7La3XDi28DPGFiutsBcgOFMwqDnFDB2CxhD7?= =?us-ascii?Q?5MO+xOQlkoWSqPUP3xA0Z5VptNFNAEeRMPZA+ezXi7pxKZUJIHeBVXkB2HVX?= =?us-ascii?Q?xxJ7561Ss56R0Jm+Htsl/XWdNtrSwuy1oYhwrpYbvLmwFXOy/uaNlg1LwmW1?= =?us-ascii?Q?brX0u3Hse8nQqcakxgy98LfSO/PJ6I1asF984HF4GnvrY4FwtHYELs6G2vKv?= =?us-ascii?Q?Frh2oweF59hDcOWwPYKIDiIUWrYFlDnzRDz3VC4O6tqRMt7N0QE+/S8j2Aoj?= =?us-ascii?Q?CLYtLaEe0USjDPW66U8PlVwF9o6I9JDyecauS6BVIISzVZnStd+EQE5FBJEK?= =?us-ascii?Q?QegDzPxN+PM2/DIoIBLDwcar8B2v0j2WdNzymJF5djOCEJ3ihbSecAb9e/lJ?= =?us-ascii?Q?LC6st7RQ19cz3MXQavLFiO51wCBaQi7LTJkfoIBcQUtipUWsVy2PR/iiKWy1?= =?us-ascii?Q?fnImlhfKUVBqlKnguScjOsj23Fx2vVCgFLI3M9KQyf8HshofzGe7GBVSQJVq?= =?us-ascii?Q?xZdk7zTuUD3UlvatfWl89kxwLMGzphgdP4ZFn7eZWXXGAST1mdLrn3K1vQK7?= =?us-ascii?Q?DhEt21nfQpCNargnVw=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;6:280j9LkpDYta++WkzV8yNhY5RpbR+inq29aZFXh2WtRRnt3PEqCX8WVv4qHRL0EHlqXOxKwmHJjE3PUXQKAVf06Yfc7N1YB5esHUhTXDtYtuJwhbVf8Rz5uaoVEZPIyS64AO4BKsguHsxCiqrRiiHE9au0JhXta5L/CCX/Gvv12ppty8Mrwj2OSmd7C4uVQMX2Cot8YP8+ks5/B8gEQQFxY2b0QhFrJNOaS5gMi98cEsJevhIJTd//tvkhRbXBhDGSVBzbGpVnzU5yHi9jbSBweCttfc80zThVPBazOoq/Ewt4Pol3i8BWaE6Zu5C0LIU7cvi1R2rpSIzu4u3wTwxg==;5:1Vga9WaHCrc/EwcsR8qorPm9fG3lcxJCN4PRWeuFTAbEx2xy5bTLKa/76vkuvs9NsUzyGXNMoFqKyyPRg7mxnaK5lRKYmOK1qKoEbO6FeFdsNjQb+wNJjZ6kO+QUGoVlFN1jSxnuKL10fix2Evz2GA==;24:oJTZrQpWZrorKDEyt/Ic4PvVk2H3bGooE4HmmIwptHNJXWldjAJY7rHvMhY15qFM8OBeP181e61VrvVtH4JjeoA2Ar2e8unsVb44OspP8so=;7:OaKhnLz6wcZc7UYGsIhtT6w1G7BKkPrVeAAdRBDSyE5uHcrTfRm/Nt3Xl+XVWiDEpUvMIf5hBNWXYXzSOf94+l5j+ZyTzqYmAwtOmy5O+n+QrL92gVhpEIfqdGYMAhtQrMxxnC9KRBKAhJMpbVHEvPKxwBLB0ZfqV1EvFO8DuJa9n4apyxVrlX4a0SZyQaCZlggmSAGoGjZ8a+LURWEELw9eDh8RdT8l/lzIayR1zuc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;20:ms5oxcYZHi/lJlimQFa30LJgaaWZe+l3V+V9VJYc9792UoGU0En3aDuo/KlD8BW/tTv5b0TosfCldpCiwFd5qI9YLqMWvf70jwRpzmuMUw2jIA9broLu3S5E9pyc/gXpFvrHhDlrPD8e6Cm5OMi99NZ2oXnu1BxeEkcU3uM5/Bk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2017 18:53:03.5249 (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-19_09:,, 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 Acked-by: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov 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 0bbdc720dd7c..69db5bf9c580 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 @@ -1031,6 +1032,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 @@ -1234,6 +1257,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