From patchwork Thu Aug 2 00:31:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10553147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F1CC13B4 for ; Thu, 2 Aug 2018 00:32:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FBB628826 for ; Thu, 2 Aug 2018 00:32:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13DE129A6F; Thu, 2 Aug 2018 00:32:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6314328826 for ; Thu, 2 Aug 2018 00:32:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17CB76B000A; Wed, 1 Aug 2018 20:32:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 12F8A6B000C; Wed, 1 Aug 2018 20:32:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC4A96B000E; Wed, 1 Aug 2018 20:32:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by kanga.kvack.org (Postfix) with ESMTP id 74B216B000A for ; Wed, 1 Aug 2018 20:32:44 -0400 (EDT) Received: by mail-lj1-f200.google.com with SMTP id p8-v6so92315ljg.10 for ; Wed, 01 Aug 2018 17:32:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:from:to:cc:subject :date:message-id:in-reply-to:references:mime-version :spamdiagnosticoutput:spamdiagnosticmetadata; bh=arGdBWfo+OeE2DLlb78edCGjzCW3AhGuBJnoonsOX2A=; b=hRl/x0zN/DshONyACmKlM1pXULPesAtCUpYmAGHSuLLYUH/cM9EB7hQ2olOHXmL6gu I+mgVGjBvrHCt3mMr2loXUjz2WiE+l332S0sTB7KcR1OQB228NZHmocAV25U550zAeUg zXedwY14BY6e3fX2y2a44y67nAMGhiHKtpaY5lTMfCFlXnrMDESQFsaScas1jc4TuyS8 GUcy1vRfMI03JFqTJW24lykTZz4RIzR3tn7+FMOXLouL/P64EYEf9YLMJMaV5FLwAoqm LWU1Njs0n/RfzphEDKfIqWSzLZT2T0YbmtNcr10wuo4pDySKYNN83E1MUzXRNy/Ee7kO bETg== X-Gm-Message-State: AOUpUlHpa1sHwGlKKCUd0S+rUOXChC5X+b87wjJL8X+xF7bKnaWHTmFY UASloIHQ9dPEvsVAgOkCnhUVz/g8Hs20vGfzP66AAh+6H2zUXECrea5dO/lOW8WxeJR/ZFpQ1Oc g6cxDVzs7l79qrvrTJwxDytNupdPia1lcXNe2k5Jbf/ZyzgkqRd8nZfqKeUYjzORkkQ== X-Received: by 2002:a2e:9a95:: with SMTP id p21-v6mr342208lji.60.1533169963807; Wed, 01 Aug 2018 17:32:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpexnb7MvXkFn+37HIKR+oPJ2aXZdaCmnE0KS49WpzS9YlgjdZsryhLCtJmOfqfTJaR2KtVF X-Received: by 2002:a2e:9a95:: with SMTP id p21-v6mr342186lji.60.1533169963103; Wed, 01 Aug 2018 17:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533169963; cv=none; d=google.com; s=arc-20160816; b=EXL6bw20fDu5h+ejlAV4C/T70MgQRHO6gfS7u9soqXdsye7uBxaFxtbqSNEQNNgONT xZPx55ESsKTRcuaEvvB8NWuVH4no66YFpVwtxtlXM5i1s9IU+Rbd5FrPsQnZ+UREUYcN qg/w7Eygivqr8pShmkLxvpbAPuj0EY66YWhhCBMJPcPpLcMD+iyHJIV76uQg1NJJmONg v9OWat0QSLpNJR+izT5zxpD0nUIWc5pNzZm62VdMOKGSztNnpieC3WOn+dN/UCEzhDTf JyYSQZYjCCjh28yLiiTXFDFf0uvA2x8V/NI5QvnJdjE4vEuqLk6tciuh4MGDjZE72uUc I4YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=arGdBWfo+OeE2DLlb78edCGjzCW3AhGuBJnoonsOX2A=; b=kCvBJAKuWZl7lm+x5K4mXUCL+XT/WBOiKRGtBPfmSAhFWZqmOBtjDRnxkmZoe+I5yN BY0NxQ6OlZyU+wo/Wr6VyybdLwpyFy2dkNU2UuN6FrsJEJiBfEYYnFnrlu4JNvTp7qGb HL+R9u11hsj6+S/LEDj8dsLSUP0WPs2Xm2vgOGJGb8kZCr74UQrFsen//NWalNSZF6lJ sntz1VAR2pWjSvsZttgT7mcUt1YmaGyDgDN5RiQr2AQBac8InaoYl+jkWMv+81iGTR8v dBCLoEeRCHRqlmwiz6S/tO7dP40PMi/D3tiFhEJ0qcPE030FkHD1WQdDPXJAYF6YZiUy Oe3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=lQlIHJQI; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=G03L2VbH; spf=pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17527a5e5a=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id 13-v6si155955lfz.188.2018.08.01.17.32.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 17:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=lQlIHJQI; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=G03L2VbH; spf=pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17527a5e5a=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w720WQtq007291; Wed, 1 Aug 2018 17:32:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=arGdBWfo+OeE2DLlb78edCGjzCW3AhGuBJnoonsOX2A=; b=lQlIHJQIgAFNDS1qsWiwMUB9Q0lH3+7767qIRXmCKP7lbGrrdDSmGH2n12DL0GUXgo9M 1NjV/zqPRvcrXmMercBUBZUXYdTfq5aFwfjhImjnnuPC3map8BOsYLLY0NcQ+MtWgyPv jV4TkNp7cfaSSQHjOxA0KVB8vhD/7VK0owI= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0b-00082601.pphosted.com with ESMTP id 2kkfcvhh45-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Aug 2018 17:32:29 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.27) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 1 Aug 2018 20:32:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=arGdBWfo+OeE2DLlb78edCGjzCW3AhGuBJnoonsOX2A=; b=G03L2VbH/6Wa0LhtvWt5L2W9cxLz8LQXLUxSDrk81fX2f75cAEpfvjHynGXqFok/Niogse4OrUkTTLYr3lWKdXnHtMrvHZ8UC05ldLnk5ts46Krypufusg/7tD2XBGgZh05zqCcmgC8jZL0DO4L8RztsUlrXQfQyHTcDtaml0D0= Received: from castle.thefacebook.com (2620:10d:c090:200::5:2fa7) by BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Thu, 2 Aug 2018 00:32:19 +0000 From: Roman Gushchin To: CC: Michal Hocko , Johannes Weiner , David Rientjes , Tetsuo Handa , Tejun Heo , , , Roman Gushchin , Andrew Morton , Stephen Rothwell Subject: [PATCH v2 1/3] mm: introduce mem_cgroup_put() helper Date: Wed, 1 Aug 2018 17:31:59 -0700 Message-ID: <20180802003201.817-2-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180802003201.817-1-guro@fb.com> References: <20180802003201.817-1-guro@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::5:2fa7] X-ClientProxiedBy: MWHPR13CA0006.namprd13.prod.outlook.com (2603:10b6:300:16::16) To BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbd51d0a-ebf6-4290-cdec-08d5f80f689d X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:BY2PR15MB0167; X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;3:NMiuizapGXlDHbhmLDZdNG86ba6h95VQ/6JDejBBGb4KxRFGic75E7jJW7r5VZBnXqLLCk2sC74H79XCuP3v69xG/DXIrakRg4ULlEMNgZO54cgXMSX05M+zWHFfuUUmH/5ngJHwvPprFtwHQxwjZUI1ftBXZqfyMev/53Pptoy1gq+4h5huEieIGnBqgd94EETdIdXF7vYScB4mpvvkEfn7aP0JQwh18nXZs+vk+NPr8J1/phedhgGG6PjTDatn;25:OpUe2DwTS3YwgYhg9wyEX88UYIhsbDEUpWwdd66Ml9vvu/+ZnuWRxYvsHkX7LBUK6dbYidKnI5OziW2R4cTdCjSMIoVUiWlHp3iZOBJ4oPPRxk3ds6423G5rW6p/QCAeDP15wP26IAuLuE9DXt4UsPjvjLR21IABUDkb75TXD19U/UTrUNGWAL5ojNYSCjGK/R/+Bi1dlBiKf82frIf1reJ0x1qz808n74pHzw3yMiiQFqukI4OyEHT56Euqz15UPJiCkkMdip9A1sFO+YueLs/YF8hIEQjbGsmQPwtdKfYJIlIN4Jk76OXuCU4WbLNBF9x1Kwu0ETBtduGtFKs21g==;31:6H0xx1Px985gQ8S7RJuX57/IQX/0Vnwl7K5FfrlEe6xTNWJM0ViaVXnLCKbMERI1VFi2L9bRSx5SrqFTyuJZfYcqRPiPgfnpyakwC1h3j+WWaZvddWk+AZpXV3k8KEYD2088JxD5A2PwQ/hv3SVVEdhzlyUsHFM4uG7AqIQ2W8afeLlat3K82nKqY093iR8MxIHPpol2Fdn8/7eP/KEwN4pu4AdMRKNValy8M6RL+K4= X-MS-TrafficTypeDiagnostic: BY2PR15MB0167: X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;20:fhDT+8tnGacn0QhMFv7H5tBMjmdX1++mMBevidXghc2a0/yg47LV8gBDsXF8pqz5tssTChPoQSLPLOCxTtqWBvl3yfNOMFHZLa7EHOrUGyotXu3fCjnhGHCkeqGjPJOiP1TNHwVgQEInQfOPwzPfb4Y4+cywpwKiPgqR3c8ScdaY0PcNQKIH2QGutZeXcILMpVdkVFYjBaZfzTahkLxJNYVIwPruMxJKodSpGc7vTjvdV+yGcf0zKTHZetQcBVYNa11BUDKGhJwg1QBI46gdeZEjt79n2nWzcyRq36Qm03H7ErjSnfDJ1HNvY1cgD8tcDLqrWQsOPSXr+jkqa0nTCKVaZhz2Rev1X1k4xune7XqYA+39nR+M21f9dS20NIyQDNfg0xVbcfXeAgcJYmOU3jfcSDGkT2bDhR1nJhdDCljkhj1RaBxYbic8DJYWC3vti2zUb7xoAn4CGMSN7OPjhcypxYKaJwcbUF6SDn6aAFuGZplaGX+h+6xtFrQymtpd;4:9RGpASvPzbKYiiX22zEYu5KAEQdkSn7PnDehWS5vDsO86+rcTYoqMRpIS4r7xaHnfY4uZQ4oJoAqRBdGwXJwZRqiOtzB/AAKL0ebYuDeoYGEk+ApC8VDELlV70pFA4Sq+xvYYUlDN05EPL5bgttGsi+MDEAsKMmaSPggG9ZhHO9pqhqK1p2RZS7pdnYrYk7DNrx6YkBG5vJqxNRvjHdcOvqanGo/g83dIKuse6EgvRzFuNVBGNVKB+WxJZuRlx8xzOBgVKWaX3t/Lq5a54yyhclYSnDVi54Iljm9PVIdiWcQ61R+WVxM5lQ2Jb953d5ktM6/8iM04b8CkDjKvlSgXIsq6f2b2y4dtOb+JhJC7eSXi8StjhBYR4veJxa5hbWjDy37BO4mq2lLawUEYngu5Ao4AM1ECN1Vvbq0p9 Lcd6s= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484)(211936372134217)(42068640409301)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(11241501184)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:BY2PR15MB0167;BCL:0;PCL:0;RULEID:;SRVR:BY2PR15MB0167; X-Forefront-PRVS: 07521929C1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(376002)(346002)(136003)(396003)(189003)(199004)(25786009)(52116002)(54906003)(36756003)(68736007)(16586007)(50226002)(316002)(6306002)(53936002)(51416003)(76176011)(6486002)(6512007)(50466002)(52396003)(966005)(5660300001)(6506007)(386003)(4326008)(16526019)(478600001)(2361001)(186003)(6916009)(1076002)(305945005)(8676002)(476003)(6116002)(11346002)(486006)(2351001)(6666003)(7736002)(97736004)(8936002)(48376002)(446003)(2906002)(53416004)(86362001)(46003)(47776003)(69596002)(106356001)(81156014)(81166006)(2616005)(105586002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR15MB0167;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;23:MTj7RsKvi4oilZN69o4ONv4jVKjLmTC1NSF0GhoezPx0PUjesaX57O4h659zHRXkx4FQk0Vep/fb+32pjiH+V4dOuguKpPdD17oynpJRelCZvPolOuofgj6514j8M8QXu/gw3Nk+h2BPuGiwIoBU0AzRxyD9t4xrZAer6M35SfWg1OiubMDVVNLZDtFpYcZeJq1OBah4ZVDuVNThQS+15uJERWj+vc8f3cxIv9oAq6BG9ZGH1fBTfzxHAz8udmGqwkiZtR5A/fK6FmH8jHX4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r16LT7t7959DleqZnVmUtEU3d7j6iGuk/c6MhpqKM3OI5hvo2VPzdNODDVXh5g4zKQABJBFpDTm8rwoEft5NvCEvYlwMc8eYSyNiWxiCz5qPjiblIyX2nkSEtAepbcJqJhd0TVKn5xGrL0F0vWi8YM+Zen3jO+Rytr6kOPr4vOtJd1T+hTGU7I/HjlZhNgaGfxykA40sU+AGM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;20:OgQxfKDkKUSLj6e7wiySGGK74RDy6Iu6AGeTq4CWsO0X3GjhreBgfGNnyWRnUbNHVlu7wqnTp5/JVLuoJW83yDPxd443DpiGJbX37jVxdW6L6YC1KIjpSx4YJB2u21v6gYUcrjhOGkjJtNX9oLYIvag3hUQI2V8vNgSDKEIehNs= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 00:32:19.5212 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbd51d0a-ebf6-4290-cdec-08d5f80f689d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR15MB0167 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-01_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Introduce the mem_cgroup_put() helper, which helps to eliminate guarding memcg css release with "#ifdef CONFIG_MEMCG" in multiple places. Link: http://lkml.kernel.org/r/20180623000600.5818-2-guro@fb.com Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt Reviewed-by: Andrew Morton Acked-by: Johannes Weiner Acked-by: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell Acked-by: David Rientjes --- include/linux/memcontrol.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6c6fb116e925..e53e00cdbe3f 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -375,6 +375,11 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css){ return css ? container_of(css, struct mem_cgroup, css) : NULL; } +static inline void mem_cgroup_put(struct mem_cgroup *memcg) +{ + css_put(&memcg->css); +} + #define mem_cgroup_from_counter(counter, member) \ container_of(counter, struct mem_cgroup, member) @@ -837,6 +842,10 @@ static inline bool task_in_mem_cgroup(struct task_struct *task, return true; } +static inline void mem_cgroup_put(struct mem_cgroup *memcg) +{ +} + static inline struct mem_cgroup * mem_cgroup_iter(struct mem_cgroup *root, struct mem_cgroup *prev, From patchwork Thu Aug 2 00:32:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10553149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D0BB13B8 for ; Thu, 2 Aug 2018 00:32:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E46B28826 for ; Thu, 2 Aug 2018 00:32:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31F3129A6F; Thu, 2 Aug 2018 00:32:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B1A828826 for ; Thu, 2 Aug 2018 00:32:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD74B6B000C; Wed, 1 Aug 2018 20:32:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D876E6B000E; Wed, 1 Aug 2018 20:32:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4FE86B0010; Wed, 1 Aug 2018 20:32:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 4B5A46B000C for ; Wed, 1 Aug 2018 20:32:45 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id s18-v6so231382edr.15 for ; Wed, 01 Aug 2018 17:32:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:from:to:cc:subject :date:message-id:in-reply-to:references:mime-version :spamdiagnosticoutput:spamdiagnosticmetadata; bh=U3IAqHuTQI5+fGwBjPHzcpkTcIvEn3WUFGPMfJBQWoY=; b=qEUdtKLre7q4fLyZgYScosa6ZabuMRwxa9zamikSiaGdm+43Yh+gJSI1F0oXpUFKV7 t0qSRHnKS9UU7itMcsexfIpYKS8mWFaPTUd+gZP9U9dVyFumQ+GBKinWcJAVvKOKO2/f u2ZzPQJtGD4ZfWUlIXrjKzgoV77IUaoQ9wMzLzysYRmbl2nVlHQXXR65SilD8A5mwb50 jy2TtK2/8ShOTMr62gJrMe/HCksOMcl8G3Aj2SAbTKzsCig8Ga1v4/J8kbQyjccRk/zw 8xwuJlsLMhI05ftZgSz1VxSGRezJYJ2X7twQartNTUGCsqRYzs9S69KgN35YlfCTsC4Y VchA== X-Gm-Message-State: AOUpUlHjCugIY/FSs8iNU8nJeeD3YoymIZp3twGepcNQ9qTyc/IQ809+ /wW5Oxf/L88mRoiC2a5yh2ecgZs5xuIATZsz75oriXGt10cjRIsSbb0BxhNDzU3cvkJb/eHJ4Ru jUzSjLe8kPhWTykl2LaKybytKX0+lpNBTEmg2eQp0cMbyqIwQL+RGvb/muz4suyJyVw== X-Received: by 2002:a50:9943:: with SMTP id l3-v6mr869492edb.272.1533169964689; Wed, 01 Aug 2018 17:32:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfsXMybVOq/18DcgIi76hEFxLgx+3DkjYMZiERK1pMlZq18jCKC4aqrB626R2u+kcc1up98 X-Received: by 2002:a50:9943:: with SMTP id l3-v6mr869466edb.272.1533169963999; Wed, 01 Aug 2018 17:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533169963; cv=none; d=google.com; s=arc-20160816; b=ddabVAc6MrgXJWPLQeOEG19Wt1BDn4Zd2TG7onqt9pnXbjOx4nakh3Znkxr27TBcyq 4JoEjFA6xHFhc/4ZN4uYyOHNDOJ3t6mWsdJOWoFUQaNbH3wd1wjJRwmcvClErIiZJd5h +C92h63/5jGZXX0Cqj2LUf49KTcidm63RmGLfBrbvafwCfzEgQo2jZwltvPvMFbuMbSz yfzaFMmI5+WPyNX1AJYM1IXAQK14zOkksb5ukEwHiMTBZ6qMhGqHOi4dUemvCVGs8x1A sGMqPU+uDbE/Ha/jOpIqjcuH9FcLA3x+3PdZtlZJZQ2uNmhn6Te0FcKDTH/+L8H8Cu/y NXug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=U3IAqHuTQI5+fGwBjPHzcpkTcIvEn3WUFGPMfJBQWoY=; b=Gh/aOQVqMfczky1uqHEdPWGlcGA2wR//HEIWC2cjSEWaqzlz+nLELVoWBqGVt+mz/O 46DyF9Sdepmk+9oCCXey0EdgNe3ajZbHoAuSFR3puOmiXScIwZD1CfMm5m2uJ8FUKjzZ ocy9LUFrRKCX51RgUZi3h9Dyn5ADmSZmY9cyHDVWmNlRpNHeR7vNN33ipFxbsLi7iA7V NlWJAVFo8BBzC4YGITX9Fts2dAfgwJCZgY8dDcFlMsjjR3F8H7uBd43Y+AO6BZT8OcJb zsJa3JkIwAxrVuhNVCgvQuy5JDqkuR6sIaglg6N6pUPXzs78IfzYOtEtrNji0NkPK4WR Y76A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=DTaCxZXM; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=EHsgPVsb; spf=pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17527a5e5a=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id v2-v6si700600edm.144.2018.08.01.17.32.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 17:32:43 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=DTaCxZXM; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=EHsgPVsb; spf=pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17527a5e5a=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w720RlmF031549; Wed, 1 Aug 2018 17:32:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=U3IAqHuTQI5+fGwBjPHzcpkTcIvEn3WUFGPMfJBQWoY=; b=DTaCxZXMCetWwQyJgWZNeSRRI6gUPcaT/N2bYQ82Keu41tKXcXOpX4ljyhE3e55AC6SC y0oMYvjqK+8qPQMYb7TQPiCN6z5YWEbQ6ATLTNTI0sVQZ6/h0i27iT8wIOIibFrQa/yn W83r4qy3r0l4wH0tbdVTnN3cLC/syRADM5Q= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kknssr7sp-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Aug 2018 17:32:33 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 1 Aug 2018 17:32:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U3IAqHuTQI5+fGwBjPHzcpkTcIvEn3WUFGPMfJBQWoY=; b=EHsgPVsbY3ThwFrL3ZiOQdeX8xC0mRDjEWq/nxbWHISmgYAGxHp0ZzzIVMqitVxHhe57tdFEUJbmIksUDtpNA9tKoWkh3smKlswTyqdpKMI31iVB9vJisnuEdqz9k3QmNTpTLH/HRV/xoF0R+uMTDublclhNd3QZBnktL6eRi0k= Received: from castle.thefacebook.com (2620:10d:c090:200::5:2fa7) by BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Thu, 2 Aug 2018 00:32:22 +0000 From: Roman Gushchin To: CC: Michal Hocko , Johannes Weiner , David Rientjes , Tetsuo Handa , Tejun Heo , , , Roman Gushchin , Vladimir Davydov , Michal Hocko , Andrew Morton Subject: [PATCH v2 2/3] mm, oom: refactor oom_kill_process() Date: Wed, 1 Aug 2018 17:32:00 -0700 Message-ID: <20180802003201.817-3-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180802003201.817-1-guro@fb.com> References: <20180802003201.817-1-guro@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::5:2fa7] X-ClientProxiedBy: MWHPR13CA0006.namprd13.prod.outlook.com (2603:10b6:300:16::16) To BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9348a694-726a-4afe-f8e0-08d5f80f6a8c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:BY2PR15MB0167; X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;3:RD1BNDJnTcFkgMwPv1JOu457LVZhQ3QvZXiWaYNoNMnXlj70TWlKk8/hYF3dCM11irznJutDQbwDmF/pcSW+2ZPxxIppVOLHtGQabNqbyJ2zXgWJI0yvQ4AgE3ecil2HdArTS9Pos+RAaksS0UhrhB3JYnVyEk5faJaxr2iNadkE3rfDM5URDkLozXBVMroNGl85QAmIhoix60v6qxG4XoSWlioUUZlArJ0AD23KScBRkWvb4RZQ81zl7WRXz3//;25:ij8N2cB//IS/OWATYa5067apxqGWDrYiY9KivMIvuK747z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zMve9m3wiDQIONHcHa06r3ORbS+FreeYtE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(274141268393343)(85827821059158)(67672495146484)(211936372134217)(42068640409301)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(11241501184)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:BY2PR15MB0167;BCL:0;PCL:0;RULEID:;SRVR:BY2PR15MB0167; X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;4:j2OabNnVdGG4l5qwM81A8MBJFQ/HxvZ1prLZKebx77X02H5JAGArYP0PkcquYeEvxy3D+HFW4rNyrgVKH5S8FVLVQY/jmjOqK05gB5DeS0i7oBF271AYXbc2+1L4BX8rnMoRKpzslFgDrSI3fYwE7VVIm9P6saDLkYfWw2Dd4QjS9xQ2q1+VAeYGFOjVbmbrJfHD5ebf/1VkGweJepVmTDwdA/v5xFCb/NC+Z5+O9SaVLr4XjW/aZzVypl6GQ/PGyK7OvCdSs+mCaeP/EWgjJ6dPiiiJQ4CBtMkdNMoNCAyhTxN91qW0ACv1b2+J5lZ2YFXmpltkOSV14DN1cT1l0Lz8095G3VEmTj4NtvozkWOcdECnbnvf7du2IR+K1EH8LVg1aGLVK+4sU4/6xSoMyAXXuACg5zLc4dh92M0UNR/2LxPpzK+3+oPptUowmTwkaAPxVbJF4/QWRFkQj2TwL6IGwm8VxZiCbokeoRr1eGA= X-Forefront-PRVS: 07521929C1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(39860400002)(366004)(376002)(346002)(136003)(396003)(189003)(199004)(25786009)(52116002)(54906003)(36756003)(68736007)(16586007)(50226002)(316002)(6306002)(53936002)(39060400002)(51416003)(76176011)(6486002)(6512007)(50466002)(52396003)(966005)(7416002)(5660300001)(6506007)(386003)(4326008)(16526019)(478600001)(2361001)(186003)(6916009)(1076002)(305945005)(8676002)(476003)(6116002)(11346002)(486006)(2351001)(6666003)(7736002)(97736004)(8936002)(48376002)(446003)(2906002)(53416004)(86362001)(46003)(47776003)(69596002)(14444005)(106356001)(81156014)(81166006)(2616005)(105586002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR15MB0167;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;23:eEMcX77e5JcmKzhVviUUnm35ejlcDqSHxWRuMiZuI5F5O8EAGZjEx/gljNzwQQ6Aa66Hx3ClXV0deH48fZfpDHHSHUkz1Sgnopg83VMhoBzPZZUyG3PxlE/tf137F80cBjWsmnmgNniAp1gD/5ftkfDCz5PmN+j7hFI76meI2BbpQwmi+IBOL3Kc7t/TqYZJBr4gzQvKXC9a4Rkssv0PD80Yp4ms8YfbU7gLSPhnB4WJDOC+rqLCDFzypz94LojcGKI3vVWNGDY5c6fRhkjfBNBjsICjihHrk/jmmGiyyjhOF7/Rescf5GoaOQ6WzIAAjPku5MoiUUeLheCL7KuxqNS6RxxlhPRVOLx48zPvV91vQRezJsajY2XpPyYgmZmJe1MaUqgEUFQ9NhvgFmDx6nr0YgOAmaQGhSYH1v1I8Y29VVqyXOlMqwZ/ZPEW0h7gXh4JXyEkbpKZ4ecTGm693qeQXXY/ucdPJMPUiq/VtF0tIgKYgYnLElTaukkhQDBlxKXpGHTldiCxM5sr08dnyDPboIl6LF/rmsg6P4a6GosqUD7umEVs4eu3LMqrYH5Ewth4SjYZCR0OnQezdzQf9k/i9imDUPE7H6DnhzG3cD3dB5t5wLuIzHp2Zm55fm8aX8+ArNXw4XCV9H4k1bDbvjVIFwT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UYn2GMqsLv13tp0LdUBvhAfaWr5aJNuKRgtpHItf2if5lUhfUC8NY0SGqaX/oIRakIHEXU6hbNSIw0pgQiVbzRfFTLwx+Px7cmelHg4lqVwD2zN2LXO0j7MveitPFqozhjri9qLGNM2xVk58= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 00:32:22.7474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9348a694-726a-4afe-f8e0-08d5f80f6a8c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR15MB0167 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-01_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP oom_kill_process() consists of two logical parts: the first one is responsible for considering task's children as a potential victim and printing the debug information. The second half is responsible for sending SIGKILL to all tasks sharing the mm struct with the given victim. This commit splits oom_kill_process() with an intention to re-use the the second half: __oom_kill_process(). The cgroup-aware OOM killer will kill multiple tasks belonging to the victim cgroup. We don't need to print the debug information for the each task, as well as play with task selection (considering task's children), so we can't use the existing oom_kill_process(). Link: http://lkml.kernel.org/r/20171130152824.1591-2-guro@fb.com Signed-off-by: Roman Gushchin Acked-by: Michal Hocko Acked-by: Johannes Weiner Acked-by: David Rientjes Cc: Vladimir Davydov Cc: Tetsuo Handa Cc: David Rientjes Cc: Tejun Heo Cc: Michal Hocko Signed-off-by: Andrew Morton --- mm/oom_kill.c | 123 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 58 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 84081e77bc51..8bded6b3205b 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -835,68 +835,12 @@ static bool task_will_free_mem(struct task_struct *task) return ret; } -static void oom_kill_process(struct oom_control *oc, const char *message) +static void __oom_kill_process(struct task_struct *victim) { - struct task_struct *p = oc->chosen; - unsigned int points = oc->chosen_points; - struct task_struct *victim = p; - struct task_struct *child; - struct task_struct *t; + struct task_struct *p; struct mm_struct *mm; - unsigned int victim_points = 0; - static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL, - DEFAULT_RATELIMIT_BURST); bool can_oom_reap = true; - /* - * If the task is already exiting, don't alarm the sysadmin or kill - * its children or threads, just give it access to memory reserves - * so it can die quickly - */ - task_lock(p); - if (task_will_free_mem(p)) { - mark_oom_victim(p); - wake_oom_reaper(p); - task_unlock(p); - put_task_struct(p); - return; - } - task_unlock(p); - - if (__ratelimit(&oom_rs)) - dump_header(oc, p); - - pr_err("%s: Kill process %d (%s) score %u or sacrifice child\n", - message, task_pid_nr(p), p->comm, points); - - /* - * If any of p's children has a different mm and is eligible for kill, - * the one with the highest oom_badness() score is sacrificed for its - * parent. This attempts to lose the minimal amount of work done while - * still freeing memory. - */ - read_lock(&tasklist_lock); - for_each_thread(p, t) { - list_for_each_entry(child, &t->children, sibling) { - unsigned int child_points; - - if (process_shares_mm(child, p->mm)) - continue; - /* - * oom_badness() returns 0 if the thread is unkillable - */ - child_points = oom_badness(child, - oc->memcg, oc->nodemask, oc->totalpages); - if (child_points > victim_points) { - put_task_struct(victim); - victim = child; - victim_points = child_points; - get_task_struct(victim); - } - } - } - read_unlock(&tasklist_lock); - p = find_lock_task_mm(victim); if (!p) { put_task_struct(victim); @@ -970,6 +914,69 @@ static void oom_kill_process(struct oom_control *oc, const char *message) } #undef K +static void oom_kill_process(struct oom_control *oc, const char *message) +{ + struct task_struct *p = oc->chosen; + unsigned int points = oc->chosen_points; + struct task_struct *victim = p; + struct task_struct *child; + struct task_struct *t; + unsigned int victim_points = 0; + static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + + /* + * If the task is already exiting, don't alarm the sysadmin or kill + * its children or threads, just give it access to memory reserves + * so it can die quickly + */ + task_lock(p); + if (task_will_free_mem(p)) { + mark_oom_victim(p); + wake_oom_reaper(p); + task_unlock(p); + put_task_struct(p); + return; + } + task_unlock(p); + + if (__ratelimit(&oom_rs)) + dump_header(oc, p); + + pr_err("%s: Kill process %d (%s) score %u or sacrifice child\n", + message, task_pid_nr(p), p->comm, points); + + /* + * If any of p's children has a different mm and is eligible for kill, + * the one with the highest oom_badness() score is sacrificed for its + * parent. This attempts to lose the minimal amount of work done while + * still freeing memory. + */ + read_lock(&tasklist_lock); + for_each_thread(p, t) { + list_for_each_entry(child, &t->children, sibling) { + unsigned int child_points; + + if (process_shares_mm(child, p->mm)) + continue; + /* + * oom_badness() returns 0 if the thread is unkillable + */ + child_points = oom_badness(child, + oc->memcg, oc->nodemask, oc->totalpages); + if (child_points > victim_points) { + put_task_struct(victim); + victim = child; + victim_points = child_points; + get_task_struct(victim); + } + } + } + read_unlock(&tasklist_lock); + + __oom_kill_process(victim); +} + /* * Determines whether the kernel must panic because of the panic_on_oom sysctl. */ From patchwork Thu Aug 2 00:32:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10553145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A166A13B8 for ; Thu, 2 Aug 2018 00:32:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83FAC28826 for ; Thu, 2 Aug 2018 00:32:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73A3A29A6F; Thu, 2 Aug 2018 00:32:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61E9928826 for ; Thu, 2 Aug 2018 00:32:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 301B76B0008; Wed, 1 Aug 2018 20:32:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B1466B000A; Wed, 1 Aug 2018 20:32:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1526F6B000C; Wed, 1 Aug 2018 20:32:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 907DD6B0008 for ; Wed, 1 Aug 2018 20:32:43 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id l16-v6so218486edq.18 for ; Wed, 01 Aug 2018 17:32:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:dkim-signature:from:to:cc:subject :date:message-id:in-reply-to:references:mime-version :spamdiagnosticoutput:spamdiagnosticmetadata; bh=X7lNMoLKVx4RDXVdRzjSX4rjxqkOtVhHwV6b42mLuoY=; b=OlCRNE5UHiqF0nmQPM+1qh7nhR4dcQBjnqV/y41RwBOjM04r5RIlb1I0D5xbWVayIV JdQAAWTEZ2e5bQ+v0yTZQ77o0YA8rxZHSJhWnGpK3gC7SpqE45mdqCHsEQQR+E6XBSCl CP0UBTew2i8Vf6EeRDSkzEl82aesYdL/QyhEkkOi4ScQWlepb/+u7Po0vAtBYrx31thq RTFMcHdwe1ibDY0HIRwssAPYQmleh3H52NeGQ0SPS+5Kvin0EoIc7OumjIpygeSiY/Q0 pDvh0dRpEKBVDPqvHdA26DJVYB3yy+vMeT20SL7mGMpVcoQPhBbWnvLf+z+96PejY2HZ JTMg== X-Gm-Message-State: AOUpUlFYZoPfuW5BLSl1YMgkXbfP3Xz0MHC7tX8bcQ1CPFbtXdKR1gnj 7eQs8/zXKn3M0GkuXlABFN/dFUUVE0TKiB4jaHVL4Xm8tLj38Hwj6KpMeQUmXzJYY8LxZwHQ2Rd 5c670zItBtKRaYSeAMyQ2MJ71nXUqEBR68s6wb5Pga0LR12i3JUGfZNjd3Hk4jE3r5Q== X-Received: by 2002:a50:bb65:: with SMTP id y92-v6mr943203ede.10.1533169963032; Wed, 01 Aug 2018 17:32:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc1P7xuxEWwSgm53wepess/EpbS6NTDJJxa4sTDCqR3/63LRid+rb4yGENmLpm24yZj4hiz X-Received: by 2002:a50:bb65:: with SMTP id y92-v6mr943171ede.10.1533169962142; Wed, 01 Aug 2018 17:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533169962; cv=none; d=google.com; s=arc-20160816; b=Vth2JOPgAeZa08pgoEOcefcEdA1bxepK6+nxXAhVWjXd2PRFsRuaZjJB1k8vwNWLzH bBLU5EdlPUBhJpSqYyG6MBBhFA3H1fQUMB9VxILiMs0V49B2W7Ooy5WCWGUIFFeHkbx5 0xdwvlN/TGHdqjlIMdOFkSetfegNLwbfXCInoqtQXctciUswT74fp2/YW5M3lZ5EssQO GfJlUcMXXA7jVGWCLjJbBcUqSq0CHOFA6jTVlxinXgqWkKyLZcKIMNsgWcdeWkby6Hdw PkS214VSvQmE3zoXvywAm7gwCWzUqsoRWtqSlfjFadtRGWsw54krR4EzIaqeAMpJ9py3 D1qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=spamdiagnosticmetadata:spamdiagnosticoutput:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=X7lNMoLKVx4RDXVdRzjSX4rjxqkOtVhHwV6b42mLuoY=; b=GVX2TIGbjfZCLXx/mGpJNumAour1FH5frZldhmfrx8YAfKFfTH6iNhuK+N/7iAf/fB TQ2HB0QzMXX0uBd6pLIX7ZLJKM+OP/1CXvtI8R4CUQ4bPvV6WoH/PoDN29Lfs3p2ltoJ 0vtqQxGgNhazGsvuJyxjaQj+sQN2GwinK8sx7bOP2wgc2/OZ0Q8+zGFMTwpM0GFINa8V g2Zt9Kp/L/LhHofnJNjCTUGrOqIg/rAjAEIIn6O4vZThDTRFL5u1DtpQOX2kfP+2YotV fMwMvG+wXRL//5MperYXWXyG44DWvZ+wEkelBeQSzSqaPD3vg6BmJq9U2M86fNIRwjmj c4Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=iKahuqDF; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=BauiBf6Z; spf=pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17527a5e5a=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com. [67.231.153.30]) by mx.google.com with ESMTPS id b58-v6si838615edd.398.2018.08.01.17.32.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 17:32:42 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) client-ip=67.231.153.30; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=iKahuqDF; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=BauiBf6Z; spf=pass (google.com: domain of prvs=17527a5e5a=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17527a5e5a=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w720RlmE031549; Wed, 1 Aug 2018 17:32:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=X7lNMoLKVx4RDXVdRzjSX4rjxqkOtVhHwV6b42mLuoY=; b=iKahuqDFGcU/uFTy3FA1AZq/A5eRAl8Y8X9sWKSSZ6Cs+vVdBQPvnFwkma95vt0eFyGr 1YhLG0amm9yM6e1Sd/hVplxnp0yh68Ogn7k+0KKybKH+DimAHrIWe6lq0ot2zVCMOTr2 WtquhSD7xoKrZdIGFaqz8kZROUq4ltDlr0c= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kknssr7sp-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Aug 2018 17:32:32 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 1 Aug 2018 17:32:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X7lNMoLKVx4RDXVdRzjSX4rjxqkOtVhHwV6b42mLuoY=; b=BauiBf6ZYOFzbN6QvIaKhSC1splA1mnMzJx+ThKPhC9FpuX6Ipd0juimEqhO/bXiPZJbGkiOZeRQ4P3TWU0Rj+mBIFM/MNnbuR02WxpHhKql0VTlPKcIGLf+gx2SznM1jQJKd5pCRwnbHbxvlNxjQ/x1toGq1oMrw1O0dL9ZYr0= Received: from castle.thefacebook.com (2620:10d:c090:200::5:2fa7) by BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Thu, 2 Aug 2018 00:32:24 +0000 From: Roman Gushchin To: CC: Michal Hocko , Johannes Weiner , David Rientjes , Tetsuo Handa , Tejun Heo , , , Roman Gushchin Subject: [PATCH v2 3/3] mm, oom: introduce memory.oom.group Date: Wed, 1 Aug 2018 17:32:01 -0700 Message-ID: <20180802003201.817-4-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180802003201.817-1-guro@fb.com> References: <20180802003201.817-1-guro@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::5:2fa7] X-ClientProxiedBy: MWHPR13CA0006.namprd13.prod.outlook.com (2603:10b6:300:16::16) To BY2PR15MB0167.namprd15.prod.outlook.com (2a01:111:e400:58e0::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6f724835-bdfc-40d6-2de1-08d5f80f6b59 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:BY2PR15MB0167; X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;3:uDCdlHiTx7a30WV8BD2Sq/2Iqiz5PPmP/eW60cjXQ8spkF7mDjyYC1ACCnjhcqORrJd05n6EtmWVCpHyHDaQncOBkd4AjZ8m0jNZXq4Znn8uPB9vvp/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BR8fzpvABP8SdASyG5Aw7bQ4OyRLrHIVpHqfNnZcyb7QErjS+olDXMgboeqWDuHbkvvAQzCCtvxZrMEz8ilDlFNfwIffosiMQem9D2/G7xsaeG09yEa34k4Kvx14WyVLzT2tYspENVa5TfO1b1CpZfWaUP8TDLsHKX9on2NVsslBMu63HwU+3p4avdpGPlJIWVI0RgxCx93mNVmTOjDntClrGArD+jhv1FF;4:rDvO81UI66IgJJ4ZwCr08nVWpMIOM6c57LwhX78LOrk4JnRrKZZ6+UoSfBDaEJRSETZYAgC9EqWY1qgtW0yh/+Y9HEsstap9T72ZP5tIxtGf1KdU9JwpuJexnu42IFxCixfX5PXFTD6IJZ7eKqoY7K01h6VcyO8gUIPovUaOHmOTEhpfLSY0ra0BuoQxdD347Naez5NZe3DVugw9isW2G4NWazBl8McKz9/PLsMCBnJRqp8qJoM1BKnHsJeDarY7fJOpKbBERHQTUcnCbKFQTDheMU565Uil5DEy0LrsH8O0+CRZEHwjD/EBJEsTVuwADtGdLSOrsOwRdW6GBMzc5YIg4n+E6tnZn/+MU1SOxuYjgtIchy15MdbyRIDI7m/ezwRJ7bxWmFlr4mnPX/FArbVmrQCJXCYKWOnHfm HE0LI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(274141268393343)(67672495146484)(211936372134217)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231311)(11241501184)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:BY2PR15MB0167;BCL:0;PCL:0;RULEID:;SRVR:BY2PR15MB0167; X-Forefront-PRVS: 07521929C1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(979002)(39860400002)(366004)(376002)(346002)(136003)(396003)(57704003)(189003)(199004)(25786009)(52116002)(54906003)(36756003)(68736007)(16586007)(50226002)(316002)(53936002)(51416003)(76176011)(6486002)(6512007)(50466002)(52396003)(5660300001)(6506007)(386003)(4326008)(16526019)(478600001)(2361001)(186003)(6916009)(1076002)(305945005)(8676002)(476003)(6116002)(11346002)(486006)(2351001)(6666003)(7736002)(97736004)(8936002)(48376002)(446003)(2906002)(53416004)(86362001)(46003)(47776003)(69596002)(14444005)(106356001)(81156014)(81166006)(2616005)(105586002)(42262002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR15MB0167;H:castle.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;23:1d/ta/hHb+XFcF4BleTYUyymda5n3U8LSDGEZUPwvkKvTDCpxZGo3gBVHeOqzQQNcUu8OmmJXRIeP37ysxEmq+g9/FdCf+0AMAZNDXtMSQx7D1ybfllchNXq8ZKSHWH/MLq6yYDkbLTkUsNyWTq39wKyJC5q6S8ylpQXuEA2TUUye6r3C1NGCXDlFXQxltsnuSoOmb6pVc9+uUyixCAqNQQmRgNNd9jXU78YCEUSKjsTJ1YDG+QNUXp52Bl3wEVfdgg1/DQYAxJrofSCNpTgzeCRZTjBchzja5BWvmhHVHUZT+VywYvGsNcysr2YXcdC3f3SUK2ByrURMboFBAyLSMGQwMx80GxzdP08zZFzjprQB9Pmbpt4pLy9Ok6BOBWCRSOBgPUsyr6i3C18Zz6hWQCiWwZLZXibiKpeh29d+34JeH0GDMg349iMSNR4hR4jUMEzL+ZzSfDnLZIgj09KDOqBxl01NbAY4xf+MZsmsxgn0br37DfoTJxIAkaLPr2jy+EHQso3U/8R3s0f9jdCmTFS/75jsE3BgQu1dOblOVDGMlIgsw6xxZ8bAYnZZVuvHPRhbBMWcbxwanLD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gRJJX1F6BhA8nyaGOAcN/Tep2xADMCqURw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0167;20:vBL4Kb/Cv91GubWUSu5bXVrZyWtMPZRn9wLzbjLPAAEU0OxWVrZmFOU6sG6sF6PfyQxHhoA5WyR00kznHDB4iwK3gpIML7g3V5/fC6n4q1AcVMBCKM/BW3AISXPDU9fjxdFIDrkQzGiRZrmXhQoldrWH6gU6FCGAlCTSMQNt+ZM= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 00:32:24.3249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f724835-bdfc-40d6-2de1-08d5f80f6b59 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR15MB0167 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-01_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP For some workloads an intervention from the OOM killer can be painful. Killing a random task can bring the workload into an inconsistent state. Historically, there are two common solutions for this problem: 1) enabling panic_on_oom, 2) using a userspace daemon to monitor OOMs and kill all outstanding processes. Both approaches have their downsides: rebooting on each OOM is an obvious waste of capacity, and handling all in userspace is tricky and requires a userspace agent, which will monitor all cgroups for OOMs. In most cases an in-kernel after-OOM cleaning-up mechanism can eliminate the necessity of enabling panic_on_oom. Also, it can simplify the cgroup management for userspace applications. This commit introduces a new knob for cgroup v2 memory controller: memory.oom.group. The knob determines whether the cgroup should be treated as an indivisible workload by the OOM killer. If set, all tasks belonging to the cgroup or to its descendants (if the memory cgroup is not a leaf cgroup) are killed together or not at all. To determine which cgroup has to be killed, we do traverse the cgroup hierarchy from the victim task's cgroup up to the OOMing cgroup (or root) and looking for the highest-level cgroup with memory.oom.group set. Tasks with the OOM protection (oom_score_adj set to -1000) are treated as an exception and are never killed. This patch doesn't change the OOM victim selection algorithm. Signed-off-by: Roman Gushchin Acked-by: Michal Hocko Acked-by: Johannes Weiner Cc: David Rientjes Cc: Tetsuo Handa Cc: Tejun Heo --- Documentation/admin-guide/cgroup-v2.rst | 18 +++++++ include/linux/memcontrol.h | 18 +++++++ mm/memcontrol.c | 93 +++++++++++++++++++++++++++++++++ mm/oom_kill.c | 30 +++++++++++ 4 files changed, 159 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 8a2c52d5c53b..7b4364962fbb 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1069,6 +1069,24 @@ PAGE_SIZE multiple when read back. high limit is used and monitored properly, this limit's utility is limited to providing the final safety net. + memory.oom.group + A read-write single value file which exists on non-root + cgroups. The default value is "0". + + Determines whether the cgroup should be treated as + an indivisible workload by the OOM killer. If set, + all tasks belonging to the cgroup or to its descendants + (if the memory cgroup is not a leaf cgroup) are killed + together or not at all. This can be used to avoid + partial kills to guarantee workload integrity. + + Tasks with the OOM protection (oom_score_adj set to -1000) + are treated as an exception and are never killed. + + If the OOM killer is invoked in a cgroup, it's not going + to kill any tasks outside of this cgroup, regardless + memory.oom.group values of ancestor cgroups. + memory.events A read-only flat-keyed file which exists on non-root cgroups. The following entries are defined. Unless specified diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index e53e00cdbe3f..5b26ab460565 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -213,6 +213,11 @@ struct mem_cgroup { */ bool use_hierarchy; + /* + * Should the OOM killer kill all belonging tasks, had it kill one? + */ + bool oom_group; + /* protected by memcg_oom_lock */ bool oom_lock; int under_oom; @@ -517,6 +522,9 @@ static inline bool task_in_memcg_oom(struct task_struct *p) } bool mem_cgroup_oom_synchronize(bool wait); +struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, + struct mem_cgroup *oom_domain); +void mem_cgroup_print_oom_group(struct mem_cgroup *memcg); #ifdef CONFIG_MEMCG_SWAP extern int do_swap_account; @@ -951,6 +959,16 @@ static inline bool mem_cgroup_oom_synchronize(bool wait) return false; } +static inline struct mem_cgroup *mem_cgroup_get_oom_group( + struct task_struct *victim, struct mem_cgroup *oom_domain) +{ + return NULL; +} + +static inline void mem_cgroup_print_oom_group(struct mem_cgroup *memcg) +{ +} + static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c0280b3143e..23045398ad21 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1577,6 +1577,62 @@ bool mem_cgroup_oom_synchronize(bool handle) return true; } +/** + * mem_cgroup_get_oom_group - get a memory cgroup to clean up after OOM + * @victim: task to be killed by the OOM killer + * @oom_domain: memcg in case of memcg OOM, NULL in case of system-wide OOM + * + * Returns a pointer to a memory cgroup, which has to be cleaned up + * by killing all belonging OOM-killable tasks. + * + * Caller has to call mem_cgroup_put() on the returned non-NULL memcg. + */ +struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, + struct mem_cgroup *oom_domain) +{ + struct mem_cgroup *oom_group = NULL; + struct mem_cgroup *memcg; + + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) + return NULL; + + if (!oom_domain) + oom_domain = root_mem_cgroup; + + rcu_read_lock(); + + memcg = mem_cgroup_from_task(victim); + if (memcg == root_mem_cgroup) + goto out; + + /* + * Traverse the memory cgroup hierarchy from the victim task's + * cgroup up to the OOMing cgroup (or root) to find the + * highest-level memory cgroup with oom.group set. + */ + for (; memcg; memcg = parent_mem_cgroup(memcg)) { + if (memcg->oom_group) + oom_group = memcg; + + if (memcg == oom_domain) + break; + } + + if (oom_group) + css_get(&oom_group->css); +out: + rcu_read_unlock(); + + return oom_group; +} + +void mem_cgroup_print_oom_group(struct mem_cgroup *memcg) +{ + pr_info("Tasks in "); + pr_cont_cgroup_path(memcg->css.cgroup); + pr_cont(" are going to be killed due to memory.oom.group set\n"); +} + /** * lock_page_memcg - lock a page->mem_cgroup binding * @page: the page @@ -5328,6 +5384,37 @@ static int memory_stat_show(struct seq_file *m, void *v) return 0; } +static int memory_oom_group_show(struct seq_file *m, void *v) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); + + seq_printf(m, "%d\n", memcg->oom_group); + + return 0; +} + +static ssize_t memory_oom_group_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); + int ret, oom_group; + + buf = strstrip(buf); + if (!buf) + return -EINVAL; + + ret = kstrtoint(buf, 0, &oom_group); + if (ret) + return ret; + + if (oom_group != 0 && oom_group != 1) + return -EINVAL; + + memcg->oom_group = oom_group; + + return nbytes; +} + static struct cftype memory_files[] = { { .name = "current", @@ -5369,6 +5456,12 @@ static struct cftype memory_files[] = { .flags = CFTYPE_NOT_ON_ROOT, .seq_show = memory_stat_show, }, + { + .name = "oom.group", + .flags = CFTYPE_NOT_ON_ROOT | CFTYPE_NS_DELEGATABLE, + .seq_show = memory_oom_group_show, + .write = memory_oom_group_write, + }, { } /* terminate */ }; diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 8bded6b3205b..f10eb301f6bf 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -914,6 +914,19 @@ static void __oom_kill_process(struct task_struct *victim) } #undef K +/* + * Kill provided task unless it's secured by setting + * oom_score_adj to OOM_SCORE_ADJ_MIN. + */ +static int oom_kill_memcg_member(struct task_struct *task, void *unused) +{ + if (task->signal->oom_score_adj != OOM_SCORE_ADJ_MIN) { + get_task_struct(task); + __oom_kill_process(task); + } + return 0; +} + static void oom_kill_process(struct oom_control *oc, const char *message) { struct task_struct *p = oc->chosen; @@ -921,6 +934,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) struct task_struct *victim = p; struct task_struct *child; struct task_struct *t; + struct mem_cgroup *oom_group; unsigned int victim_points = 0; static DEFINE_RATELIMIT_STATE(oom_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); @@ -974,7 +988,23 @@ static void oom_kill_process(struct oom_control *oc, const char *message) } read_unlock(&tasklist_lock); + /* + * Do we need to kill the entire memory cgroup? + * Or even one of the ancestor memory cgroups? + * Check this out before killing the victim task. + */ + oom_group = mem_cgroup_get_oom_group(victim, oc->memcg); + __oom_kill_process(victim); + + /* + * If necessary, kill all tasks in the selected memory cgroup. + */ + if (oom_group) { + mem_cgroup_print_oom_group(oom_group); + mem_cgroup_scan_tasks(oom_group, oom_kill_memcg_member, NULL); + mem_cgroup_put(oom_group); + } } /*