Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp218295imm; Tue, 14 Aug 2018 17:38:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwrMxK5fBNEYPVcYF/GcdcsqIpTPpU0H8hD1gGPm5cuOa9p6sjjCgVdS3i6jT5tUZc7mWmU X-Received: by 2002:a62:e511:: with SMTP id n17-v6mr25839740pff.210.1534293483380; Tue, 14 Aug 2018 17:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534293483; cv=none; d=google.com; s=arc-20160816; b=Pys+KU34R+T0utkX+Yq4hktX7XcebL6v00pXVgBdcKCDNmQuc8S7Zvy9q4LcOf4/Yh 3QWY4BVjXpO7W2o8QCgQ75EA1/I/OarqhBpLqSzvVxgGxhYPz24MHVhwS3eRtR2HaFMB EHfDq4pLJposOZ3p27OxBHjwWam5L9hDxG6fGtIpcvSRMI03HBIf3Yxm4R/RE5SDBCpI IkBgWS8rw5nmM1B6dZBp9OPaL0PQHhuKLzRZCywHD9D8m6O4LHUbNeOuHkbjqPk5rz68 TaY7oG6n8PrUB6yP20HkMswCh/v/SN0hf5F3L/jrCmRkYwmijRoU7KF0FgbPVEvdmleo xyHQ== 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=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=FIAMQnXViEaGGmupwoa+7EfyG/CG2T4WLakVDcR2zsik8JiAfS6ru7j/FCcVGM3t0E c7HNz01zBandMlZqfwLbCI183luMt2PADZCz2HsxrQvNQdnFofwfmZiIyQok8dnGKG+/ fDyg7PO+uWIyWHjJmJNe0K1ftvu5v5CGx7vwVUi7BE9Tbow3YerBUJGuqD5SlqQ8fFKC 9VAfkxF1VC4HardBOl9tXs0UgwZtZf0Po67hVxv5afcZHZB0Z9yFmCN5ZKB0AlvaEYD0 HoLRH73bQ8leunVNFmZ0Qnc+sD4/SUZ3lmdzzb7OCaAkxzwIwIwzQLopDR+hTNVKykKE Yijw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=lg9y5jYy; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XwTPYzfV; 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 e10-v6si20360199pln.161.2018.08.14.17.37.46; Tue, 14 Aug 2018 17:38:03 -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=lg9y5jYy; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=XwTPYzfV; 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 S1728426AbeHOD0c (ORCPT + 99 others); Tue, 14 Aug 2018 23:26:32 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:35834 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbeHOD0c (ORCPT ); Tue, 14 Aug 2018 23:26:32 -0400 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7F0UOna028091; Tue, 14 Aug 2018 17:36:45 -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=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=lg9y5jYyHQURsMpjlHM/eNSGuBXqflp3SMMpZ/hF6NXnwwQjzDvpAICHml4w1O09mNn+ 9DR1ntzKkNteyStGrGbu+tA4P2Am1k+7EMpu0o6kFvchWx6yXaEN4p6/fZfyg/4rAGKh 0HGSpHrXniZhygfKa3HRjmaZkgxPE9vs6PQ= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2kv6hqgg7w-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 14 Aug 2018 17:36:45 -0700 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.20) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 14 Aug 2018 17:36:43 -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=eesPrDvOqeXhMz2Kka4CiC+3KQRHS0oUCbgFaiOyA2I=; b=XwTPYzfVJkqTd9zEHQE8MPRh6PwxAVe9/nQSMv6OF+y7kNvujKmFmCrRjVREy4h7ztByEgPWcl9DFReazpQ3CLEaxvwihOXF+/7ItGeEP8Zr3ygNOLy2CRQzkw7tzaCwimI2nX4pXDnKEu0qR0fEf+eRlsLkYS8e2+sbdI0iag4= Received: from castle.thefacebook.com (2620:10d:c090:200::7:b884) by CY1PR15MB0169.namprd15.prod.outlook.com (2a01:111:e400:58bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.19; Wed, 15 Aug 2018 00:36:41 +0000 From: Roman Gushchin To: CC: , , Roman Gushchin , Johannes Weiner , Michal Hocko , Konstantin Khlebnikov , Tejun Heo Subject: [RFC PATCH 2/2] mm: drain memcg stocks on css offlining Date: Tue, 14 Aug 2018 17:36:20 -0700 Message-ID: <20180815003620.15678-2-guro@fb.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180815003620.15678-1-guro@fb.com> References: <20180815003620.15678-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c090:200::7:b884] X-ClientProxiedBy: MWHPR19CA0006.namprd19.prod.outlook.com (2603:10b6:300:d4::16) To CY1PR15MB0169.namprd15.prod.outlook.com (2a01:111:e400:58bb::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d6f46611-207b-4f65-0590-08d602472b88 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:CY1PR15MB0169; X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;3:UI46yOKmfkpe/1meHUV6jztQpakFTB7S868xTeM/dM2ON1Ozzdn48vQCtNV1qO0KEoBHCf8GLbn52n7QoZ4md8Hhf+p0EVRhAQMf4Jjf3DFRHoQAIloxikda12pubGoqmcVQwIoFVVOlh4znWs8OYIW90E2b9tKi67MJQgx5roeOlSCCzzMLl0gZYKaj4EaK7qRP009vXBJ3yQnFXTKZ27KQGe4YcgcpBBSCSEVx+VBJMJLU1NuWc1CGsZkphpI5;25:etb9QUBEsFrmnsF5eFjbLKdrDslScAbPgtc+e8V6HcWiNk5VTbbhR1zwEJ+Dj/HRvZ7VpnWj0m5rGksturpqX2M2mTI+GKYBU9v9NnhQkF+GH9CZLRWLGv9xwkVFIYoixpsLwXnhIDTcflAFupKQe5qdkneyWTirwnK4DJL49JFIS2c0lq3ylJzfm5y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wAsNvDqJkyct0FhoTt7ZnfIdiz7KA8Sna1Q7Er6nz8D1777+ZKgYQWxgL1AIPLrSdM9ohDZdEpmQ05lFqPLxvEZnH+xIBgOqqEhpZSGAwqbTPyyFDDRGxPY+s0OMAL+oU27sm1KSyrjXr0iH76M7H1gRaRigAItBz0W0zjIbdoVNT68rpCoW3QvylQwE2kwvLp1FZpfKSrG1HeKZ1sUhnM90HDhcSTtjZh2lcIGTvePO6ChhTqHXQ6LPXVm2LYWhcdTpbJhcHAP9lAjeIcOl3YgVNfSGEE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(67672495146484); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(11241501184)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:CY1PR15MB0169;BCL:0;PCL:0;RULEID:;SRVR:CY1PR15MB0169; X-Forefront-PRVS: 07658B8EA3 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(346002)(376002)(366004)(39860400002)(136003)(199004)(189003)(316002)(2906002)(52396003)(54906003)(105586002)(4326008)(39060400002)(69596002)(51416003)(25786009)(16586007)(53416004)(76176011)(52116002)(36756003)(305945005)(50466002)(7736002)(106356001)(48376002)(2361001)(97736004)(68736007)(8676002)(81166006)(81156014)(6512007)(6486002)(53936002)(46003)(8936002)(2616005)(486006)(476003)(386003)(446003)(11346002)(6506007)(186003)(1076002)(86362001)(6116002)(2351001)(6916009)(6666003)(47776003)(5660300001)(217873002)(478600001)(16526019)(50226002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR15MB0169;H:castle.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;CY1PR15MB0169;23:UY4HuPUJKdKcLYQjpc56eGtqA9hoQFrwYHtlFvWa/?= =?us-ascii?Q?UF0Ycraq6GR+pIRpHRwVMXzZIVJPRgYQlGS+dgdzVX4GYZkae2qH8WUPX19m?= =?us-ascii?Q?6V8Zzl4skoGV+3IXjYRkmpvsLxP1AjNbOb1XNgQb5xXzk3kTy9D2UK9YI2V/?= =?us-ascii?Q?hLf6m/mZn2SMPUMC+IM2z1RcXeTmDI4n0k6SBUmlL6UM6JiWx88PcS+fnm8r?= =?us-ascii?Q?BkleknfBwYSO8tBDXaGFB9DdIwCtxNw72I28cPSAAjdugzkYGGa/wx3FCXE/?= =?us-ascii?Q?rSTjUEjyifrjkLqbyo+tvgIOo+BVlx365PHVgOEezyAGWXWurVZ1etEgKRV5?= =?us-ascii?Q?dJuiTDHoGOV6tE4e2oVKYybP9baH+CtJDvvLVDt7E1Ai0vRcoGa7WvYfeAVM?= =?us-ascii?Q?QcOQo+3Qj/ubwLWUcgy+PvZfvi2iwWb/ed8C2qefOI4KT+SeDwdGq1G3rHGx?= =?us-ascii?Q?3R/geMBJYEBgAatWr+wriwCEBygBJXXxxO91xW9UnE5XabTrU2CR5Oo6oZp7?= =?us-ascii?Q?MDQvWaOuyImccJG7ZwsJThehCvendKy8h4EFcTXPF69PFcHCKB4rndFTEuAT?= =?us-ascii?Q?FFYJYYax+AgLOx0UqILE0IH9nLVrbaoQCQfsQpxH6fQvN3WVkVMuhR/gW7Zm?= =?us-ascii?Q?mXm4zhGunVUExQHWymz/XInsePf7+jGZTxumkka8hpmlUk6/zhKuMwbQoNT8?= =?us-ascii?Q?nZgdeF3C/CgYE8fh9L4vv0gSdTqe9lTrO14wayaasC2CS637i4cCi7l7iz/x?= =?us-ascii?Q?MAHzGTplag3NofR3bXD0nB+pRuff4dM9plZnA9kdb7BEoqjTlYNmlCyGlNhB?= =?us-ascii?Q?J5k7HVSeMsa4Mbo8OlL+0Ai4b9tBNiq2u8vMI4N8KYUxyGZmYQTpcNXq7XTA?= =?us-ascii?Q?zKX6Kphi2K0d+HiIVXlEntqqa9cOfrA7E74elAi8792e8fhhNm6CPFSBRsdk?= =?us-ascii?Q?K2oi3wLtxFN0Yux143FJqIl2RGlMVNrrm65ip5d2uolsMOUclbVCGybbBlPP?= =?us-ascii?Q?4LCFfwshYoGWbq2V96VBnfLDNpLIdR9xCHDAGCEdaY0aP0mYwd2UBZ4cQYU+?= =?us-ascii?Q?eW+Nl8imb8hall+lJiTMyjHbRZJWMQx524mF0pSlYB5oyOATVmSIvp8jFiQZ?= =?us-ascii?Q?BaBDz8sRCixESrmlfQjBRJTfrIuJLg0SFQlptfBh0GkqErLeEP4lg+mN1hrE?= =?us-ascii?Q?OEPthSPzsnJgm4rV8O6dqaBE2FqMuKK+egOjrg/GANQH6nK+dGXCwvsRx9DC?= =?us-ascii?Q?KyIK7xKLFv2y+azr5ldPGrgcB6osp3j60bM2U3UX21aWO7IVKVj962P2rrUQ?= =?us-ascii?Q?vgUKfqpremz4w1h0E0sbOs=3D?= X-Microsoft-Antispam-Message-Info: lNFA9jVecFSvQLY97xe/I3ObTih7Qk+RN0I7SzmzwsT3CgDpZnt7S62ES3+u+9EperH4wHcYTl5qw1kd19TUQzIHNX8GnD3Qwv0AmOl1VUb6dUp75aREzgiDHsxGpVapMniFK8JkqjadPQOWCeWdNIJWtAhD4tG7PajulrUoqCWkVQmiSSIM4NS6xa0zrDCzsXZoCshf9YgAjjtCUsVdQhNgMU/Xrn96POEgfjJNr9YBBq8h3HAcMb2CuYU4/2JTMvEEDGHupX40O0wAY+b5jmgrzFqkiwjB1K5gsyER7oPTsQdFWVchaJIpKJd7Sjgcsu0wPKnoroypOXMBRym8C/1sXotY1KTpdQcA9jLpJgE= X-Microsoft-Exchange-Diagnostics: 1;CY1PR15MB0169;6:+8mMtTD5r8Io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VOurejgndA9qVm7tC+QJl9dL+CfXVOg5g56zq3OXAmjxlsEYcSQkaDb+yIQ7nR7HC95aoIpo4jgo= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2018 00:36:41.0302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6f46611-207b-4f65-0590-08d602472b88 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR15MB0169 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-14_12:,, 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 Cc: Johannes Weiner Cc: Michal Hocko 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 4e3c1315b1de..cfb64b5b9957 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4575,6 +4575,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.14.4