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=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 B0318C4363A for ; Thu, 29 Oct 2020 06:16:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C90DC2151B for ; Thu, 29 Oct 2020 06:16:22 +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="jQ2Vn+hl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C90DC2151B 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 04EFB6B005C; Thu, 29 Oct 2020 02:16:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0257E6B0062; Thu, 29 Oct 2020 02:16:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA6046B0068; Thu, 29 Oct 2020 02:16:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id BF3DA6B005C for ; Thu, 29 Oct 2020 02:16:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5F395180AD817 for ; Thu, 29 Oct 2020 06:16:21 +0000 (UTC) X-FDA: 77423953362.21.use88_260f0c02728b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 3D1F2180442C2 for ; Thu, 29 Oct 2020 06:16:21 +0000 (UTC) X-HE-Tag: use88_260f0c02728b X-Filterd-Recvd-Size: 5718 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Oct 2020 06:16:20 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id a200so1470069pfa.10 for ; Wed, 28 Oct 2020 23:16:20 -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=n7NRtz56PDrI9TlnLNjgdlxbuOLi2alt2q22qA5ZMDM=; b=jQ2Vn+hlZsZS9o3ITt59L/OK0Z6t3j2+1+WF33ekNAIhXNb3Pu44yIxwScTO18PQTZ EYIkIi/RZVDGQZSc16nb7gnKbf8Xh0MEFCILhPzbYX2xZln+4wzKEfRtQVqiAtcH2697 LVLQcf7/Kwy7MgKBYXCW7Xx/4OnuqeZTrGumdH0W/R3oKdB9powFDeomnAWQYWgrFda+ I7CFDxh910gYVWYr5s/MJvpZs+/Bd1/UTbZIqYqC7sRuRDRY1FeWOaWNdnXJMxVVRNqa QduYL17Ccef4j2aAPbpwov6T3yydVsku7bFJMZ5h6U8wzCB3QWq8SCQPcfV+dTucgKjk QvkA== 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=n7NRtz56PDrI9TlnLNjgdlxbuOLi2alt2q22qA5ZMDM=; b=Obqp7Y+Vf78L9jYkVBYYSYVg4G6o0EUTiQ/Bh6uop7ouWeX8wEEPlwaL0BMoEUbJmr rndcllk3wBmL/yBlK+7lh17qL3IjNake3TLY6DWVTPYKtUWbYRmKsR17Qu1JvjeJxcvy zTCHtqj5aBo6tTc3wXB0FPweQrBVC5JodBPUd8WyWuBHZv7J4frms+8hksISz/tvmOhn c4xIWFChK03AF+Zf0wWH2fgjmvI0dgjW+G46nBqPxH1WEnTRk44sRTN02sm/v7TUf244 WxZhFRgCfPymBWpISVLVnvXOGa2/q4ktGNFBTkcpv2wFwk6hcFeQA+hOSfcMuf6F5yMd quXw== X-Gm-Message-State: AOAM530+amYFAleV4Tce+8V5r1o1/kwsKPR3Jxc7UHEyP0tPkgAEqqQQ 9cBa3BL729rLXMd3MVKq034yoaeur+bo5AmrPwsimQ== X-Google-Smtp-Source: ABdhPJw4NQpqsTHHLGdK75LoiiTryFYJh3x82DLJSORkilAWhto57nEDjgwGuJu8Veb+OBxuu8+VsxK1p2PUyNwomc0= X-Received: by 2002:a63:5804:: with SMTP id m4mr864296pgb.31.1603952179186; Wed, 28 Oct 2020 23:16:19 -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> <20201029001408.GF827280@carbon.dhcp.thefacebook.com> In-Reply-To: <20201029001408.GF827280@carbon.dhcp.thefacebook.com> From: Muchun Song Date: Thu, 29 Oct 2020 14:15:43 +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.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 29, 2020 at 8:14 AM Roman Gushchin wrote: > > On Wed, Oct 28, 2020 at 10:56:20AM +0800, 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 > > 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). > > I pointed at a different patch in the same thread (it looks like you read the first one): > https://lkml.org/lkml/2020/10/21/612 Got it. Thanks. That is fine to me. > > It contained the following part: > > @@ -868,7 +860,7 @@ void __mod_lruvec_slab_state(void *p, enum node_stat_item idx, int val) > memcg = mem_cgroup_from_obj(p); > > /* Untracked pages have no memcg, no lruvec. Update only the node */ > - if (!memcg || memcg == root_mem_cgroup) { > + if (!memcg) { > __mod_node_page_state(pgdat, idx, val); > } else { > lruvec = mem_cgroup_lruvec(memcg, pgdat); > > So it's exactly what your patch does. > > Thanks! -- Yours, Muchun