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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 D1EC7C388F7 for ; Wed, 28 Oct 2020 03:48:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A62022454 for ; Wed, 28 Oct 2020 03:48:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bytedance-com.20150623.gappssmtp.com header.i=@bytedance-com.20150623.gappssmtp.com header.b="zI0AZyeo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A62022454 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E9CB06B005C; Tue, 27 Oct 2020 23:48:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4EF86B005D; Tue, 27 Oct 2020 23:48:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3D536B0062; Tue, 27 Oct 2020 23:48:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id A3C206B005C for ; Tue, 27 Oct 2020 23:48:31 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 477463625 for ; Wed, 28 Oct 2020 03:48:31 +0000 (UTC) X-FDA: 77419952022.05.point85_011189727281 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 2D5ED18015879 for ; Wed, 28 Oct 2020 03:48:31 +0000 (UTC) X-HE-Tag: point85_011189727281 X-Filterd-Recvd-Size: 6176 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Wed, 28 Oct 2020 03:48:30 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id p17so80419pli.13 for ; Tue, 27 Oct 2020 20:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yam/p71AJ8As7tsiU5BDigXfn1EtsRyjjS0tu9YDXrE=; b=zI0AZyeopougGJaeeJKxiy2HLVVsv26SHyuC9lZGn3mHVPG4adTo3D+aO+j0XR44ci FfTwaVnJRPi9zVvA6hpf1ZaFfoCoURpS9XHlqQg+ZrxnBO+E8rPyP0tqmQnY3nnjeq9r 5VGafNNKYn89gOl63qP9XNkAmVpb19eKTiDG3hK4i8x4UAVa72s7TO+CBx0vfglLdF1+ APNMSS+vFOYw1EXZr6atQtq2nZsb9X0cMA/NSVed5Q/XK5jmkE6PRoRpodiGA9qxLOTT qkdrX0ZygO5jnlaXcOL8hyXIPHhNTjGGK/dgRNviCW59mfPLSiuYuaCRwSiCT2KtnBYY zj2w== 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=yam/p71AJ8As7tsiU5BDigXfn1EtsRyjjS0tu9YDXrE=; b=iUZQbcI1cC+G2MBONpxfEIeAeCfmgj1GJZTE62njHE3pdh5eseiuzh/pFJEx7AQ2yn 3/0nuUaogn1jEnDTXjda+l+T19wRrXflAUj99ENnf7mZcIKbjzp8pGmc8o1O7MxM9GxQ EhCH2g4X7GugPEYfRtxIbzhtHkkBrkRp4FjvGzX3s0K7Ns/Wi/IjqFTDJiXK8NNza68C YSIjxuveyyD7nzNH1ecj3LFQPhL7I4UKz+ThZpmIvCJna/q7ZrAt2Sgivgw0cJewuXse jW1M5RahcRvnv3MWQh7kpBO0OAC4Tr27BUEqVtEaRkxXzMTQJS7gL8S46x/Z3hZq5tSR 1xgA== X-Gm-Message-State: AOAM532yZm/pr0wCJaa07wylWwaZL9Hep8YcjaHWEXs8dP5ZqmsvHrqJ hfzdgXIWmkqucskrQiDidry5/jR7CVs7lR+Xyi68vQ== X-Google-Smtp-Source: ABdhPJzcyOPjVfOlUg3PViyAu/gl+jzGPcviCKBDSBikqH/3CYMmhNba4abq3ls5eRn44xWfRFIFC7RRs9VhhTS4d7U= X-Received: by 2002:a17:902:6803:b029:d2:42a6:312 with SMTP id h3-20020a1709026803b02900d242a60312mr5401682plk.24.1603856909433; Tue, 27 Oct 2020 20:48:29 -0700 (PDT) MIME-Version: 1.0 References: <20201027080256.76497-1-songmuchun@bytedance.com> <20201027080256.76497-5-songmuchun@bytedance.com> <20201027184835.GB827280@carbon.dhcp.thefacebook.com> In-Reply-To: From: Muchun Song Date: Wed, 28 Oct 2020 11:47:52 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 4/5] mm: memcg/slab: Fix root memcg vmstats To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Shakeel Butt , Joonsoo Kim , laoar.shao@gmail.com, Chris Down , Christian Brauner , Peter Zijlstra , Ingo Molnar , Kees Cook , Thomas Gleixner , esyr@redhat.com, Suren Baghdasaryan , areber@redhat.com, Marco Elver , LKML , Cgroups , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" 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: On Wed, Oct 28, 2020 at 10:56 AM Muchun Song wrote: > > On Wed, Oct 28, 2020 at 2:48 AM Roman Gushchin wrote: > > > > On Tue, Oct 27, 2020 at 04:02:55PM +0800, Muchun Song wrote: > > > If we reparent the slab objects to the root memcg, when we free > > > the slab object, we need to update the per-memcg vmstats to keep > > > it correct for the root memcg. Now this at least affects the vmstat > > > of NR_KERNEL_STACK_KB for !CONFIG_VMAP_STACK when the thread stack > > > size is smaller than the PAGE_SIZE. > > > > > > Fixes: ec9f02384f60 ("mm: workingset: fix vmstat counters for shadow nodes") > > > Signed-off-by: Muchun Song > > > > Can you, please, drop this patch for now? > > > > I'm working on a bigger cleanup related to the handling of the root memory > > cgroup (I sent a link earlier in this thread), which already does a similar change. > > There are several issues like this one, so it will be nice to fix them all at once. > > I have read the patch of https://lkml.org/lkml/2020/10/14/869. You > mean this patch > fixes this issue? It chooses to uncharge the root memcg. But here we may need to Here I mean "It chooses to not uncharge the root memcg", sorry. > uncharge the root memcg to keep root vmstats correct. If we do not do > this, we can > see the wrong vmstats via root memory.stat(e.g. NR_KERNEL_STACK_KB). > > Thanks. > > > > > Thank you! > > > > > --- > > > mm/memcontrol.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > > index 22b4fb941b54..70345b15b150 100644 > > > --- a/mm/memcontrol.c > > > +++ b/mm/memcontrol.c > > > @@ -875,8 +875,13 @@ void __mod_lruvec_kmem_state(void *p, enum node_stat_item idx, int val) > > > rcu_read_lock(); > > > memcg = mem_cgroup_from_obj(p); > > > > > > - /* Untracked pages have no memcg, no lruvec. Update only the node */ > > > - if (!memcg || memcg == root_mem_cgroup) { > > > + /* > > > + * Untracked pages have no memcg, no lruvec. Update only the > > > + * node. If we reparent the slab objects to the root memcg, > > > + * when we free the slab object, we need to update the per-memcg > > > + * vmstats to keep it correct for the root memcg. > > > + */ > > > + if (!memcg) { > > > __mod_node_page_state(pgdat, idx, val); > > > } else { > > > lruvec = mem_cgroup_lruvec(memcg, pgdat); > > > -- > > > 2.20.1 > > > > > > > -- > Yours, > Muchun -- Yours, Muchun