Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752523AbdHPPn6 (ORCPT ); Wed, 16 Aug 2017 11:43:58 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:52012 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751643AbdHPPnx (ORCPT ); Wed, 16 Aug 2017 11:43:53 -0400 Date: Wed, 16 Aug 2017 16:43:25 +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: <20170816154325.GB29131@castle.DHCP.thefacebook.com> References: <20170814183213.12319-1-guro@fb.com> <20170814183213.12319-3-guro@fb.com> <20170815121558.GA15892@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:b605] X-ClientProxiedBy: VI1PR0801CA0087.eurprd08.prod.outlook.com (2603:10a6:800:7d::31) To SN2PR15MB1085.namprd15.prod.outlook.com (2603:10b6:804:22::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b119dd3-fc70-4a9f-5f4f-08d4e4bd9035 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:SN2PR15MB1085; X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1085;3:cD1xd8QTUDAUgl3EaypLORabzO0mmK5vfKNbOkxBjkCZg7qTSASWvSgJFXSfmEAOUwg+iBxHbgUBUVsmgVQ1GYGDDy7+v1c2lStosb4/XwpJ+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f65urUV2VKrQjUjO2jUT/bDKEflVABUbXIuAaAxrgTJo/nZoQGsUZe9EdnOolUzH09ZrZwe6O8E+mtw38xAChIOy3xg/I4qPupkHX3LDc8FN2i2wXxki4MyppvziPfBKfmIERx1yarCztDvFUHLwA6ReKWYWt7Sg76yzt2Iy+Yc4OfAH1UWS7I7v8WlinF/KFcdIbhpKz546XO61k9KojFq4UORsd3WM29lZjgALfyBpmlj3uuYy;4:OqmjTGaPNJi0crRGv7sg2wqPvhAWrQI7UqK7EjmBkBDagMOLxthH8P5KV2+JB75SkdHxy63l2jH+Np2YAedjs52vTZFreJ0FCnEA8nsLgukd5NxNbi3bMc8lzBQU5kXW4+1TRadrarpzaPO0QWZhmVqgsj/WMILrb24XaLeRC/FtOOHVUWtFld3h35TaAhlUxjLYDl75yf7l/WEJDARLW9BfCOpwJwqdBO2VVCKTglMLyvw4l+/pWRaMdps/4TU+4cNBumWxtJtBVMQ1Seu5d1kP/b7k7PGSkCH4J1vrAHk= 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)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6041248)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN2PR15MB1085;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN2PR15MB1085; X-Forefront-PRVS: 0401647B7F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(199003)(54534003)(24454002)(189002)(5890100001)(33656002)(6246003)(7350300001)(110136004)(83506001)(81166006)(81156014)(8676002)(50466002)(5660300001)(478600001)(53936002)(7416002)(93886004)(86362001)(25786009)(97736004)(68736007)(4001350100001)(50986999)(76176999)(54356999)(9686003)(7736002)(305945005)(47776003)(23726003)(54906002)(101416001)(105586002)(55016002)(4326008)(106356001)(1076002)(42186005)(6116002)(189998001)(229853002)(6506006)(2906002)(6666003)(6916009)(2950100002)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN2PR15MB1085;H:castle.DHCP.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR15MB1085;23:ATXyzcYxRDeqpdArnJkjVcx9mZFdGoKWf5/BGGQRn?= =?us-ascii?Q?BQU2VkpReSGEzMgYrktuoULtWBA5jAe+VFdhUQD7N2gKwPl+KmCsEigm/pHW?= =?us-ascii?Q?YXPhzq3JcBU7TGq8KL27xSve8VjRPQGb2DGGy2YKXKMJnBp3r92mtIB6ZrhX?= =?us-ascii?Q?RGbkKSvUi1RefJpJssfap+AX0zjYysH6OkPAoPSQWukSdaPx35S3ku0odo8l?= =?us-ascii?Q?2IBojOCSFy9uQtHeMYzxtIv2Sk1MNjEJxCj3AN6xzZzy+Xg6L2JIFp5ZSPb+?= =?us-ascii?Q?rMBudgymk3ogOXd207K/TW6hwVzMIzkQgtj9qCTL4yVLTUsARRYATpV6DlsK?= =?us-ascii?Q?6B18eFO75+YMO9aCXQsMtMzEMm+7BQsN1MfObEeoK1CgKllW+jMF/T78uxPl?= =?us-ascii?Q?gFCK+U7N2JXDksTrlx1D5q10nL4yU2il2Zsx3VNUmSN5srqn+PqZl+OcR7h2?= =?us-ascii?Q?yxNcUirF6F41Y8kz1tuj5Biadz7Wa24klcuI3W7OrBAxxmzJRWvxFAAHu0N1?= =?us-ascii?Q?S7OvKPkGYHkR4wCfQlRT/jQadx6fjjOsmLIO4UjoLONtKn4eK74soXpw7J9A?= =?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/N+gyXubPEuyHFF6iatLId4oS1VWKlu30D/0jUu600kW2xa6DsOps/t9rLQvMtN6hWsNi4CU8U5zliGscV7R4GAA93DJZtQ8HLTdGi8V0vDzVRiARqWdSTfsVhdlVKgYB1Cg0VxqqEUYYvoCXedYO1rC9IX2B+r0+lL2nvJkZcnVQ6zzhUvQ+1pUcnrw/5WcNagdZ1QEfA==;5:MpssBFHnnAYxsPzSSOtH74gQSsZ1oxNkIBoMvzb9Fp1ynwDzQg4OiZHfe3N9Gc6eOPP0LAbgMvZRUPFuE57wgeFRs1wcOy3hY+50NTuEl6F6Lud/aCDuCEuDGTHQntBa5PvWQ7FXmzu2vs6JxFJ13w==;24:GJ2WrfqwBjIjUsra95vaPReMpuJ3cRhgdUOSZrWW13zDfnSz0v0I7pEto45rq8LWUxvMf5g6NA5yvTz6fYD+11WW3+eVZUbCvaIPOdXAmSQ=;7:6HAXxa/8EEqfv8KC2nds5E23cbl7naxJJw+Igk/Y8lFtF2F7UTkrcvxOp9XHulcVYBgFJr+S1wdZYPCdM7gTFfPG9NXDqO10jkFfdDhe3noBugK35AThvaPjNLhdvQ7eiQntUHBYn/THW4qrLvUqzDN/hOsLKlh/1Vd0yrVoxTLWJsxQ8zH/thxlzHjN/bNZdw6H+T+nIMpjSHt6r0aUaZmpENKJ++0pUPphCzX9IGg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN2PR15MB1085;20:qKv5PWklzLvjuBBgtrtvc00MeUivc54h/U5TawD340raGFDT4SHJu2nX7mSHMBc8L7kNSHnjZkKHojsmKq3vtSI87Kfq+hMejG1TYrZeTd6QMkFjgnc9EomU+tGqsPBcO+PXeTonpKUpKxAkrtDzofhQtWed7jF9zf1xFyA7Kow= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2017 15:43:36.4044 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR15MB1085 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-16_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4591 Lines: 100 On Tue, Aug 15, 2017 at 02:47:10PM -0700, David Rientjes wrote: > On Tue, 15 Aug 2017, Roman Gushchin wrote: > > > > 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. > > > > I'm disagreeing because getting all tasks killed is not necessarily > something that only the kernel can do. If all processes are oom disabled, > that's a configuration issue done by sysadmin and the kernel should decide > to kill the next largest memory cgroup or lower priority memory cgroup. > It's not killing things like sshd that intentionally oom disable > themselves. > > You could argue that having an oom disabled process attached to these > memcgs in the first place is also a configuration issue, but the problem > is that in cgroup v2 with a restriction on processes only being attached > at the leaf cgroups that there is no competition for memory in this case. > I must assign memory resources to that sshd, or "Activity Manager" > described by the cgroup v1 documentation, just to prevent it from being > killed. > > I think the latter of what you describe, killing all processes with some > exceptions, is actually quite powerful. I can guarantee that processes > that set themselves to oom disabled are really oom disabled and I don't > need to work around that in the cgroup hierarchy only because of this > caveat. I can also oom disable my Activity Manger that wants to wait on > oom notification and collect the oom kill logs, raise notifications, and > perhaps restart the process that it manage. > > > 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? > > > > No, it can restart the process that was oom killed; or it can be sshd and > I can still ssh into my machine. > > > The special treatment of the -1000 value (without oom_kill_all_tasks) > > is required only to not to break the existing setups. > > > > I think as a general principle that allowing an oom disabled process to be > oom killed is incorrect and if you really do want these to be killed, then > (1) either your oom_score_adj is already wrong or (2) you can wait on oom > notification and exit. It's natural to expect that inside a container there are their own sshd, "activity manager" or some other stuff, which can play with oom_score_adj. If it can override the upper cgroup-level settings, the whole delegation model is broken. You can think about the oom_kill_all_tasks like the panic_on_oom, but on a cgroup level. It should _guarantee_, that in case of oom the whole cgroup will be destroyed completely, and will not remain in a non-consistent state. The model you're describing is based on a trust given to these oom-unkillable processes on system level. But we can't really trust some unknown processes inside a cgroup that they will be able to do some useful work and finish in a reasonable time; especially in case of a global memory shortage. That means someone needs to look at cgroup after each OOM and check if there are remaining tasks. If so, the whole functionality is useless. If some complex post-oom handling is required, it should be performed from another cgroup (protected by the lower oom_priority value). So, for example: root | A / \ B C B: oom_priority=10, oom_kill_all_tasks=1, contains workload C: oom_priority=0, oom_kill_all_tasks=0, contains control stuff If B is killed by OOM, an "activity manager" in C can be notified and perform some actions. Thanks! Roman