Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp87747imm; Tue, 21 Aug 2018 15:08:51 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw3RNNgm/U9dwhmTHE7vTYVG3t3E8acChpa/O90gMAQY7KXL6PYtWyoWFMqAwp5+WGCqRQs X-Received: by 2002:a62:e813:: with SMTP id c19-v6mr54614052pfi.124.1534889331767; Tue, 21 Aug 2018 15:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534889331; cv=none; d=google.com; s=arc-20160816; b=HINMrpwmyiBZOFGDIxPrWYSbbhSWF2TUIKmBq2qfmsYm7aRMYcCUzGbnjLShzF+jnO 4pGQbdT6UnyKIv+Sfn7ur+9fCg/1Zuu818dtRJUiyTkt3W/7Qm7RdIxvheNIbMp0TzJ/ uhR1FtR8knFgNngX1Jgw2jSBowtmpGQ1r0oBpCM+ltt3+vu3tykMzGJdiUp+nuOZIYdD e40v6PpMrfTvQ9qnmFmzsY3+yqr1ME/gXpFCKjWiX1pQ5DCzWBT+tnHxEssSdhB1pYgP o3zJ59jvcTsD7UT7QnMo1A4aFPAYtPb0OoI5Xm1uPBTclp2WFFZTOrlkBMIDhsfxYRnU Pm4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :arc-authentication-results; bh=zxLfJma5W6+QeF7kJqnEsF/bgjjJ2NJLkMmgfAY0Ecw=; b=ZMxj5dz/m/5YGK40mVM0YqOGTVncd3GuBCBH3NbElJiQhbOOLbTuRIM8S4S7HCXQhK 4RWYjXl7C7SBjIzmGjlMyPPw/karwUCQucdravVWuRXRdAEIRZApxAIu92eprsibGO/h BNT60WCbMYgkgVyfC7vurUsFtvdOAI2V5btQ5OzmCq4/1d0tlPzfVQsMPv7KCKaM35wD yFaiH9QbuI5BcYn4RBzzcP+OeIvESpsxIwUA58A0D9MybGFb1VE9iSwkWm0Ss94NgzBR ZsjoPXB+p7yO8wwvI7fYEvorKM+hJ4evve4WcYxoxlJklyscpAJ9ZwStll7Dy18xNaGz 3YCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Oi7kisRU; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=PQBAuvZE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4-v6si13307665plr.213.2018.08.21.15.08.36; Tue, 21 Aug 2018 15:08:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=Oi7kisRU; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=PQBAuvZE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727562AbeHVA60 (ORCPT + 99 others); Tue, 21 Aug 2018 20:58:26 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:50192 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbeHVA6Z (ORCPT ); Tue, 21 Aug 2018 20:58:25 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7LLYGVi010571; Tue, 21 Aug 2018 14:36:26 -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=zxLfJma5W6+QeF7kJqnEsF/bgjjJ2NJLkMmgfAY0Ecw=; b=Oi7kisRU44EBMcHZZOg9Q+dAI7wT9U+eT1qWmZJzYw6PaBShjtyb+3Sk6MjzCqAql0Xo IT4QiY6MDQv1s3yMFN7VAtT2sffIN/LQ4Z8rbW5/6gZ6yxjPB4Zd66TnpR1crpjCz2Wl iqvESvmmbkVGDjQ/Qdbzp8SwUUVoh29whmw= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2m0ssj05p6-10 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 21 Aug 2018 14:36:26 -0700 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.14) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 21 Aug 2018 14:36:20 -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=zxLfJma5W6+QeF7kJqnEsF/bgjjJ2NJLkMmgfAY0Ecw=; b=PQBAuvZE11i21vm1cwg9E4vHPd93gMtSnq4ssVqc/rDUC2qNvHtgxd7oBAiGyTwJ3MtuizTkQhJ5+/K85Akon5W3WFA4Er4Y7jyFrlZwn17sm42jGKt+L02u5U4ti49U+xzltsPaK7kPqVWGaGNsdoTn2UJNyvS5qxG6Jl5bTHU= Received: from tower.thefacebook.com (2620:10d:c090:200::7:b0bf) by BY2PR15MB0166.namprd15.prod.outlook.com (2a01:111:e400:58e0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Tue, 21 Aug 2018 21:36:16 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Johannes Weiner , Konstantin Khlebnikov , Tejun Heo Subject: [PATCH v2 2/3] mm: drain memcg stocks on css offlining Date: Tue, 21 Aug 2018 14:35:58 -0700 Message-ID: <20180821213559.14694-2-guro@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180821213559.14694-1-guro@fb.com> References: <20180821213559.14694-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c090:200::7:b0bf] X-ClientProxiedBy: MWHPR1301CA0004.namprd13.prod.outlook.com (2603:10b6:301:29::17) To BY2PR15MB0166.namprd15.prod.outlook.com (2a01:111:e400:58e0::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40419c43-56d2-49ee-f824-08d607ae207c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:BY2PR15MB0166; X-Microsoft-Exchange-Diagnostics: 1;BY2PR15MB0166;3:TBL0qJTkjZiWFKU7w565iphd9wDD/jpRMM8XT/T5YoDaOLV2j0Jwm2uvpaXazPwhh0EAiM7TYJ8K5h+82/B49QzyZAf4dukl6hzNpiTk5Ic5n47GNG1b/fBY1nlmqlESSlOx5+A0jg9js0eoCklIJTLQEYF6Ty0gluDqHTzaJ8TKO5SzK+1qXdZvkvBjcVjW3WKIzOo5jTQIs7kxThQMrm5Kx4Ku6YztmCVkbd1gr1oU0jNBt5e1bi9oeUfZwFDK;25:2Oj7blzgBNaTQz3a472uDfIr4SuDLuGU7waAnlewMh0NniB+DEU1CVj6rR039ndi7KvHG81YL2yTOXaA+X9gBUYFQH3IuYzgWVjPrq+aE2MsKOQwz4/PVRpGJAm2zOoIpyCINiwgy59bJZNKkWFZ6s9Mqs42WAcWFxZWR2N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POYwXxISSnoNFsKxOsD7zVbVtrN5BLYbsMIFH1hvD7rknUrfmieXOQASV7bpgp0vZSg3Atk8V9KtzgMedft8vCMYoh9wYn1oCVP25x3QAlNQmqeN8zckR6yiHxGpTflIGSyMKbw92J044nOYvkKA846buQOB94Eup6nSGZr9k9O564sflXEOSmeWI0I1hfKl4e+d3Z48nAnqXaMj1ZxlFYVjWlPuRPcXxz9Z81lSdjz3zjuklkSpnttGLLRIsBERAVsjOI1sv5nQvZmzl/UKvGdecvBGoy0gCjwZinbNPN06TPsBpWGKmWMW7i47CT597o2jhBYxFp1ZOAk8lWGS8BOwbeJ4g= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(67672495146484)(211936372134217)(153496737603132); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(93006095)(93001095)(3002001)(10201501046)(3231311)(11241501184)(944501410)(52105095)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:BY2PR15MB0166;BCL:0;PCL:0;RULEID:;SRVR:BY2PR15MB0166; X-Forefront-PRVS: 0771670921 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(346002)(136003)(376002)(39860400002)(396003)(366004)(199004)(189003)(53936002)(68736007)(39060400002)(50226002)(8936002)(25786009)(1076002)(2906002)(6116002)(4326008)(476003)(486006)(86362001)(16526019)(97736004)(6506007)(186003)(386003)(46003)(2361001)(478600001)(105586002)(48376002)(50466002)(54906003)(446003)(106356001)(6486002)(2351001)(2616005)(11346002)(6916009)(76176011)(52396003)(305945005)(6512007)(8676002)(53416004)(69596002)(36756003)(16586007)(81156014)(47776003)(81166006)(316002)(52116002)(5660300001)(6666003)(7736002)(51416003)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR15MB0166;H:tower.thefacebook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: fb.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR15MB0166;23:rFusLMPsguwOOA2ZTbxEEV+B6UIijFRTnsNwcZnMR?= =?us-ascii?Q?/5dL9RFF/cax+ECy3ZmWEQmxmZqznJIlUdEVZ/0eCi8WqjNiLWR8aRZ6AvjP?= =?us-ascii?Q?1pMjwXg+qNiBK5e/PeULaNSnKqHTIGGdbaJqGlqDgimfF84qTKUqMjdaui2y?= =?us-ascii?Q?hqdxNBF0IZBa2S2KGmLh9x0FwfPgk/FctI0GuSoHfgP05bJofN5p/kSHW6K9?= =?us-ascii?Q?ezawnf9/fj6nW7Sj4FSp6b12RMF74bIGefoTYDbd1Thszc18h7HpETHB17KB?= =?us-ascii?Q?Jb4tZWhbGFuWkHmakNzTArpX01Xun2YGcjjwQ7mj/LNBLPgo7JA59Tafx5qo?= =?us-ascii?Q?wXENIzsoulAEASdrcO0aZUcRiAYIomZS4MZaDhIvlPYd6UZDytnJGEwa9Jbs?= =?us-ascii?Q?eX9zszuB1cyljHvCaEeBbXP9xivcKQPRK2orEcgJgM30BC97+/6Y0IaHqupO?= =?us-ascii?Q?XmBGlf2gWXFy92k7TsUwI8hje5CqGj7AkdDPkW8oT0vncRPaZkSpvfd+8dMj?= =?us-ascii?Q?OQZ++WkRKqGtlmPwLxVxJgttE2IqTh1TbGZOs2Uee5KymiyhmZjJ8GCe23ye?= =?us-ascii?Q?yiD9Pin60pTH/Kheck4MGh0UL/pW7+Wl4WQa+9/YN+lzgc8LaAq3UyrvI7UD?= =?us-ascii?Q?3/cv+H1o/qhEKDCyEbOJtVBahU/AuKfta2ncPMSuIhNGZy071kjIqUQERb1l?= =?us-ascii?Q?SeqEFz+pnfqccYIw5se/hlXeUB8z0V8AuCS9pEjYn0w1iXygW2lpxbwL7xGy?= =?us-ascii?Q?ZbZwszZSfWbe/WhiUdQMsSt9ovyYlLuEq04YNeXY5i3/UpuygWVWOZ1ANMwg?= =?us-ascii?Q?+Hc3OROnzVVFZaISoWPS89uhyidz29yw0i3QqD5DExOYRhFgxwKmxfbEgT0i?= =?us-ascii?Q?wFJeC2xj6LHBC5VSKOgIb4WBDLZPMosUMOtolewLBT7F7MbXOph8ZH+TKZHT?= =?us-ascii?Q?sqZFLagcUrBBA6XnCZke6VrB4+sryDiMRY5sy9zuTWOv3fn/WT8GSgIg12aw?= =?us-ascii?Q?0HJFKgQsOt/Qs5/Kr9RCpG7ZAJxek+XhYE10ttZjMBTCh6N0FXFhwYC3IKW9?= =?us-ascii?Q?UH03sjtHLWFwL2E6nR3mvgW0QabKdYF+eCzRrSha3x0XVm6pjcO324ap5dDZ?= =?us-ascii?Q?EBSG1DdYjC4p+RTNvuyCJjTYRUFl4BQuMPUzV28A5jtWC336WpxFpitPJ6uo?= =?us-ascii?Q?ntTRnwtgSJMd42EojiO2BW9O7GllA9C4irsnx+HfUjalD720czDGTd6KYtM+?= =?us-ascii?Q?a0e97/xF27mfNs99tq/FnJX1HG5k2DxC+QIM16++acpl3COeCfA3X8VUaC1Q?= =?us-ascii?B?dz09?= X-Microsoft-Antispam-Message-Info: kr8NafbeI82blmvsxo/yRtCuWkiSdENdFZcJBrhKQ493F4+PZ2VF1t0WqFPdk6/TxXxTU8rerXcJ/0t171e70/4vo/qNGimLJxq0I3oSM5M5//ADC2LbSG7TgSHRGNeOdqIE6EQ/YkO52olhe7wzueAlxUECD3Kgu3lONQYiutQ1mexq0zeyKlg4boICIwflN19S2FD+9mwUBgsQ/Eis8sOvFI5CQkdeqa/iqQOi6Tnd6mDJTqw0O0gJnHiUDs6O7EPrUw1uNASET/a/WTdmOpLBkkL/TBIdVi+BrWFlgUsFT6GnkOI30UV+Jeo+Sew2qbzYojDaSKg66QvA474e7teO0B3O08YB7uSj+hT42J8= X-Microsoft-Exchange-Diagnostics: 1;BY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NyLFoiqoKkI8NZMELMhPRcgWWqK3GQ+ssTCUX2wo2kMe1qDBGCxs+PHOCwXYnLH5g4FL+TRBWqiUAbVgFsvOyhE= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2018 21:36:16.5581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40419c43-56d2-49ee-f824-08d607ae207c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR15MB0166 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-21_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memcg charge is batched using per-cpu stocks, so an offline memcg can be pinned by a cached charge up to a moment, when a process belonging to some other cgroup will charge some memory on the same cpu. In other words, cached charges can prevent a memory cgroup from being reclaimed for some time, without any clear need. Let's optimize it by explicit draining of all stocks on css offlining. As draining is performed asynchronously, and is skipped if any parallel draining is happening, it's cheap. Signed-off-by: Roman Gushchin Reviewed-by: Shakeel Butt Acked-by: Michal Hocko Cc: Johannes Weiner Cc: Konstantin Khlebnikov Cc: Tejun Heo --- mm/memcontrol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6a921890739f..c2a254f74f30 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4518,6 +4518,8 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) memcg_offline_kmem(memcg); wb_memcg_offline(memcg); + drain_all_stock(memcg); + mem_cgroup_id_put(memcg); } -- 2.17.1