Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932215AbdIFNmS (ORCPT ); Wed, 6 Sep 2017 09:42:18 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:52188 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754470AbdIFNmN (ORCPT ); Wed, 6 Sep 2017 09:42:13 -0400 Date: Wed, 6 Sep 2017 14:41:42 +0100 From: Roman Gushchin To: Michal Hocko CC: , Vladimir Davydov , Johannes Weiner , Tetsuo Handa , David Rientjes , Andrew Morton , Tejun Heo , , , , Subject: Re: [v7 2/5] mm, oom: cgroup-aware OOM killer Message-ID: <20170906134142.GA15796@castle.DHCP.thefacebook.com> References: <20170904142108.7165-1-guro@fb.com> <20170904142108.7165-3-guro@fb.com> <20170905145700.fd7jjd37xf4tb55h@dhcp22.suse.cz> <20170905202357.GA10535@castle.DHCP.thefacebook.com> <20170906083158.gvqx6pekrsy2ya47@dhcp22.suse.cz> <20170906125750.GB12904@castle> <20170906132249.c2llo5zyrzgviqzc@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170906132249.c2llo5zyrzgviqzc@dhcp22.suse.cz> User-Agent: Mutt/1.8.3 (2017-05-23) X-Originating-IP: [2620:10d:c092:200::1:66d4] X-ClientProxiedBy: AM5PR0502CA0019.eurprd05.prod.outlook.com (2603:10a6:203:91::29) To CO1PR15MB1078.namprd15.prod.outlook.com (2a01:111:e400:7b66::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 008310d7-e993-47e4-7454-08d4f52d0aca 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:CO1PR15MB1078; X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;3:KXEnS/Gf2CFEkXLWg9ciTweNouAqq5ZyOpjYZEQvyMFiYzeSLjzsNgxKM5sH/wlGPAVY5YMKr4LL4PJ6wF07mxYGIw4bVHVBmBLqc2aXs9MlHPZ85TcA7b7Su1JJQ3yy6wqQTY6BwVBunQA5CLMJPma49q8UYaKhch5miHrn4l+LINkqMWJtQlqwkyF5M7pShhl2cjkZsyaZGtv5Wcci8bS23xszCUNoRfYhIuzIziRYBcIvAV+8gwQ3G/dUY2xc;25:JTOYrwJbh8mkUNK5tBjVmXjOnnkPt+Hv2evy8t2v4K/FkUAnJlpypL3nNTNCwTHJvf/dBrYMbleS4ndPSWvyrMkgD/zlYQpbfqmmjWonvVvbrg9rarQEcMTNN0fmzsgBTIW48nFVIBg5pKq/7BoQ5KwVMMAlvoDDQ/90G+cl7WEZv1+hzggoGCRIT2PTpRaaBvFQcFagcncjYDK2Ytyn1CJgod/y2H/zQMunxiX61GLerIdcq5ACpEsZNfbKNHp6e60kcczdMvPT1tlSLwkV8/gj8cN37OvRphhmhlznjy1xuQHX3yonHyi0b6lhoF+qSoymvRvm60Rgu6m6x29SPw==;31:litRMVahGbEaO1a9uzUcau6v2Y0nR+061sNWWqBfIM+jWLGhDhAJKFWY/Wsr5AJQzirhCIcZSwLbrJDUpsFWShbQVk64eGjqbJL9F7nqn5s73VK2+f6zhOjGL292NbBULaTt89F5eVvpOZNxBnQrriaFT3UKIzEwMwpIgmiXbZ9FCIANhE2eCrQxJFcceoI++F3QNMIy+oexwDdnG6Cwvuy9n2MgAfn05CNG79iwXAg= X-MS-TrafficTypeDiagnostic: CO1PR15MB1078: X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;20:PNY/3hZxHOFDn074myDptrxjwOncC802+D6I0b+TKr0oIaVfdQGy2iSKSxzyKrEb9OXFSjZq+XJZ56V+yr9nWTfJwOplRy+ZPJvoL2yZkMXnWr1rYiSB9mkvOF56Kk3B37fPU5YVNCn/9KSWAMvu1wRGTGqTuVX7ae1TNveO+HHSRM8WpUqyrMQ+p4dNToEcxKGZMu6SWhe9DfrPj8zazZU47EDj/mQ0+mmMWLlaiYxZFGZwazTqz1yIdpa4npceGvunVN9sUZTMFhKn05Clrfu0QKriNX917S1mNNVBWcfWgJWLJE9Lo4EqeTUCCKcqtGGqhtvRxX18NCdPdHYMfaIdy09QjzkjkWPu+rT4Wkzp/SL6TGRx4XLOj85Z3pokRe+uXVAFLmagh2ofgvOn1o5i0+JYxgYT+4GaYORbPinVZAVvTR/sGDSdfeEz+hksxxLZNJN0pJtnKwzGa+2VOWgDpCcQkgH20WMfsGy24ry18879UCPHreGwWh4TDhQl;4:cxgWzAZoio3vvAXxkqcmLDTJx/9KVOYq7x6NzfneB9d3Vt6Xwpu2KarKa3pKv1EJ94tTYRU6umWXJXOB7J8tm08UBEre30rmAqi+5fcosTOsUTac0Bl70tONmW/H6qEtNqhyfuLhYOcJ8VfWt4FFL6WoVvsLYUbIXpavj5MhdCoxrHziMB/7BqnU4uPdMDzP+hp9uuRHpFRTqTW2LZ541OlYCLsxqONYiT5+ifPCR95bhyYP1hgjIeKESxa9ETr2 X-Exchange-Antispam-Report-Test: UriScan:; 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)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CO1PR15MB1078;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CO1PR15MB1078; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(52314003)(377424004)(54534003)(199003)(24454002)(189002)(54906002)(93886005)(110136004)(42186005)(50466002)(39060400002)(105586002)(53936002)(4326008)(55016002)(9686003)(1076002)(86362001)(106356001)(305945005)(6116002)(189998001)(68736007)(23726003)(97736004)(4001350100001)(6246003)(6916009)(2950100002)(229853002)(7736002)(101416001)(50986999)(76176999)(54356999)(8936002)(25786009)(33656002)(5660300001)(6666003)(6506006)(47776003)(83506001)(8676002)(7416002)(81156014)(81166006)(2906002)(478600001)(18370500001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CO1PR15MB1078;H:castle.DHCP.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO1PR15MB1078;23:1xPB4MCW76Y+DpoGbSvO4wic6KWWLplVg5kboeXeK?= =?us-ascii?Q?dL+HBIRB6aNvygq6DJgo7iuImk/RgtuzNHCop4wuT4ShBpwAuwWknBkQSx93?= =?us-ascii?Q?vf0Xz5ssoLEKdKR8T9bfWmFbIAupXH6T8oO/WoiQ6zJcC4lyQFIYO8fRwsMf?= =?us-ascii?Q?iyB6jQrtlwRLjbINGIWIwVKcNq1QybpfaNzUrTaXKnwVUROTkF+EWUUEEVtT?= =?us-ascii?Q?taU5eXirFtQ0tp9P4BVFUCMUYKQHkfjIMI4VS1i3oZdlqQyEzARaHIUc2D8Y?= =?us-ascii?Q?GrO2+f16QlvNbdYs91MB1zco4pMk3C8EfbHmrzKXEWJJAX7un+ssG4wJMrZZ?= =?us-ascii?Q?z3QiXCNjbygIeFy7mfzn15BqQ6fUtUOLrZwJxlCtMMqboyfMSv9oON8wD37B?= =?us-ascii?Q?nLt3ShM/afiBDU4a2zowd11htQaQpFA1VTXH61TD5Six8Ku6x6pteRZo689U?= =?us-ascii?Q?PBWBEsH/Zi5iWp7CHsX1o3ce3PT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xgE+HQ76BxQeEhKOZkDhboMTXfPuiDKTw+8q8UugjiAz1jDmiLB9DLsn5Jnvxs9JVDuFlyi8ffCP40q9Rb005lZofiesEQyuVXJhjDrepEaH8D0ZY5ksv4RSxjybz/tRHutbIIlyOSbClzcdbf0922mVSP26KqsWi2ry/jB/3bxe/E4NMkmDhBOJsr2zqIhbtas9C8IYw6K6KV+J6eCaifWNBh1Unytd6rmQcU4Q4auu61hEfZS8OtrspDRYI7jYHc09bzPUuFCYnWOW3XLtE6KxwsDegwD6FmnALRA==;5:8zTGCqANR/GUXdepUk8tcr2DSx2YzYHz8Aw996Q1RCFz/9dZtm3z8YADQVibPxlCXGvN+t7oZyT72VzQUTNTU6OtCvWvmKwXJe6qsk6D5wQB56Gz0xY7zVJoxlYV9KMBnre1J25RUTwOlIHOedVMSg==;24:ggnjChuPv+TloIM86YlJTDKImVxybZbsAqmRrY9cp1OtgqHw7Lk3lFvaymcL4BUHs0wuKA3ea7IOPNbwe4voSCvawDJcRrqIEYxucyD22DE=;7:7QIXyuDpVc/stWc2Pq/c6fiSvV1GGKAiwR2/ibex6iMzEE3o+CvRjv/AfineTcxV+oRiUifkVebWW82RBC8ptMC+DKls+eXUnpS+8g5c+Algbff+X0cKHXiaHx3wFC9JSPQ0ic2rZreB8onxw1TI4UsK73Ow0JCJeZLXGSC5FnFbaV04j4rgPyilk9H2FbPjOn9wgprtXxh3B0WdNy5saUU1G8/i9UwVqNDl0U4vlYQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;20:q0O8LHsDSFbC8ZaU6x1QPcKB5TY+TB7J2rtJKa0LEf8A8BrDNJulbxgT8MrOYH4UDK2CHVMKUyM4jcBCkB+XsZcWSdw7rTMIuP5/WEi7ydcmJqNq+TGwv5y94ssGoXJsbkfIe4SGYPAcFk3yQJZMEjdun2PxFxqjv0krh5sDn2s= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 13:41:54.5549 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR15MB1078 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-06_05:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4898 Lines: 105 On Wed, Sep 06, 2017 at 03:22:49PM +0200, Michal Hocko wrote: > On Wed 06-09-17 13:57:50, Roman Gushchin wrote: > > On Wed, Sep 06, 2017 at 10:31:58AM +0200, Michal Hocko wrote: > > > On Tue 05-09-17 21:23:57, Roman Gushchin wrote: > > > > On Tue, Sep 05, 2017 at 04:57:00PM +0200, Michal Hocko wrote: > > > [...] > > > > > Hmm. The changelog says "By default, it will look for the biggest leaf > > > > > cgroup, and kill the largest task inside." But you are accumulating > > > > > oom_score up the hierarchy and so parents will have higher score than > > > > > the layer of their children and the larger the sub-hierarchy the more > > > > > biased it will become. Say you have > > > > > root > > > > > /\ > > > > > / \ > > > > > A D > > > > > / \ > > > > > B C > > > > > > > > > > B (5), C(15) thus A(20) and D(20). Unless I am missing something we are > > > > > going to go down A path and then chose C even though D is the largest > > > > > leaf group, right? > > > > > > > > You're right, changelog is not accurate, I'll fix it. > > > > The behavior is correct, IMO. > > > > > > Please explain why. This is really a non-intuitive semantic. Why should > > > larger hierarchies be punished more than shallow ones? I would > > > completely agree if the whole hierarchy would be a killable entity (aka > > > A would be kill-all). > > > > I think it's a reasonable and clear policy: we're looking for a memcg > > with the smallest oom_priority and largest memory footprint recursively. > > But this can get really complex for non-trivial setups. Anything with > deeper and larger hierarchies will get quite complex IMHO. > > Btw. do you have any specific usecase for the priority based oom > killer? I remember David was asking for this because it _would_ be > useful but you didn't have it initially. And I agree with that I am > just not sure the semantic is thought through wery well. I am thinking > whether it would be easier to push this further without priority thing > for now and add it later with a clear example of the configuration and > how it should work and a more thought through semantic. Would that sound > acceptable? I believe the rest is quite useful to get merged on its own. Any way to set up which memcgs should be killed in first order, and which in the last will more or less suit me. Initially I did have somewhat similar to the per-cgroup oom_score_adj. But I really like David's idea here. It's just much more simple and also more powerful: clear semantics and long priority range will allow implementing policies in userspace. All priority-related stuff except docs is already separated. Of course, I can split docs too. Although, I don't think the whole thing is useful without any way to adjust the memcg selection, so we can't postpone if for too long. Anyway, if you think it's a way to go forward, let's do it. > > > Then we reclaim some memory from it (by killing the biggest process > > or all processes, depending on memcg preferences). > > > > In general, if there are two memcgs of equal importance (which is defined > > by setting the oom_priority), we're choosing the largest, because there > > are more chances that it contain a leaking process. The same is true > > right now for processes. > > Yes except this is not the case as shown above. We can easily select a > smaller leaf memcg just because it is in a larger hierarchy and that > sounds very dubious to me. Even when all the priorities are the same. > > > I agree, that for size-based comparison we could use a different policy: > > comparing leaf cgroups despite their level. But I don't see a clever > > way to apply oom_priorities in this case. Comparing oom_priority > > on each level is a simple and powerful policy, and it works well > > for delegation. > > You are already shaping semantic around the implementation and that is a > clear sign of problem. > > > > [...] > > > > > I do not understand why do we have to handle root cgroup specially here. > > > > > select_victim_memcg already iterates all memcgs in the oom hierarchy > > > > > (including root) so if the root memcg is the largest one then we > > > > > should simply consider it no? > > > > > > > > We don't have necessary stats for the root cgroup, so we can't calculate > > > > it's oom_score. > > > > > > We used to charge pages to the root memcg as well so we might resurrect > > > that idea. In any case this is something that could be hidden in > > > memcg_oom_badness rather then special cased somewhere else. > > > > In theory I agree, but I do not see a good way to calculate root memcg > > oom_score. > > Why cannot you emulate that by the largest task in the root? The same > way you actually do in select_victim_root_cgroup_task now? Hm, this sounds good! Then I can apply the same policy for root memcg, treating it as level 1 leaf memcg. Thanks!