Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp81683imm; Wed, 29 Aug 2018 14:34:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbWc6mf8bcPBTBZgkSMpmSGSZ8xtIwUtNH5qcZqs69qaiTpXVagi2b1Ey+8swjgDIdtwVke X-Received: by 2002:a17:902:585:: with SMTP id f5-v6mr7542460plf.7.1535578453534; Wed, 29 Aug 2018 14:34:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535578453; cv=none; d=google.com; s=arc-20160816; b=LbVi7zvudATTCGaIKZxqUq02Ow9sxKUYktVlhYbp0Pag5vpkRIapjOdQf5j1vPUSpJ NAaNvbcEUT2/PnyobnBPmgoTty7m2yv6+AxLM2CHhI+ewODh9av+mu5GputNNhhz1Kwg YmhfVZv94raDWC7Aq4ShH36r0RTChyC+oJfNZHrjVknkP+LkUnfaCcJLuKOYQa6IsAPj rCG9qrlT722rlEwKKfpzebrz/48AxzOXWBJ5ngmrGE1BKDELHfAN6K6nd4xof5irVfFK Ihh7QjNDRDyoaHHaaktRTH/eyKUZLa5QuCcFF0+UexQX3Yvw1TDqu4HhW3larwmRRVFR 13QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=CphjVue2o3o17XWYVNM0JlnFGUQbbef4ItukWd4EagA=; b=sDoeOBmQCOlhyCfDUE/UaE8FjchwSduZHeWqEF1dimUjZls5mqiHuFE6jgXzYLWXoY h60UEjmDshvZB95ifrF+KNF+xt4EP+bKh7d5f1cOgqbQ4nRIsjY2UWHMUN7e7diKNVGG 7kkakJYun3qcOZJ8rkJmkJJ2FXh3rOoCanjo7O6/GFsa2yG2N+xQJHbBBErdC/ti6qQJ JNCp37pmwRaXKf1pjKtLW+zg337j3DjumHlSooJ/wMze7Zd4v47LXlyN80QyyoqeOn+p FbIczs9C4yW8+qzvWJmx8kaqxmc3yL5Doqxco8igMRDBCyxh8dceMu1aPEOp26NAqTFk zA1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LXF4iuLU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5-v6si5182979pfb.104.2018.08.29.14.33.34; Wed, 29 Aug 2018 14:34:13 -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=@google.com header.s=20161025 header.b=LXF4iuLU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728247AbeH3B3P (ORCPT + 99 others); Wed, 29 Aug 2018 21:29:15 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:36720 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727324AbeH3B3P (ORCPT ); Wed, 29 Aug 2018 21:29:15 -0400 Received: by mail-yb0-f195.google.com with SMTP id d34-v6so2610572yba.3 for ; Wed, 29 Aug 2018 14:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CphjVue2o3o17XWYVNM0JlnFGUQbbef4ItukWd4EagA=; b=LXF4iuLUICRShq7V3mEYu8AsOOAIal4SlKY7nSH99BYDFv1eTUjkeDQbbOi6UlkT1i xJlAAnb7FC4n3Z4NM3sqITYHGg5qQ/3gLaH5OzyKaHD4Gq6t74xqHDGRgUhUkrhnP7Mb d4JpCeuZTydK83HiRUstP2h3Z3d6F2oo5c0Bkl/L3dfT2UQmOZgAljHa/ZbCrCsdcJ7L 4YlJWUVWgmO/s/VG+Ddt8YKIMkjeW153z8icfGDC9LnbPBO9OzC3z3eGd7tcca2ObLl2 F3wa0mt0baUNPqeQidV+SzCTXczzMcAn9GhdHd1pbqlIyy9RCk2Yk3e9OZTO1ev5iOJP hXrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CphjVue2o3o17XWYVNM0JlnFGUQbbef4ItukWd4EagA=; b=KQXGLAkseP+1g44gn5s3jmsG3n98nm86VIHQg4rQs6CkBSO5d+9+IjzWDx4w0C7RVA uvuG9ay8oCH06nsO3oUaW/Iut3tFyYBRku4BF9/IGjM6dXavTAq270fKXhbk/gs0VPyg SjmxDqEIadklIO2QKuMraItZAPn+poshn1hherKseIiXs5bIWUYpqQY9a3CQ7910GATS T1NP2qtJSi8f2T4s3KAMCt3IKxOlBskR7JLP4jIVI4OQFjdcYKjXUg3uIgp67XgliSp0 +a2B4OFWfL8I93gbyTQB7Z1S2OHhFsoYI02jY5vXAUxHMULVly8+cIsaIDl2z2pd005C FmKg== X-Gm-Message-State: APzg51BxRi3Zl3PH5fPHovllGNFzdpbDrnePJXftHiXWF765K9+VUwj+ lhlydK+XpuqD23ZRba3vX3KFXB+FU33nhTZS4stvjg== X-Received: by 2002:a25:d6c8:: with SMTP id n191-v6mr4447153ybg.150.1535578227877; Wed, 29 Aug 2018 14:30:27 -0700 (PDT) MIME-Version: 1.0 References: <20180821213559.14694-1-guro@fb.com> <20180829212422.GA13097@castle> In-Reply-To: <20180829212422.GA13097@castle> From: Shakeel Butt Date: Wed, 29 Aug 2018 14:30:16 -0700 Message-ID: Subject: Re: [PATCH v2 1/3] mm: rework memcg kernel stack accounting To: Roman Gushchin Cc: Linux MM , LKML , kernel-team@fb.com, Johannes Weiner , Michal Hocko , luto@kernel.org, Konstantin Khlebnikov , Tejun Heo Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 29, 2018 at 2:24 PM Roman Gushchin wrote: > > On Tue, Aug 21, 2018 at 03:10:52PM -0700, Shakeel Butt wrote: > > On Tue, Aug 21, 2018 at 2:36 PM Roman Gushchin wrote: > > > > > > If CONFIG_VMAP_STACK is set, kernel stacks are allocated > > > using __vmalloc_node_range() with __GFP_ACCOUNT. So kernel > > > stack pages are charged against corresponding memory cgroups > > > on allocation and uncharged on releasing them. > > > > > > The problem is that we do cache kernel stacks in small > > > per-cpu caches and do reuse them for new tasks, which can > > > belong to different memory cgroups. > > > > > > Each stack page still holds a reference to the original cgroup, > > > so the cgroup can't be released until the vmap area is released. > > > > > > To make this happen we need more than two subsequent exits > > > without forks in between on the current cpu, which makes it > > > very unlikely to happen. As a result, I saw a significant number > > > of dying cgroups (in theory, up to 2 * number_of_cpu + > > > number_of_tasks), which can't be released even by significant > > > memory pressure. > > > > > > As a cgroup structure can take a significant amount of memory > > > (first of all, per-cpu data like memcg statistics), it leads > > > to a noticeable waste of memory. > > > > > > Signed-off-by: Roman Gushchin > > > > Reviewed-by: Shakeel Butt > > > > BTW this makes a very good use-case for optimizing kmem uncharging > > similar to what you did for skmem uncharging. > > The only thing I'm slightly worried here is that it can make > reclaiming of memory cgroups harder. Probably, it's still ok, > but let me first finish the work I'm doing on optimizing the > whole memcg reclaim process, and then return to this case. > Yes, maybe we can disable that optimization for offlined memcgs. Anyways, we can discuss this later as you have suggested. Shakeel