From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A682DC433E1 for ; Wed, 12 Aug 2020 21:01:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 808FE20774 for ; Wed, 12 Aug 2020 21:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597266073; bh=ni872Nb7tXEQTCWupYvCVUPWd3ozVQbWyA51aDTugOw=; h=Date:From:To:Subject:Reply-To:List-ID:From; b=a+bzFn9aEa+IeZAhFUCLal8Sd/wslT1jfFN4FiIAikk4oc3xzScqL0Sny3GJEQras GZUjlJHINyv/iTsfgA8vqnkaBZhnAkxHXxUcZ2+HZImas8Q6hbqVXhxZ3jveD/yvXv qIIC6MXwKXEEM4Lue7QzFhAM7WRLXMI4z5Vs1Yx8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgHLVBN (ORCPT ); Wed, 12 Aug 2020 17:01:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:45032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726030AbgHLVBN (ORCPT ); Wed, 12 Aug 2020 17:01:13 -0400 Received: from localhost.localdomain (c-71-198-47-131.hsd1.ca.comcast.net [71.198.47.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B291220768; Wed, 12 Aug 2020 21:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597266072; bh=ni872Nb7tXEQTCWupYvCVUPWd3ozVQbWyA51aDTugOw=; h=Date:From:To:Subject:From; b=rJYvjAfhNn5QdWbLQdt/n8QOb65ydMBkHWdOrIrEgMVmP0hJEKela8Tl4Ujf/jI0S 9KdGn8L6Caac86NDjaxTiEBRtKnu2rFQ/m2pHoJekp7KuKNyAOi3ta0yDVS3axthB5 NSsJAdalOtTCsHfsD9KRuzhkpXrICGDIQ3+GERV4= Date: Wed, 12 Aug 2020 14:01:11 -0700 From: akpm@linux-foundation.org To: cl@linux.com, cuibixuan@huawei.com, dennis@kernel.org, guro@fb.com, hannes@cmpxchg.org, iamjoonsoo.kim@lge.com, longman@redhat.com, mgorman@techsingularity.net, mhocko@kernel.org, mkoutny@suse.com, mm-commits@vger.kernel.org, penberg@kernel.org, rientjes@google.com, sfr@canb.auug.org.au, shakeelb@google.com, tj@kernel.org, tobin@kernel.org, vbabka@suse.cz Subject: [merged] mm-memcg-charge-memcg-percpu-memory-to-the-parent-cgroup.patch removed from -mm tree Message-ID: <20200812210111.-QYHkP6u7%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: mm-commits-owner@vger.kernel.org Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The patch titled Subject: mm: memcg: charge memcg percpu memory to the parent cgroup has been removed from the -mm tree. Its filename was mm-memcg-charge-memcg-percpu-memory-to-the-parent-cgroup.patch This patch was dropped because it was merged into mainline or a subsystem t= ree ------------------------------------------------------ =46rom: Roman Gushchin Subject: mm: memcg: charge memcg percpu memory to the parent cgroup Memory cgroups are using large chunks of percpu memory to store vmstat data. Yet this memory is not accounted at all, so in the case when there are many (dying) cgroups, it's not exactly clear where all the memory is. Because the size of memory cgroup internal structures can dramatically exceed the size of object or page which is pinning it in the memory, it's not a good idea to simply ignore it. It actually breaks the isolation between cgroups. Let's account the consumed percpu memory to the parent cgroup. [guro@fb.com: add WARN_ON_ONCE()s, per Johannes] Link: http://lkml.kernel.org/r/20200811170611.GB1507044@carbon.DHCP.thefa= cebook.com Link: http://lkml.kernel.org/r/20200623184515.4132564-5-guro@fb.com Signed-off-by: Roman Gushchin Acked-by: Dennis Zhou Reviewed-by: Shakeel Butt Acked-by: Johannes Weiner Cc: Christoph Lameter Cc: David Rientjes Cc: Joonsoo Kim Cc: Mel Gorman Cc: Michal Hocko Cc: Pekka Enberg Cc: Tejun Heo Cc: Tobin C. Harding Cc: Vlastimil Babka Cc: Waiman Long Cc: Bixuan Cui Cc: Michal Koutn=C3=BD Cc: Stephen Rothwell Signed-off-by: Andrew Morton --- mm/memcontrol.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) --- a/mm/memcontrol.c~mm-memcg-charge-memcg-percpu-memory-to-the-parent-cgr= oup +++ a/mm/memcontrol.c @@ -5131,13 +5131,18 @@ static int alloc_mem_cgroup_per_node_inf if (!pn) return 1; =20 - pn->lruvec_stat_local =3D alloc_percpu(struct lruvec_stat); + /* We charge the parent cgroup, never the current task */ + WARN_ON_ONCE(!current->active_memcg); + + pn->lruvec_stat_local =3D alloc_percpu_gfp(struct lruvec_stat, + GFP_KERNEL_ACCOUNT); if (!pn->lruvec_stat_local) { kfree(pn); return 1; } =20 - pn->lruvec_stat_cpu =3D alloc_percpu(struct lruvec_stat); + pn->lruvec_stat_cpu =3D alloc_percpu_gfp(struct lruvec_stat, + GFP_KERNEL_ACCOUNT); if (!pn->lruvec_stat_cpu) { free_percpu(pn->lruvec_stat_local); kfree(pn); @@ -5211,11 +5216,16 @@ static struct mem_cgroup *mem_cgroup_all goto fail; } =20 - memcg->vmstats_local =3D alloc_percpu(struct memcg_vmstats_percpu); + /* We charge the parent cgroup, never the current task */ + WARN_ON_ONCE(!current->active_memcg); + + memcg->vmstats_local =3D alloc_percpu_gfp(struct memcg_vmstats_percpu, + GFP_KERNEL_ACCOUNT); if (!memcg->vmstats_local) goto fail; =20 - memcg->vmstats_percpu =3D alloc_percpu(struct memcg_vmstats_percpu); + memcg->vmstats_percpu =3D alloc_percpu_gfp(struct memcg_vmstats_percpu, + GFP_KERNEL_ACCOUNT); if (!memcg->vmstats_percpu) goto fail; =20 @@ -5264,7 +5274,9 @@ mem_cgroup_css_alloc(struct cgroup_subsy struct mem_cgroup *memcg; long error =3D -ENOMEM; =20 + memalloc_use_memcg(parent); memcg =3D mem_cgroup_alloc(); + memalloc_unuse_memcg(); if (IS_ERR(memcg)) return ERR_CAST(memcg); =20 _ Patches currently in -mm which might be from guro@fb.com are mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings.patch mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix.patch