Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753795AbdIDOWR (ORCPT ); Mon, 4 Sep 2017 10:22:17 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:52533 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753749AbdIDOWK (ORCPT ); Mon, 4 Sep 2017 10:22:10 -0400 From: Roman Gushchin To: CC: Roman Gushchin , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , David Rientjes , Andrew Morton , Tejun Heo , , , , Subject: [v7 5/5] mm, oom: cgroup v2 mount option to disable cgroup-aware OOM killer Date: Mon, 4 Sep 2017 15:21:08 +0100 Message-ID: <20170904142108.7165-6-guro@fb.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170904142108.7165-1-guro@fb.com> References: <20170904142108.7165-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:6ba5] X-ClientProxiedBy: HE1PR05CA0180.eurprd05.prod.outlook.com (2603:10a6:3:f8::28) To DM3PR15MB1084.namprd15.prod.outlook.com (2603:10b6:0:12::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb3b387a-5b67-4637-5c57-08d4f3a04961 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM3PR15MB1084; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1084;3:cd8IY7VNI16JYevKnp7wh7BcCOCKFamTRQAMStodqL9fQZbcZXTMym1WIWMSOziijWUXzS51q+xt1S5QtyiSUMNhtI0Tt5/m0xD5AMiirN63mSyYHOfhsUrOj1F0Kq0JamRm340JWPAml6U3xCFozBM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MEpcqEWnKtlSQtAnkEKCL+Iun7uMiormhM54pR6f3uvFS/I4UaIbJbDYBFKaOMYxrccJDD7sNS2/8vI0q13A3JLEPICp+bLMKChVITiw6HkU1uLUHtAZHtEl0lfM6+WPHwAK6mu/UkPRBTCk07mKf2glw+ar5ONY5ew6XvtugbPCtl2anr/LkRTAb0KAJCu9Etps57yyuB;4:WyeEKSOJvX1NWYT3E2djQ1ITNKQNijIPPAAp0nPIr1VYdnCu1BWIbB6zUqs5jfGeabaqvzysNReTUG5dCQHbjUn2WI+diad5Bsc3FYACaFGwI+Gds/s6nDTLcmoweqPTOP5SsIsLbGeOEXu8/c/2oshmfuBYMGKohW+UJ44hsb2hXG6yO4sNGvpImZZAD4KAYEtXI3B0wiwnXzxWEi7DZUPX3EzTUbr0Cf8MEHsmV8/6pJVbc70x1knW22YNiMNoowGIcjwfmi4qdiupPFGy5yZU4JWSmPPlErTLKf3/kgQzOcNpnFtiy7pf+bQaAS4XUNYc0TEWcWfSf6zW7xS7+JK2iX0/dYpBkKKwLG2dwrYXhhW8i4aF5QkCDOOATqBdJGmBsfan9PIOfifef4Ycow== X-Exchange-Antispam-Report-Test: UriScan:(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)(100000703101)(100105400095)(3002001)(93006095)(93001095)(10201501046)(920507026)(6041248)(20161123564025)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(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-Forefront-PRVS: 0420213CCD X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(86362001)(6666003)(53936002)(1076002)(48376002)(33646002)(50466002)(189998001)(7416002)(69596002)(97736004)(305945005)(6506006)(7736002)(6486002)(5660300001)(575784001)(6916009)(2950100002)(34040400001)(101416001)(105586002)(6512007)(25786009)(5003940100001)(4326008)(76176999)(50986999)(81156014)(54906002)(36756003)(53416004)(8936002)(2361001)(81166006)(106356001)(2351001)(42186005)(8676002)(110136004)(47776003)(2906002)(39060400002)(50226002)(478600001)(68736007)(6116002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB1084;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR15MB1084;23:UcgKp3Zu+l8+1ae1JFy7z8rYmmNRZiR+R9g++4vf2?= =?us-ascii?Q?P4A0hb6MWMskMcnkIJkHS7QxgerXC/bxSpUjb7PnOSn9yZ7NLWOknKdd27Ks?= =?us-ascii?Q?RLhvFkp2Xt7Dm9TM6IVcLhaV5RqcaajipbMRwIGxnh5SaxV8KkpvL8wcUZQ1?= =?us-ascii?Q?Ls5FjnKBCoTf1sxl158XV3fDQaNMFq/yOI5jYTGNmWmHI7VoAUen4xKXA2ci?= =?us-ascii?Q?fs0+AhLhlxU1ZxPjul8JtTnBAzUifWNLASj9R4ykBSjr5Bxobcc0JGTSoIfD?= =?us-ascii?Q?wqniwSBIKP6mZNpBDlMF2hmvHmOJdn3aLrCNZaJrufuT3Dx7cjuq/G48WsJQ?= =?us-ascii?Q?7RHcwcze5mrnE+o7v/RJXRF9YDbptmkxvvwFTxcdpIvHgZ6cB0X+cCYOjpPJ?= =?us-ascii?Q?efg0Rh8rA+B3PozLEa0auavO4LhX53L4dcAkT2nydgNsum4K1oZOyQDQXCjI?= =?us-ascii?Q?p9j+9l2vEAVtdQ43wB2asDK3QMNHgoigookuaWxyOxplcdS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Xfu8Rqx5GRpNmxcl8Qgl5/QeTIYmWonQRB/q4rdeNrc8iLyhWYEQ9u0N86vMZfhcCDJc3V1mk1G8V6XmknhCZmRuX3vClZaO+1Dl2eJZLJ8lBzA/rMdTbKxr6uyU4R1R//KGdKzBpQJQzcOZEXhhyuvQVr6doXBV2zYCfhs1ZeILY2AzhwJ//LpW/JPuTDO1Szob50I5i94C7hzUelVyg1B16NlYV1k/MymtNO4YEPdhw==;5:bDevRhETuhEl9U1hr5cC0iyLQ0Xo82TGrGUbzc3fNJxlXx02rDwhQRJ5Zu+frQDAkoh5FTNoyLHdLftFYch+ss+Y7uwO30wHOEcUQKSWLH6oHHgjDkE00EQempWRSsqBVIMEXfz+irkvGziH7ov66Q==;24:paVEL12j6c4mI2pL8nRwu1BTIvuDa54GxtfZZl6P3JDu+BmU4fsBZqKjGvjZKmdtG3wK4mYST9cplwUaHT54SI5L5++BMaVjYXHVb9F+riE=;7:d/zwbSsu+joFKaZCYywrOecIMmYmQyIwzkFhJ6cY06lJ8GCq0N97Vd33kiVLf8uc/EzcATTlwFC8EfrRan0kUHdKsxKR1vSr7UZ7tT2Wn4zsw+UerFzbRf0QjXBvApxOhiwyI+PG+W/lQiUCRsozByGo4ISctkC6322CJett5istJGsrKBWuW7gDt20rur1Z9PeHZWMtryWabWFyKdbKum/x0+jLtwCOttzT7zP7tPo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1084;20:xDQOc+7vhF7M0mUOJpcELySGMXSsJgRf6rkpJAjyv1m6/KWBZgbFYPRDLOkm0Bczw886g+KyQkdYf8LDmTrdz5bye2ATqcsYMO2pWiUKS0BDCGyN6cJX49yOAxy0oaNeG9yRF/01n1mlv/NLc8ZCfjx640q3yw2nxyQfF7UOoOg= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 14:21:48.8609 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 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-09-04_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2652 Lines: 78 Introducing of cgroup-aware OOM killer changes the victim selection algorithm used by default: instead of picking the largest process, it will pick the largest memcg and then the largest process inside. This affects only cgroup v2 users. To provide a way to use cgroups v2 if the old OOM victim selection algorithm is preferred for some reason, the nogroupoom mount option is added. If set, the OOM selection is performed in a "traditional" per-process way. Both oom_priority and oom_group memcg knobs are ignored. Signed-off-by: Roman Gushchin Cc: Michal Hocko Cc: Vladimir Davydov Cc: Johannes Weiner Cc: Tetsuo Handa Cc: David Rientjes Cc: Andrew Morton 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/admin-guide/kernel-parameters.txt | 1 + mm/memcontrol.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 28f1a0f84456..07891f1030aa 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -489,6 +489,7 @@ Format: nosocket -- Disable socket memory accounting. nokmem -- Disable kernel memory accounting. + nogroupoom -- Disable cgroup-aware OOM killer. checkreqprot [SELINUX] Set initial checkreqprot flag value. Format: { "0" | "1" } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d7dd293897ca..6a8235dc41f6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -87,6 +87,9 @@ static bool cgroup_memory_nosocket; /* Kernel memory accounting disabled? */ static bool cgroup_memory_nokmem; +/* Cgroup-aware OOM disabled? */ +static bool cgroup_memory_nogroupoom; + /* Whether the swap controller is active */ #ifdef CONFIG_MEMCG_SWAP int do_swap_account __read_mostly; @@ -2822,6 +2825,9 @@ bool mem_cgroup_select_oom_victim(struct oom_control *oc) if (mem_cgroup_disabled()) return false; + if (cgroup_memory_nogroupoom) + return false; + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) return false; @@ -6188,6 +6194,8 @@ static int __init cgroup_memory(char *s) cgroup_memory_nosocket = true; if (!strcmp(token, "nokmem")) cgroup_memory_nokmem = true; + if (!strcmp(token, "nogroupoom")) + cgroup_memory_nogroupoom = true; } return 0; } -- 2.13.5