From patchwork Mon Jul 30 18:00:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 10549555 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 D46E414E2 for ; Mon, 30 Jul 2018 18:04:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A9FB28A68 for ; Mon, 30 Jul 2018 18:04:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06A9129451; Mon, 30 Jul 2018 18:04:24 +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 A94E42A81A for ; Mon, 30 Jul 2018 18:02:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C98C6B026D; Mon, 30 Jul 2018 14:02:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 679386B026E; Mon, 30 Jul 2018 14:02:27 -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 4CA9E6B026F; Mon, 30 Jul 2018 14:02:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by kanga.kvack.org (Postfix) with ESMTP id B9BCF6B026D for ; Mon, 30 Jul 2018 14:02:26 -0400 (EDT) Received: by mail-qt0-f198.google.com with SMTP id k21-v6so10902508qtj.23 for ; Mon, 30 Jul 2018 11:02:26 -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=scuHpibUn0Le6Cs82Dm7fG+4MYqegz3zxv5qDEXXdWM=; b=FSdIjGUmCjg0XA9Sb9hmjfHhSgTL3iY/5XQjPiPYrfNoHnDB3e0z3B84pBfwjqNaG4 XnQYNnhguS41A1e5VKRPVZmOLAnUmdqJuluur+EarnENLuCEaIchJmhLj6BjwLiOfaBJ gYp1x6cgNMPokWopxGSW+zd2XMp+mp88cnDcWZwJcEPiJKEDwsumXSmB4veYBPCIvasC jJREsjpHsh5oAr7btnsQIYj7pdxAwsIpne2/zh3rSxNUYus+0+iD6HzT5jcx+mehyZEg I+ICMFEdZBli1yysk705GAhI73QCK8QJxFBDzSSwwif4efrlzpQoDRq0Lye8C/zss3N+ 55MA== X-Gm-Message-State: AOUpUlFI+Fi4SdwgfXQLFDnEEc9eL90eiQQ8u/FeGGCKAXM3CALWL2IE jMcTNRiC1csvCEgYO6Xhb7/UHOeMp690jtvXyPSBpgd7OjTnHVyvsOoi4BzptG+ypQa5mmqj15X Xn9wszVrzcCAzbhtuoUSZr+Tt5ngoFHA/kXH05nAOOP/JQEQc5H9YamFyU4RoJCQ8pA== X-Received: by 2002:a0c:bf09:: with SMTP id m9-v6mr16049897qvi.2.1532973719269; Mon, 30 Jul 2018 11:01:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdUjDvJFMQajE6MiUlARkrafsbNJOBE/qz64Q8LCMLekotiXi/k8bCa2be7i4smEW85z3QJ X-Received: by 2002:a0c:bf09:: with SMTP id m9-v6mr16049851qvi.2.1532973718800; Mon, 30 Jul 2018 11:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532973718; cv=none; d=google.com; s=arc-20160816; b=CfYigmb6MhIi633VnXSpdBbwhrH+pe9e4S6SPjkQESvVQs3pOwJQCDptLkoDa43+Xz 04vfpVvjkt/c3vTlrFSIRfdt0XwQBvaVdGIYHyhaN2QeSwCo8iR+yor5AeTZJ3IrBlfj 821KNknIbmB9LNYFS1Q8CTnbqonhdGy8IeIFBHwNjcPF/GTl/ToMe906VwizoxvkFalw DwPTbQ2KTg4s/WOGuQ6B9hIQwFCkLwwyUcGb7va+x5lYO0Zs1ZYExIAEoBH7n/H4WxTo SxVdGdpOEVEfQR0t48ykUWSstheNWKLLsv2N/+RQT77oIrDqpuCNr9kK6SvLRiBLIHQ+ J7jg== 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=scuHpibUn0Le6Cs82Dm7fG+4MYqegz3zxv5qDEXXdWM=; b=TOp0esgxnkU0FbTbp30I0NXxIxcLit+qQoMORNqkbmhuHWOjHKTRbaC/YYOaL8WpBN wloDsPAbuWMtvFtzdzONkftlmA7RltJ+4bfHGQeRSrttiMLQI+Xajx9095yvqc1WdUCJ UTdddfToLTAMlfcKsIV7o1/C0YlxWBeNtvhnHoJ+yneDvVX0x3jvfliPiWslGaiGHU1s HLkA57wrp+d5DG4JURldZOKPC0oQOXiIwtJoh7+nP56NQaDqRZJ3ki3eBcKGmURK+C9r avAenA81Yq6j3KP63a+6t1n6gbBZeG+w6IhH06fMd4/+njMwLz4ub/aWY6PhvGe7ht/h n84w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Rc1Qa18c; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=emb5oZkB; spf=pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17496daedc=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 a44-v6si5773946qtc.270.2018.07.30.11.01.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 11:01:58 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=17496daedc=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=Rc1Qa18c; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=emb5oZkB; spf=pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17496daedc=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 w6UHouvi010810; Mon, 30 Jul 2018 11:01: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=scuHpibUn0Le6Cs82Dm7fG+4MYqegz3zxv5qDEXXdWM=; b=Rc1Qa18c+u7rB6jpduVm02w1pAa0wVN34GXkWkVCyloTP2pWIt23vZOpPIe8yps/CLp7 p5zdtxOjyqcHF6Xq/v41ukISEkKIrvwmQpfn3Giq3ulqV0xEXACPf3uWEpVWG4fRzl6P wajjwhpzn/nWyYR1AifbiJvxZV/m9Z83jM0= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kj53g0ghv-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 30 Jul 2018 11:01:31 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.25) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 30 Jul 2018 14:01:29 -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=scuHpibUn0Le6Cs82Dm7fG+4MYqegz3zxv5qDEXXdWM=; b=emb5oZkByn82N4+xxB5IU2w8U82y+506VVFjXZsv8lW8biYBbyfz+4dZTXq3ILdB1e9srjfUBh80JJHBZX+MUbXRISA6Xtsxje2N+9N/HTpItfoyJsj60bkubpcAqrT8wGWe8hMqt7IGUidNQchkAYf0n3urxrSutCaQrCtDqV0= Received: from castle.thefacebook.com (2620:10d:c090:200::6:484b) by SN1PR15MB0175.namprd15.prod.outlook.com (2a01:111:e400:58cf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Mon, 30 Jul 2018 18:01:24 +0000 From: Roman Gushchin To: CC: Michal Hocko , Johannes Weiner , David Rientjes , Tetsuo Handa , Tejun Heo , , , Roman Gushchin , Shakeel Butt , Michal Hocko , Andrew Morton , Stephen Rothwell Subject: [PATCH 1/3] mm: introduce mem_cgroup_put() helper Date: Mon, 30 Jul 2018 11:00:58 -0700 Message-ID: <20180730180100.25079-2-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180730180100.25079-1-guro@fb.com> References: <20180730180100.25079-1-guro@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::6:484b] X-ClientProxiedBy: MWHPR15CA0060.namprd15.prod.outlook.com (2603:10b6:301:4c::22) To SN1PR15MB0175.namprd15.prod.outlook.com (2a01:111:e400:58cf::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1aa46cf4-b16b-41ec-0512-08d5f64678a2 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:SN1PR15MB0175; X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;3:EObc8fDgTFaQTwI25z0yY9fuqYoJfJFPjuU/eDG8GHgIuSMJJ2qGgIwugF2VD9LwjoTyzPTgv026rJ1SyYp12d1jCwDpA4Q3dqrLcLLGvgPcydlvDQ4jQQ4NEHVrCzaruavRWot8Mf81Ib/hX4E+TmlYwNdrSomNqgQAVXGvhdGYbeMhlrS5vvLyl+OZ6URm+pPluiLbztMRYeF3q2jPtkeIw8TjCotwUODbY912sYh1nWi7vlc/9OsFsP2U0MH2;25:EvHC8W7QxeujOCQRK7Z6JtPCszhR0XOjET2jQfMxvpil14yh1YP8n6mbMQs1KyL/Nr+cFhupnPfKURl1syevYD1gftNgMgOeByZ5Q4I1fdirHjtelCWS327RGWqzcBzVFA5ByD/n2EOMPEfM/TQ8EG7fSsI6oagJtbdA3GscHljpNLGj0o4PhGSjg40+EPbSMcIMmmi2q5DD8LeB/W8NtMsOx9LMRWOIbNutMlj2Y/YVIac6ZiEvHlzmv7c0RpS4D7I/H5jebXhXfDgYsbMUkReiabILhc4AL58JFjDarmr5k0GMROCLGDCuj6NBzTcQWHfaUEE2WsgKHJPD/EgXBw==;31:ijRt+ZPS7mrgStyYqIWCr7NtYyoicQgsAxZ5/przYHz0JNwUQjW6sGkQd3FyVoNEEwtF/QXDeYcTXwxE9rYGkCRz/YhxijSdwwQQpG/5i0Es/29fdBGtZ34tuW5/0IRw2zAmDTTG2Pk06o8rmdpyx8wtgB6/v1zOG/e88LgQ1C7PQwHzZSmyeXfvsRoF8+hKPdju1seHj9yGGpDucbEy638Od9bQV5oklJRthkVWmdE= X-MS-TrafficTypeDiagnostic: SN1PR15MB0175: X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;20:2929LKuKKlVya0Ok7L8rlviLBtZw6cl68/zpoCHIQw3FLQh3EvLEPdX5ELegIpocJlVJy9r9OplqIrSuFthTye2kivrZHZGF50JiDKiOgN1muZR6sj93eRk4V2K+agjMkF9qyJ9bInEPDptLwVQgujJNOtSpOcaw/JF5sVkdgRxkt1xgph+v3wWokuj9eGuU/8N/Wqrr5u0J9NQGoQDa7Fyy1FPwLRTCl4QIwwdA+U/46fzuw2sIZYeEE+a0TG14Ay/ar+uMqT1qEV0MOgnet21kXnJ43meytRn9WXxEwS8YGcHegyN4SejWF116RCk16m8huLcjb77/zgesMFqR1tjDMypUzxIemA/2thMpx0PQwQ/hYRyzDQ8Lvd3mb6riCOILDJADo4i4Vd6OjZ+6X4capP1ZaZNG7yBJI5cFRDq/tzKsHsnCRSmdfVnu/cu/CatNWzztY4Zapb9xXw7A1pEyx8JyQGjyzLokOGtcxHA92IRODGulLsEbaX3/eMQP;4:7mCi/p7fMijYgC/i/WNzLfiAMpSqdvzkKRCFVcAK1Ys/xk42bTFJC83qJLXyRTMnZHIEl22SvaFfWpEgAsH3sktXYuIcuz50YBmMGByh3bEYnnmXJ7tAUVjVlS6BmARbVwe8Mc3gFk04+RaU78CcP02a7jTEbdpYOOTejJ5W5GCqZeaz6VKI64OGuLJAwSgmK6hqbaD2pgnbhV9BbL43Ro6s0ibbrAyPknh21Fg4W88HOwONE/ZEd3Pzxf8ARqSARM57kx/wQ1fsT/5pExIA3tmJ48B4ALUNWqcsjJBzNS/sv6K3WR+1tVe9DHBl1kyCgUkdL93CsboxlRtSPMoPO0QwoHd3kzuWdYBuRNWJ8WnEK94/2SwpU/fGMbyn3ZF9nCZy+px6Gm48BRzsP3rSs6JXlLz29vRVatTTVU Q4hcM= 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)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016);SRVR:SN1PR15MB0175;BCL:0;PCL:0;RULEID:;SRVR:SN1PR15MB0175; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(346002)(396003)(39860400002)(376002)(366004)(136003)(189003)(199004)(36756003)(6116002)(8676002)(6486002)(16526019)(6506007)(386003)(186003)(1076002)(86362001)(69596002)(76176011)(52116002)(51416003)(52396003)(81156014)(106356001)(966005)(2351001)(105586002)(97736004)(8936002)(81166006)(305945005)(7736002)(53936002)(6666003)(50226002)(25786009)(53416004)(478600001)(6512007)(6306002)(7416002)(5660300001)(2906002)(6916009)(54906003)(2361001)(16586007)(316002)(11346002)(446003)(48376002)(50466002)(47776003)(476003)(4326008)(46003)(68736007)(2616005)(486006)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR15MB0175;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;SN1PR15MB0175;23:amZL3cxWKSlIupBBdSWTHL2RrzFAvwVWfLi4okpZJl5eqBTshKVx5ycizY/dNIPj82G6PwiBLHo22eYAEeqHGOa3Hyg5f/cMkpnG3yxJAAPaHh1ZATnTDm9ndNl2uCVAolBSDxXsLdKsL7gM+4UgfP7M6pkblDa23tc/vKDxV/MRdCpUB0VKRCwCMt3zHJty40IWIzurzmZxq+Mp2JAbPG4JtAaSArFlTtFxJmAOMoTF2mewOXibu7b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lZ1mJI/vtMefMcDsHnjv0LaTaX9nYEaInzgEzKRAtGhOf9M+ukfufeGGmuFAgk8TY+w4dRzA6pkNi+sN+g64hrPBPrOqrtO+RIwdWHTijw4yhYOwKpLVqgrsq45UWg/EQawFJ2RZW4eZpFTFhvZWldQy0iy3G82xjaKJax8DNac9rKXYgDt0dBhj8Ro0QDWY5UT9x5HOx3EaQprb3IR8OS3OYseBM3EruZNDzAKgCTLpIoF5HnIulyUbKDnuolb SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;20:OrJCI7dNYq/HVyx0lRpuVBVZc3QjxYOgyZ6ENZfHLIgdEVPWDFpzOGIE4+xurt3ykLTvIJ5Mf5eZYtmGxpt5lkuHzI1W85bBjEJEGWFQe0YPYYvpJ4eTfdZYySoHlgzFMnFhRzmjEa0aPHHITLEtgtbx/eyXVpckuj2pyIlUss8= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 18:01:24.6247 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1aa46cf4-b16b-41ec-0512-08d5f64678a2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR15MB0175 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-30_08:,, 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 Cc: Shakeel Butt Cc: Johannes Weiner Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Stephen Rothwell Acked-by: Michal Hocko Acked-by: Johannes Weiner --- 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 Mon Jul 30 18:00: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: 10549549 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 9C4C814E2 for ; Mon, 30 Jul 2018 18:01:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D1532A419 for ; Mon, 30 Jul 2018 18:01:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 807312A5FD; Mon, 30 Jul 2018 18:01:54 +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 3CB3C2A419 for ; Mon, 30 Jul 2018 18:01:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 286336B0269; Mon, 30 Jul 2018 14:01:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 235816B026B; Mon, 30 Jul 2018 14:01:52 -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 061F26B026C; Mon, 30 Jul 2018 14:01:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb0-f200.google.com (mail-yb0-f200.google.com [209.85.213.200]) by kanga.kvack.org (Postfix) with ESMTP id B3A8F6B0269 for ; Mon, 30 Jul 2018 14:01:51 -0400 (EDT) Received: by mail-yb0-f200.google.com with SMTP id o18-v6so7321942ybp.13 for ; Mon, 30 Jul 2018 11:01:51 -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=ZxYElDuKKHvsntD4O4CqK+omYumlxZa/PeuWw6eJoU9oQgUm/TZlOWq8IpAdG+tef+ u6C3pKA+NOhmhsI04r+0Zq6E1o6Zf1fvvLPta/tN2uusG1/Y394bI+qZvY9zCMOTl5Dp Rthot5XOw5Pj77c06NddF/Gw+vlOP3w/OtB0ppqvikwdfTDX25rGmY3jUDKEr5VNUgwz OGWWGt0xRkFDELxGY0WFX/d5mRZ9lTv6fgqata7F9M8pEUGmVmThE+KRBFeUCNG61jrD BW5o5MYgOhm5Gacp7qzCyjN4V89SnLFuY3wh/k2LXcVWPvyA1PBvpbs7nNvsYAYZuGEr xnsw== X-Gm-Message-State: AOUpUlHQj7cFRzMC45igvW2Rywmd173/EsKDSVzD7SdjRSUzpHj72+Vf RuvJDZynhoK3UeVEOopR0KaRonCePAnouLJr/vqCpr+3AujKvq8P2PC0iff/2Rxbvgdu6T1t319 S5RLakpqi3kUWLoI21iwsEyp8FkODunTZtc8xMJhq0a2xeIJL4ppaAbVb/k3wKK7V5A== X-Received: by 2002:a81:1745:: with SMTP id 66-v6mr9198727ywx.292.1532973711325; Mon, 30 Jul 2018 11:01:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfBYNvUOBIzVc93eHL7Qc714NpLnkQ+/y5GREvqAxpY3dcz2VHhGjLSbftWmbrsCqxkHuVs X-Received: by 2002:a81:1745:: with SMTP id 66-v6mr9198673ywx.292.1532973710260; Mon, 30 Jul 2018 11:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532973710; cv=none; d=google.com; s=arc-20160816; b=JAazvVogBOI/l6StZpZ2fYrPF/ehwX8YNSg+e0EJ0zUz9Cs0XqchcmY1DcuB5glyq+ NG0YIdKMH3RwAVwGpJ5v6r3uxl9IwHZ1RxmNgW9R1fPwV5StBzdfOFlSFv8oi+VDI5nK A7Kizj06imCufWw0Cka76p9LNGbi5LLdmyttQg4Zc+20gWs/wjPViS3+Sf5xUZB4/GUp AOf1xTHA9Swpye0B6WBlPGgXUs51muqMFtqmNyPEdK7b53kJoeImQ/r+Q+CIsZ+1VrOQ 726p5d4/djULPRQE17/sdC9qO7l71svfSGzSBa6eV2NJ78q3gK7nq69GEV3XPPHrrSWp 3mDQ== 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=c7FmBwf1eGfTgIZXtonqeFVrzgXgbUk0COklzNmzA/0dD38kkpxJ+4SGJZGuQ8laMX Ej4D17GSZIXa5J0H6wFL/hlJOD9gFEVgAWgeXkPQDQJWmUP+fmfS9eQMPies4OtdZzJQ pzdkm/oKx+7WDMQ0y2azbhWFRUKHlosUFRw4Z/1mcpIljIV9iBrSDC6fhjBbHEmVmkZe 5UG6DlBH0vrCcrDOO7wn03zvK9/gGOjw2zzrg0npuWU9L4Hb8i6RbXnifECElnqa2i3X 9pRH3dpMmkvuZ4NSEEx53i59jlxdLzz1tO3MdTvtPxQhxQbFyrmL6rzkJi94CuOCRhCa A+wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Zc+blTtw; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=WUl7pWTa; spf=pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=17496daedc=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com. [67.231.145.42]) by mx.google.com with ESMTPS id 75-v6si2878926ywp.465.2018.07.30.11.01.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 11:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.145.42 as permitted sender) client-ip=67.231.145.42; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Zc+blTtw; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=WUl7pWTa; spf=pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.145.42 as permitted sender) smtp.mailfrom="prvs=17496daedc=guro@fb.com"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6UHoupf014230; Mon, 30 Jul 2018 11:01:38 -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=Zc+blTtwIAB0+Dv3QcOYzni3BSOW2ON3h3xV+cZo8aYAPbd5PHRH0R1MHExdy8emw1te mJ1Se4Fv0VGrWxAAIg2914g7n8ydelqZLj7/Sy9zbh2LQXJtwHCsZxyBK/hBWZx2CiGl mXMVR4MNZmABP9Q0raCrDJrJ4/vMt81dZqI= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kj57p0fjb-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 30 Jul 2018 11:01:38 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.33) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 30 Jul 2018 14:01:35 -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=U3IAqHuTQI5+fGwBjPHzcpkTcIvEn3WUFGPMfJBQWoY=; b=WUl7pWTa5r8TCrsLyLwpl8uDC6y7rQRy838H+06bVMk2xkAlGRECYzxMfVf12qwkF64IFQqSv+JnedMQTXaLV4L++Sj/wgyj7xntP6sgOjTE73aPMV0wyc8agULVuZf2cLOjXz2Ib5ErrR1QS3BFEQv/6RsX8+YgHM+2Oek+h98= Received: from castle.thefacebook.com (2620:10d:c090:200::6:484b) by SN1PR15MB0175.namprd15.prod.outlook.com (2a01:111:e400:58cf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Mon, 30 Jul 2018 18:01:27 +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 2/3] mm, oom: refactor oom_kill_process() Date: Mon, 30 Jul 2018 11:00:59 -0700 Message-ID: <20180730180100.25079-3-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180730180100.25079-1-guro@fb.com> References: <20180730180100.25079-1-guro@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::6:484b] X-ClientProxiedBy: MWHPR15CA0060.namprd15.prod.outlook.com (2603:10b6:301:4c::22) To SN1PR15MB0175.namprd15.prod.outlook.com (2a01:111:e400:58cf::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a521c10-fc15-4dc1-9807-08d5f64679de X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:SN1PR15MB0175; X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;3:jhpNDoFxuGd2IoyjH20yxjr41KXDy3SpfgItPY71HpQjFhObS0Zzl5WMMFCkWR8T+RxEkOWFohEcvi/YSlckHrFHrBNVS+xaLbOnF2etN+oA3lgxyaimiGKHIO0j78HhW0HSBOD/aY+j/cN0m/gIkfdosaLtse4+AINvyyhTkWapidIJQKZQtj3JtQouW3b+h1+6sNmUb9Gd+vTEvSj3AxwyTxt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etJXxjETG3q7TNEfCmxPY62bqXJSKNtWGtg09Y7aIEB7681UNpaxKp65Rs8TfeXc5nu/4oLC4RjN4m8jhtmAhXuhyma56NPMdPIvn68/X9JnNSxvUV3MxTU2 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)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016);SRVR:SN1PR15MB0175;BCL:0;PCL:0;RULEID:;SRVR:SN1PR15MB0175; X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;4:JYaptTCExKK1T1+XGXN7b+b2CT+TYsY4WBpkaUnuwi8crFmr8Yr8n4TDkg8+FcGhQ1H5icnrSFj4aXBRH89hGCmx7qXd5hz+ouroTcCvKTAtSLxv7t9mA/do/P9WmVV7eNdkAfkXJqIoEW+iPnZSij2brYudGBYWhYfSIDqmgC32i6c7A8qXjHKX0+NUiLD0Oqwj6xai/JUuU+EVTyqKTJsHqLiHF4y0Isu6VMUi5sVznCn9ksYQAs7vyRRIL4WXbkfhJBIXJ8nL0XJnXgB0voDMKOqSo4EOihzWvBP4nWCpPdtJZqfqffAZ0WGlkjZN0VPffreAlubWzb6S4bVFl+Kw57muxlhicLX5c7Gt2ue2YaaA8dT+U5vejTi7LQi2WUO4Q2cDqGN/nH33+RvoPBmvHRyvdYmGyI1vqczkQxo8kyKGUCcZhwT+AOyimmugABUjzPooJEocfYkX483LUoZehoSNe7Uwya+jur7m+Ko= X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(346002)(396003)(39860400002)(376002)(366004)(136003)(189003)(199004)(36756003)(6116002)(8676002)(6486002)(16526019)(6506007)(386003)(186003)(1076002)(86362001)(69596002)(76176011)(52116002)(51416003)(52396003)(81156014)(106356001)(966005)(2351001)(105586002)(97736004)(8936002)(81166006)(305945005)(7736002)(53936002)(6666003)(39060400002)(50226002)(25786009)(53416004)(478600001)(6512007)(6306002)(7416002)(5660300001)(2906002)(6916009)(14444005)(54906003)(2361001)(16586007)(316002)(11346002)(446003)(48376002)(50466002)(47776003)(476003)(4326008)(46003)(68736007)(2616005)(486006)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR15MB0175;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;SN1PR15MB0175;23:mCU3/R42/l/IAvx5XrFX/h2rLO466sG7zxKa+CEAnzF2GX9QzPFebBFk+EjiCLQ0m4nvtugk9m2EI+p3s3AAkiXUKqcfdpRvIxvvS84oxeZkj9usaKn29cu06EMjDazGGHUgQ62hA1YiyG0qt6zcFo4pPCGcumbqzJ6PtPyz1gtDqI7lBs7+vLBMV1h/j6dQQ3AwdMoRvmJVKmqKMtaX04t78jYK6Hz9sMQ7ggL6vXsyNby0edr0Jrz4ZVnztIrbb+NfXybksXYD5TRyRNKd/ZPZnaY6ZWYOAMXlifwhqwJQ9T4IgcjfDaT4lIjFaLE9yZ2e7nz2zzZWA63khTNiFMvpCh7JOU1/eH0k8y62e77h8mgKgXk428NKfEFwKYKE/kaQFqgLx3WuS0TOl+O++mG1Yu7xhRyUa4dmgSib3P4rWuW9e8vGlctI/rZTpcXWRHDlBYkJ58f4/V955qNOD6Mgd7UQcbr0Lbr0G6I/BNnbSoACZSKUPAeZuoZhAWYs2FwCevE2WWev73i7jvR3pXpEgsu3za2gtOIPre4ci0tHZXpLQ4CbTmCqOFak7N2Htig1Kl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nosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;20:VMhAl2E0iIj9Dw+dDdjB//j9etbi6PAhdE4Jr/wc6nd1nAmNpzx2QnVIl+x+E+KBF/zmOhXnkr0VgcUtqci7dXXDT+v+4mZqMsseiMaoFmAqKVKsAQyh0ChLUePNTaoFfTqCuuaFdWNyz52q+2SrhqPOIb7yzKqXUa29fL2hN64= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 18:01:27.9244 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a521c10-fc15-4dc1-9807-08d5f64679de X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR15MB0175 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-30_08:,, 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 Acked-by: Johannes Weiner --- 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 Mon Jul 30 18:01: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: 10549551 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 365E315E2 for ; Mon, 30 Jul 2018 18:01:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 261582A419 for ; Mon, 30 Jul 2018 18:01:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19E712A5FD; Mon, 30 Jul 2018 18:01:57 +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 2357D2A419 for ; Mon, 30 Jul 2018 18:01:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B38A6B026A; Mon, 30 Jul 2018 14:01:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 73CE56B026B; Mon, 30 Jul 2018 14:01:52 -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 591196B026C; Mon, 30 Jul 2018 14:01:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id BA5D76B026A for ; Mon, 30 Jul 2018 14:01:51 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id s18-v6so2658720edr.15 for ; Mon, 30 Jul 2018 11:01:51 -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=jjQDxH19kVIiM6W25t2mvZ6lYn+GWixHhSdAj2O35o0=; b=GEQlWRGjVxGneNvbY8aLOndCLRPKvI1dn/VsKAuYzihuAm76ksP1LJMkm1m6iKcMAg SWKIpXDJVRh6jouwTvH3wX4CkI2iPabNtvAprTD4d2xC/Ivz1hVZWFgE8EOpQeXzvZKo BMthw4lHrVGvs6b0TcqQTHISm+PsldzF49hjDRa6GEpYaRXRG2Jeq0lE8ce8HiFOw74+ gGaj/9VbXDuON4ajk8lnw6ToK2VxpYeUTHMJxlE+BiS1BYWo00UPgudhOCrZ1UbP42n5 /L3+lE7dK5dCeYSdlYduWtFJX/jsmwGdVl5HHxk3aOW4Umr4OIikK6r6Ce0pZM4134Kh OMWA== X-Gm-Message-State: AOUpUlFd3+ea3qNbG9qyPaqCo/+kr4G3XRV6aZW60WX97Kd5Hn14TTP2 n+vvQ1Vz5Psjx4VJe6gxxkfJWR4af/P3ZKEvIc6XjSHnpQvSPAFz0HPtHLjVSXRbVuUP1KXaryj byiYeSfO6sgVOONJRqLoE4BmOcQHkDVuNERzK44CZ2PObXn1zLVGnuloh5QdBbocKrA== X-Received: by 2002:a50:b5a5:: with SMTP id a34-v6mr8931740ede.88.1532973711200; Mon, 30 Jul 2018 11:01:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcMYyOj0Wpi1KtgyKx6qyMF83R9gPPGUjM7rIiU9xN9oH9kDOKyUqd9UASlvHo3IF+xIuhH X-Received: by 2002:a50:b5a5:: with SMTP id a34-v6mr8931699ede.88.1532973710408; Mon, 30 Jul 2018 11:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532973710; cv=none; d=google.com; s=arc-20160816; b=YjAGWismXAgxjBQSxnxkV78htC0etKNhrLPLCgHXZygWSJt2Vw3+5vQ2Yhk2yJNj7k +38cBWMILfduGA/MtSEd6nKkVefN+KsQ5o5jqi9DltRoyr0mYPZX1mGmpofnHFxSiasZ jNKoTVQzYp9gzQvVtc9N2xQ/C2HPmbcXjaSMAd6YOlJ8hjs95lu2tMleR1oQGE84q/b+ AXQFPpQkpMHEvl+tgm0G449z4h1tiue/4wUQkZU/On2xO1n3Y7HQrxCe6gjvNfmB+ytt GcLko5SPnDkBxMWzOISHchfj+fAdX5rZCWBPrs2Vp+crjO8/+zcIj1KGrIW891KN9VPM 9rTA== 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=jjQDxH19kVIiM6W25t2mvZ6lYn+GWixHhSdAj2O35o0=; b=ReLhJKs0xwBnyEjuohJnkndFCvBehwS3XfpmjRmYnZjl5PZx5xU10wlGnsCkAgicAq cEW7shJ1NvlG5pt+3uexC0CUMznuC5RHTG7ZGGR9a6fgr7HKdyWWibCQz/O/4bhfzESR Bb4siYZGst//p+MMqENvZcg4I+TH3MPYv/IUMDxdOqC/FWmx/vipXBvnGVBepPzCvQCT GMqr+lH7lx7D6+EfkTxB8vFeFTJK8WlO9GMXBxH57AUKbnDmU/tF3iwklP/qLvvreOh4 l2b5lKgqiGjo5whZYz3DeI2I2maCoOc0/V7RyDjl6kdrwF4rMjdX8znWzPase9tU7Wha +1dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Ji6nxeAN; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=YSYF4zns; spf=pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17496daedc=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 b15-v6si4944191edm.391.2018.07.30.11.01.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 11:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of prvs=17496daedc=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=Ji6nxeAN; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=YSYF4zns; spf=pass (google.com: domain of prvs=17496daedc=guro@fb.com designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=17496daedc=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 w6UHpdtS030163; Mon, 30 Jul 2018 11:01:40 -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=jjQDxH19kVIiM6W25t2mvZ6lYn+GWixHhSdAj2O35o0=; b=Ji6nxeANwQld9btMYdAobQsibRZfxY6qHjnm9Ufdcq1/eZu1qjOddNGeJ9hGWkVgcfYc /W18QdI79CIH93dKh1D+NTx7mUXywfBQuLR4mOJGknJtanNZSn7dwnIlJ2+MOlRdry7Q CRAohNxbVVUP0cv3suki6+ZAqHeA2UIlIgs= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0b-00082601.pphosted.com with ESMTP id 2kj6yy040v-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 30 Jul 2018 11:01:39 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.25) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 30 Jul 2018 14:01:37 -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=jjQDxH19kVIiM6W25t2mvZ6lYn+GWixHhSdAj2O35o0=; b=YSYF4znsOJXSuq6eb7RA3Z9R+qDHczs8/3N/oGH2FP3kHmXSDhjlxBuSQS6nM8Xtglteo2kFjaOTBg1UM9D2QD2vHbbpLw0l22CIFuIYqWFLD7eenVfcDyu6wQ6L7GDKjGLV/AqWR/ZBV4AFtBHat2Xzzy9bHIC62/12afdmZAc= Received: from castle.thefacebook.com (2620:10d:c090:200::6:484b) by SN1PR15MB0175.namprd15.prod.outlook.com (2a01:111:e400:58cf::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Mon, 30 Jul 2018 18:01:33 +0000 From: Roman Gushchin To: CC: Michal Hocko , Johannes Weiner , David Rientjes , Tetsuo Handa , Tejun Heo , , , Roman Gushchin Subject: [PATCH 3/3] mm, oom: introduce memory.oom.group Date: Mon, 30 Jul 2018 11:01:00 -0700 Message-ID: <20180730180100.25079-4-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180730180100.25079-1-guro@fb.com> References: <20180730180100.25079-1-guro@fb.com> MIME-Version: 1.0 X-Originating-IP: [2620:10d:c090:200::6:484b] X-ClientProxiedBy: MWHPR15CA0060.namprd15.prod.outlook.com (2603:10b6:301:4c::22) To SN1PR15MB0175.namprd15.prod.outlook.com (2a01:111:e400:58cf::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 547c7b7a-b56c-418b-65aa-08d5f6467d74 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:SN1PR15MB0175; X-Microsoft-Exchange-Diagnostics: 1;SN1PR15MB0175;3:zgufgtInyxTjXDizR5/h+XZLEgl3EU3Pb0uCd4ESW+otWBrKVje91k8pwK+gD2riOag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hUEG/MNbVwxWlodk8Y080MDa6p/h8LNiyvws/iCQWoSb3u/f8sAXfU/I1lj4ZQA1U9uIS81s0fHkFP14QUAyZUmGRfpP3BLhVgRX64tDcrpuzC2F6nS8AY63N0Zb++zy5YW6qrQQ90EzDE4p/hqAj5j5mHl1Wa25fIEBhkjxZ4GqvliNmfdtTgwzLVR9zUbr/VUldln9U0A372rkt79ZppmaX9LGmyqPzeDgCVZyrb9M7A2LNo43pEacYAz5Nnv2YQsrSlkLilZnnPqV5ngMiZ2qPCuvByjTpfJ;4:Kjowog2MJ/a5HzVF1nIbjZZnoMbE9zdMXMdciyGk4RKmvjT/hwQJ+V5PIiWkA5yiDDO7hrk4wsY2kIacwh8x++QYDzHKquTMSKHC2MkuMfJuR4ePy1BZX/aPHOHovBh7KuUDVNQ7OLmxDGiufgIMy7E37TC2kTpQYVhAgy6BVor2RfWOZj0bhMg43cKQVQTphSonap37HctTGU8vs9WT5I7vUcJJ77jSzm7E3TTMheLssQt40/+BaR+R/BPKpUEYZUoZpGPiWWMa2JMqeC6Th9Fd/EV1eI5WssPf8CGzpG06Ac1wPMhW3A61CHOWCA+0nWcLd0aVRERVX9pC+4ly2Qg8Ag74nyeo13yiz+t4nb3N2J5Yzn8w1Rf1sjDowd8HVqqJizsW9+a3uuwnJt5vGp2VL1Qn5bVHDUN4sZ 6SGZM= 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)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016);SRVR:SN1PR15MB0175;BCL:0;PCL:0;RULEID:;SRVR:SN1PR15MB0175; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(346002)(396003)(39860400002)(376002)(366004)(136003)(189003)(199004)(57704003)(36756003)(6116002)(8676002)(6486002)(16526019)(6506007)(386003)(186003)(1076002)(86362001)(69596002)(76176011)(52116002)(51416003)(52396003)(81156014)(106356001)(2351001)(105586002)(97736004)(8936002)(81166006)(305945005)(7736002)(53936002)(6666003)(50226002)(25786009)(53416004)(478600001)(6512007)(5660300001)(2906002)(6916009)(14444005)(54906003)(2361001)(16586007)(316002)(11346002)(446003)(48376002)(50466002)(47776003)(476003)(4326008)(46003)(68736007)(2616005)(486006)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR15MB0175;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;SN1PR15MB0175;23:o4r5UjjHWzzC695YOvuCiEuK8UK7ZY942zzLMKiyu5bHuENhV/VzUrdiue4TBnFW+sPyDsjzo4BYMSVuPHZjJTa8w7+fzozgddgQB7UxEkHTaT2CIg4PAyjiIsM51AjovMwuceX5N5lJ7oX2HwCc5zVlUsXFfwjH3kP+yxmedyFgNMSpBB9c1o3kBqcEwug47vMz0+lpROh2ImeFCNtS8aoDikaldMguUsIuj1gH1IN7M4rLICqD2FWwq/RE5dBeleIw1hgReBH7Swc0veDo/Mc3zwwn0Krk2kihD/R7K51Q1nb3HP9jQzDqlTYEDtKgw3Ft2ZY27iOORGFmRuL78HaPnsO5ia/3seiEN/21xbNFuQgN9NOTuxHHw4l+LDovcTGoI5ecp6KKHeGGbEPVIDDQyZVJeM3bxnWAGyij0rghBDXY8vCuTkam8zd6iZfP4sSLkvxhyOdJRTP3kVqLK9Qttf9rv/OCuSnoIifqsWeSobPPT6O+haq65UptPwz1hsNFgTHQ1nJb4/K07XnkqxMA/LAt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-Exchange-Diagnostics: 1;SN1PR15MB0175;20:13HiqwHM4zJxqVcU5T/02cMpCKodW5WqmYC0nghDV1p96OkU8tYWv0dDE9W4N3WdKXaRPZUEl7NnqHIcIkwHCa1Oxe704SBLVUoM59EtrHwfEjxwdCZUVXUSnBq0sxHKPlS4dmg8uRM2o0TXaii/TRSo1I2k1uPdwX+3Lzp3Hn4= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 18:01:33.6401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 547c7b7a-b56c-418b-65aa-08d5f6467d74 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR15MB0175 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-30_08:,, 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 a single unit by the OOM killer. If set, the cgroup and its descendants 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 Cc: Michal Hocko Cc: Johannes Weiner Cc: David Rientjes Cc: Tetsuo Handa Cc: Tejun Heo Acked-by: Michal Hocko Acked-by: Johannes Weiner --- Documentation/admin-guide/cgroup-v2.rst | 16 +++++++ include/linux/memcontrol.h | 13 +++++ mm/memcontrol.c | 84 +++++++++++++++++++++++++++++++++ mm/oom_kill.c | 29 ++++++++++++ 4 files changed, 142 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 8a2c52d5c53b..f11de1b78cfc 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1069,6 +1069,22 @@ 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 a single + unit by the OOM killer. If set, the cgroup and its descendants + 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..05c9c867a3ab 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,8 @@ 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); #ifdef CONFIG_MEMCG_SWAP extern int do_swap_account; @@ -951,6 +958,12 @@ 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 unsigned long memcg_page_state(struct mem_cgroup *memcg, int idx) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c0280b3143e..ade832571091 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1577,6 +1577,53 @@ 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. + */ +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 || 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; +} + /** * lock_page_memcg - lock a page->mem_cgroup binding * @page: the page @@ -5328,6 +5375,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 +5447,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..08f30ed5abed 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,22 @@ 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_scan_tasks(oom_group, oom_kill_memcg_member, NULL); + mem_cgroup_put(oom_group); + } } /*