Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751687AbdHOMQ1 (ORCPT ); Tue, 15 Aug 2017 08:16:27 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:51708 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdHOMQY (ORCPT ); Tue, 15 Aug 2017 08:16:24 -0400 Date: Tue, 15 Aug 2017 13:15:58 +0100 From: Roman Gushchin To: David Rientjes CC: , Michal Hocko , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , Tejun Heo , , , , Subject: Re: [v5 2/4] mm, oom: cgroup-aware OOM killer Message-ID: <20170815121558.GA15892@castle.dhcp.TheFacebook.com> References: <20170814183213.12319-1-guro@fb.com> <20170814183213.12319-3-guro@fb.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:8881] X-ClientProxiedBy: AM4PR0101CA0062.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::30) To DM3PR15MB1083.namprd15.prod.outlook.com (2603:10b6:0:12::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7f97752c-439b-4519-beec-08d4e3d76a10 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:DM3PR15MB1083; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1083;3:kEM7lUTw3lFAJlBmqOR3+Oei539begokvW95wmOhGV1cRvkTgnmkIK43+E9WGArAo1PRbWiQKraqUzDB5f7YFJkD43Yz4hAS3L4+1j0hC0pfkaaJqDFGuWLfGm3XCM8J13uvHFGcQNkJuRQYS3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GkcSHN/A80+XrfAxckPwD/2UcO6ccLC1olWkaPoY059lQU4f33sCcwL1/X7ve/Sg38EgePBv4WK7/HeLUgU2MwcB+cTbTVMZnwePus03S0hRu/eSlsHOxoqrJYl+wCLZSGnr2iaHpPdassBx7zwAEBKqVeG5EaUqe5ba4aRTbyZPR+xf7Ub+DBuFtptcKnxB;4:8x0wtpn8QS4lVIiSalFkVmWxXHr9T0VWh/MXLUIhnrsgggSckEdfoOGeE7Ygo6qfhQjlQToVG6gPyCcSTlUjQr5jIqthh09OyFtYUMTTzuHnrPYXZscUI4qPpXeoPwx63L4IOor20uWd3LLiGmZgCc/shuxqRwxoCuUZMdk+4AoEuicMiVTTv1+bBCPUvwhCd6zTCN/FBIdAvuVQfW9sJIwbePorTCKn6oWv1L1SMQWFN6bnFXYnyu3TO9uw/+Wo4LvunH/vOZd4Fw4nA5HWcJH/2A3nXdigNn71ZlIs+c8= X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6041248)(20161123560025)(20161123558100)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM3PR15MB1083;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM3PR15MB1083; X-Forefront-PRVS: 04004D94E2 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(7370300001)(6009001)(54534003)(199003)(24454002)(189002)(33656002)(47776003)(25786009)(7736002)(105586002)(106356001)(7350300001)(6116002)(7416002)(478600001)(305945005)(5660300001)(4326008)(189998001)(23726003)(2906002)(1076002)(101416001)(55016002)(68736007)(6666003)(6916009)(54906002)(81156014)(81166006)(4001350100001)(8676002)(345774005)(76176999)(54356999)(50986999)(9686003)(97736004)(42186005)(2950100002)(50466002)(86362001)(6246003)(6506006)(53936002)(110136004)(83506001)(229853002)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB1083;H:castle.dhcp.TheFacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR15MB1083;23:EZnNhmCpkCifVl7rhmHQAcJxb7+YWxWLHL1QPmv6V?= =?us-ascii?Q?60tfTPFo40wCZgjvbx9+800MEFcqIXH7D0NRjmfei4x9UmxXa53hFSff0Z/t?= =?us-ascii?Q?WSf+EiypaSb/roDZbh0QNj80t3TcAnbzA9k9GMeZPhpUMh9+9iAt2smpPjkN?= =?us-ascii?Q?UboEiP/TcYJ/PId+m3BFD7a0gxN7IUixvGsgrP1b++QQcJ4C7B6ZU5x4B1Zf?= =?us-ascii?Q?Wf4XjwRBh/FmH6yb57ugWPnWoNWcN5G7nVNJUMqcFUA9hA0mVIaxB4yA7+qx?= =?us-ascii?Q?ehLeMjeFxt6zIJ/+aoaiCvvfreL8dSBuPyI2lX+TCxmlsxLG24a9NgGMi5y8?= =?us-ascii?Q?S1hm53SDYkwAhwbjfMr8nmJIbD+MDmmia3qgsgsvR8IHGxzCuLrOk0hN1iWb?= =?us-ascii?Q?N3Ki+zGMurXgep0aGWesumrOMHRQGT0ZxfW6gSwR4Tt/Xu8nOms+c98gUKuP?= =?us-ascii?Q?RyieiKyd3FPGdMzXSwlDDLTa/GoDSY7bCOxK3geCbunLk2oJo2tD1hbVLh57?= =?us-ascii?Q?juFJh/BJ0SPibumDheIHaU/yYaaBNaD2w1bKgT8PpgfDHNqsSdd+Df9HNmjL?= =?us-ascii?Q?XP7F83FoDEKwpvZtUiawl04/NL4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1JNM5D7QRZmH92LBNJc0xZarZG/RhOrmNRlbQnaQPZjFUDOVvVaOv+CYuFf3CmNjhH7eSt7esi1CkcoLTUTpZMANfskkpS6y0qructF/Fw==;5:muarLU71CUZOt/avKSACR8rscPs8BuOg5wGKpuLTbnFAX3ggke+fzpJUNF0jN68qrLZVNTZJq9oJV7P55GaT+vJ/q7pCdry5kqNl/XUpszEqPmSW2xsclJBB9GWh7TMjXBylDHLKSdOQoB9zzTaT9g==;24:VTAP5KuKm9V57Yg+E9PDTxkCOhVvPzy2oVeVhcFDf2kdxbdVSAfak8avW+iMmSJ5fuXfW2zMo3xvZn1LwHisrFU+TDeozmovfiraFqeEhJU=;7:uj/Yp7uiHWmff98XNusVwM3dNOPT+d4zCwOS0+3JsHw+mO7X7/b0jZsK7EXHLQwQ04KpD8bDD7E8RByoPSr6DwSO1phr2ncGd0WIaoYmH/9PfsatO2YAUWukAjYL9tUrR7wShxigaTqpntfY59/8oyLF3WxYoByZoTUQVpijlkxK/PaEUiR8ZZ5JyrwbFqFJa9+J7+1Hq6xrxZWJ35OhH6hv291Yud6pnbJYQBbrgnA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1083;20:7xPUyWE6S3/rqmBrqwiZRO9Amgg0xYIptWSkxr4MxYBtJ38vTNSxk9AfqvHKR3RajgQqr2f8xrxrRuldVex5GlcpN+UksoWAtmWfeeRK+FkgoxItR+Se31N+8YiZP46CwWNiHK4/POg0I3PcCEap6QqI9BTh4rMJpPTSWJqX0b4= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2017 12:16:08.5381 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR15MB1083 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-15_08:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2384 Lines: 64 On Mon, Aug 14, 2017 at 03:42:54PM -0700, David Rientjes wrote: > On Mon, 14 Aug 2017, Roman Gushchin wrote: > > + > > +static long oom_evaluate_memcg(struct mem_cgroup *memcg, > > + const nodemask_t *nodemask) > > +{ > > + struct css_task_iter it; > > + struct task_struct *task; > > + int elegible = 0; > > + > > + css_task_iter_start(&memcg->css, 0, &it); > > + while ((task = css_task_iter_next(&it))) { > > + /* > > + * If there are no tasks, or all tasks have oom_score_adj set > > + * to OOM_SCORE_ADJ_MIN and oom_kill_all_tasks is not set, > > + * don't select this memory cgroup. > > + */ > > + if (!elegible && > > + (memcg->oom_kill_all_tasks || > > + task->signal->oom_score_adj != OOM_SCORE_ADJ_MIN)) > > + elegible = 1; > > I'm curious about the decision made in this conditional and how > oom_kill_memcg_member() ignores task->signal->oom_score_adj. It means > that memory.oom_kill_all_tasks overrides /proc/pid/oom_score_adj if it > should otherwise be disabled. > > It's undocumented in the changelog, but I'm questioning whether it's the > right decision. Doesn't it make sense to kill all tasks that are not oom > disabled, and allow the user to still protect certain processes by their > /proc/pid/oom_score_adj setting? Otherwise, there's no way to do that > protection without a sibling memcg and its own reservation of memory. I'm > thinking about a process that governs jobs inside the memcg and if there > is an oom kill, it wants to do logging and any cleanup necessary before > exiting itself. It seems like a powerful combination if coupled with oom > notification. Good question! I think, that an ability to override any oom_score_adj value and get all tasks killed is more important, than an ability to kill all processes with some exceptions. In your example someone still needs to look after the remaining process, and kill it after some timeout, if it will not quit by itself, right? The special treatment of the -1000 value (without oom_kill_all_tasks) is required only to not to break the existing setups. Generally, oom_score_adj should have a meaning only on a cgroup level, so extending it to the system level doesn't sound as a good idea. > > Also, s/elegible/eligible/ Shame on me :) Will fix, thanks! > > Otherwise, looks good! Great! Thank you for the reviewing and testing. Roman