Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751449AbdFAShB (ORCPT ); Thu, 1 Jun 2017 14:37:01 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:45653 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751169AbdFASg5 (ORCPT ); Thu, 1 Jun 2017 14:36:57 -0400 Authentication-Results: kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=none action=none header.from=fb.com; From: Roman Gushchin To: CC: Roman Gushchin , Tejun Heo , Johannes Weiner , Li Zefan , Michal Hocko , Vladimir Davydov , Tetsuo Handa , , , , Subject: [RFC PATCH v2 1/7] mm, oom: refactor select_bad_process() to take memcg as an argument Date: Thu, 1 Jun 2017 19:35:09 +0100 Message-ID: <1496342115-3974-2-git-send-email-guro@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496342115-3974-1-git-send-email-guro@fb.com> References: <1496342115-3974-1-git-send-email-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:200::1:ebb3] X-ClientProxiedBy: DB6PR07CA0129.eurprd07.prod.outlook.com (10.170.219.22) To DM3PR15MB1081.namprd15.prod.outlook.com (10.166.160.135) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PR15MB1081: X-MS-Office365-Filtering-Correlation-Id: 89b3f5f2-84d4-42e7-ea29-08d4a91d0426 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:DM3PR15MB1081; X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;3:b451jY0gKr+Ze9JAKtkj4G0QAJpaB3qVrEpYezo1cTqD5atDUTqkIPKQA6ZlWOKFK9zz2pb2Za5Fru37LaETHxaRr3tjvOKIw82GV5wKlCp/1g9RCfDYYXlZkD/+W53tCljorgoAZC9N1ZCXdcW+hR0ndrjbhzrSjuFrD7V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bjf+m9USgCDWbeAIFDcl6L5A6FUWfB37l1+np8BWJyw+GJRG+XK2swmaKXaJRZxY5lIeTAxEAJ/26W66dy/LGVouuhK8CM3tBLb8mB05nOGL6hRcgEfiZGeiMHowmAi7eNAYxR0jgfhxyLC0hJu9pMFy3TG9eNEIryhybv+KZVa8MgMa7DZcq0VOTWcUQQTrasKMv0qy4F+7nSpbWKoWzycbQUIfRvXqaV+mFCJsDBBd8Xuxuz8KOgzr/D2euVPKbbRnOHF80IA5Gxzy59ru5jgCSOetf+38E277oOdMuZ8bp2h4pSqE2wDM+BZzqFjM2tEbhDSZ2gIPdLj6rblCP3iVFT5Fq+wsPKbmEMUF8WjLsc4ptI9D+7y0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(50582790962513)(67672495146484); 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)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123555025)(6072148)(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: =?us-ascii?Q?1;DM3PR15MB1081;4:Agx6wK3PHHtIt3LhB0kpFuzZ3vPcXxU0F/SgZDlcCq?= =?us-ascii?Q?NpZNOOyiYhPOnbHrvBLaxIrF37Jqji55FsBwcM2rTRuIUK22ePbI/wwNumoD?= =?us-ascii?Q?sXxctrceAbEkQsI9/CH6d1TXkBQKm6K0NUEnYNGibMqDKllQSGfYH/4xJ357?= =?us-ascii?Q?kvq2G+wIxse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y15?= =?us-ascii?Q?He1pBBiDAMRKoWy+TsqbHJwalKHHNlISpIjYyYYoGQhqgCaiVzA2s6t9d/Z0?= =?us-ascii?Q?bHljD/uujaUirjZ6k99HXZtfwPsX5wliasnjMy5D3T4xVYocWei6Lw2vAX2d?= =?us-ascii?Q?ndpnD/aLhUcumw0He/UFHFslnlpnPel+7urNhDh1yUArUc09uC0M41NnU2xI?= =?us-ascii?Q?YfslP+Nhea+fX+LcI=3D?= X-Forefront-PRVS: 0325F6C77B X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(39450400003)(39400400002)(39850400002)(39840400002)(39410400002)(33646002)(5003940100001)(2351001)(6666003)(6116002)(305945005)(2950100002)(6506006)(2361001)(86362001)(6486002)(6916009)(5660300001)(8676002)(6512007)(50466002)(42186005)(48376002)(7416002)(54906002)(53416004)(81166006)(76176999)(50986999)(38730400002)(25786009)(47776003)(2906002)(53936002)(50226002)(110136004)(575784001)(478600001)(7736002)(189998001)(36756003)(4326008)(217873001)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM3PR15MB1081;H:castle.thefacebook.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM3PR15MB1081;23:rH+aRswoKGZpdM/fQYHoRMCpiKUSA+/KWi0JZnTEW?= =?us-ascii?Q?o+AgP+a+IFPGGR/b8HE0BaHJejxUzY21G8lK7nXcfAPUnZVtn7zI4Hk8MIwv?= =?us-ascii?Q?EMwwql2JV3c5I5KtmLzArag9BHM1y4pzokbesYEjysWCAspmhYDmsbvLuwjC?= =?us-ascii?Q?wOcW1V61i3x+T6kLuHcvFAd3OSRtBN6WN0cRkkJz9uNG00+tkHKZMdtuJ/03?= =?us-ascii?Q?706Kaz2LNa5t8GmuR23WsDZ7/FMWorHvoGKJTZqYVh9pB7g2WDXiUSh/aNde?= =?us-ascii?Q?X7ihOxR8FOB7wvueSNbvknNvzraEcVtu9f7IICXisXoefAXw7pwPrC6iXq5X?= =?us-ascii?Q?y5iC1aX/KfLjKygvCdHgB2rklCulZyHO6rssujIcT4eYjU7I8a7MhiVki4Zq?= =?us-ascii?Q?B0IYujYeP3A6TSW40wQ9cgejefUZvYYl/0IhLqS6g0prz93MstjVgWJM47SK?= =?us-ascii?Q?JosiuEbkRb9PRokotcq613ptL4ZYdz7XEBNIACX9OG30nFlCM3sxoJJpffhF?= =?us-ascii?Q?R+gepS7JtJrCF8wwuCtIzc3lZF1YTdSSpmSumDa+z0buVJA8TenxtNmshFNH?= =?us-ascii?Q?3Z0gdJrUEm2aLzra198LMY6cEbrTSBNCXBN7gUeVx60WvGSiftV+p3pKCQ5D?= =?us-ascii?Q?CNxqm8vQBT1/FVy6bjTeq/mh2WXJ6WcNufzZlqMqO2ii7meJ/WXRTjj7R78e?= =?us-ascii?Q?uSp97k1Kw+vijp0k4j8hyxGnNP/wYpD20M4IEUe+VGwmtGTuahrm4CoisDGF?= =?us-ascii?Q?gizESPf+LSfgKzPG5LaCkH8Lcv5LAjgOR0OusA5Pe99vywKDInpBv0+sBajQ?= =?us-ascii?Q?2wv7LQQj8HI2DdcyruyukccdXNACe4Cp4mNcZvfa4uU/TksDNqSHn58ZQUgZ?= =?us-ascii?Q?lrJui5z+W5Bw4t812kDYUSKYWjJtO5acsEdag3EaP+MzQ9mRdOuj0+qbN3gj?= =?us-ascii?Q?rTP4AvSJzQXfxe/eO4S/lSX0XE1P+Lu/5A3r6PpYpkijRiO1zL1WpSh5qXUV?= =?us-ascii?Q?HHdslJ+7fP3NLSyJHS7nWFHNbjj7M6YQ2yyIF29+Diuv4JucThEs3K4ncw8g?= =?us-ascii?Q?jH61LXp5C21+PgXbdLZvsTeCtyaTO89iDoHwGDDMbhRm8o0T09G6WFxS2btK?= =?us-ascii?Q?be2YYURcq7lZndXzdwl0opr59Mdy2UXaWiVzpoOg2y7aV57FBBGXg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;6:Ow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PHlR5k;24:S/DHKcDqvxZ6d79Y1VScslCcd2QN0uyHFcGpTOJrnQhH2AE4jY89omqjhkIiVIV40wJUiscjdn8KEX9gZNz1q92b1P+94Gz6WtDmAZt60dY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM3PR15MB1081;7:DkHcSWe2ygfsmnl2p994TVRAw3o858PWSzvkI6jyBpkESE/sSiCoAqBkwzgYu2steAelgKkFZntVW/8XkIlaouWI2SBu6XF9QxXttn1r/ujBuCu3kpJu7IY5cg73CGEvgGJWhbS4AXTqRbjxH6DJxVYUVI2iG1SvpPs4UYSQz+NSoKKuCvK2apYKxuVMuVkz1AurTL6kDPHq6FsDKLJlqwcNkTNWjHRcngKGAQiTmRnbTDLcz34g78RnWBulOlEAgf/VzclufziRe58W8t8hIG2tZqhitb6yxq0n/Ff4Iqu/J/toFUjTTEpyEq7jN6tIQr13k7PnLwQaAaFZ4bOrng==;20:amyEXKSM8p5j7JXTPt/kJYy/VMtKT4ldaJQk59uEm033XHbFfi1vLnwj+PoGb6SQYyZfPGivpGlypD8TkrzJON9d6ZvmHxq0Zjp5/F+Gh+Ykp244g5vtouuWXiKe3yjnJs63szw57/ihwwmuzJvujmGEhladUv9i8f4eGl0rfPk= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2017 18:35:43.7374 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted 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-06-01_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1850 Lines: 55 The select_bad_process() function will be used further to select a process to kill in the victim cgroup. This cgroup doesn't necessary match oc->memcg, which is a cgroup, which limits were caused cgroup-wide OOM (or NULL in case of global OOM). So, refactor select_bad_process() to take a pointer to a cgroup to iterate over as an argument. Signed-off-by: Roman Gushchin Cc: Tejun Heo Cc: Johannes Weiner Cc: Li Zefan Cc: Michal Hocko Cc: Vladimir Davydov Cc: Tetsuo Handa 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 --- mm/oom_kill.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 04c9143..f8b0fb1 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -343,10 +343,11 @@ static int oom_evaluate_task(struct task_struct *task, void *arg) * Simple selection loop. We choose the process with the highest number of * 'points'. In case scan was aborted, oc->chosen is set to -1. */ -static void select_bad_process(struct oom_control *oc) +static void select_bad_process(struct oom_control *oc, + struct mem_cgroup *memcg) { - if (is_memcg_oom(oc)) - mem_cgroup_scan_tasks(oc->memcg, oom_evaluate_task, oc); + if (memcg) + mem_cgroup_scan_tasks(memcg, oom_evaluate_task, oc); else { struct task_struct *p; @@ -1032,7 +1033,7 @@ bool out_of_memory(struct oom_control *oc) return true; } - select_bad_process(oc); + select_bad_process(oc, oc->memcg); /* Found nothing?!?! Either we hang forever, or we panic. */ if (!oc->chosen && !is_sysrq_oom(oc) && !is_memcg_oom(oc)) { dump_header(oc, NULL); -- 2.7.4