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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 B3258C433E2 for ; Fri, 11 Sep 2020 14:55:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B0982075B for ; Fri, 11 Sep 2020 14:55:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DRq2hDts" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B0982075B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AFECC6B0002; Fri, 11 Sep 2020 10:55:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB0676B005A; Fri, 11 Sep 2020 10:55:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99F5A6B005C; Fri, 11 Sep 2020 10:55:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 807166B0002 for ; Fri, 11 Sep 2020 10:55:34 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 426D5824805A for ; Fri, 11 Sep 2020 14:55:34 +0000 (UTC) X-FDA: 77251079388.23.music66_220f516270ef Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 235E137608 for ; Fri, 11 Sep 2020 14:55:34 +0000 (UTC) X-HE-Tag: music66_220f516270ef X-Filterd-Recvd-Size: 7864 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 14:55:33 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id x69so6157194lff.3 for ; Fri, 11 Sep 2020 07:55:33 -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=RyGETUg9mUKb771YPAmqWLGZaTO7mZ6hKFj3E91siek=; b=DRq2hDtsbMxfpg7W5O+ZLV1lUVDBsWosPPite6Mp7DI9sgN0NZSVPPtwxQe6bBU/f3 gLNTTgHzLJMDPfUAcKbMD3OW8k3KoymNgxK8mLl9QWoIw0sZDr1T4Vx4mu7k9k7JdEs5 3x/fFhmTkY7qWGxK22snBGLvTN6Z7TlrJxfY+2ncfuGRKZpwYXJ11akrgf7sTNurnp85 lmT4gl5NmTNytzmc/6rAngMH+OxJ4BXDeC75yDziaV9eauYodGRNeKbu9vo8/uWsqzeX lfI7glc9MDT5UAMYVjxq+qRPGwA/gilQEYXic/i7Fh+QKmW24oQoJ6FcBWMzloucXDDQ OdSQ== 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=RyGETUg9mUKb771YPAmqWLGZaTO7mZ6hKFj3E91siek=; b=Ht467ZN20CvDgCYEV6xbWK4uxMSfZMXMg5Bf1+shQFON3oJbtyQcfeFiqqxym831qA mgY/3pgQ1VRrSdjAw4fV3MJY7t2k5j+kE7MeqVYXr+f6yNO1US6wYEAKcSxGFPBjx0gX XTMLSszQZjHV+rwWkPpB7y1geAj8cZkNVGXf8apmcSiZbsfEp0NQUhdUhIRtCx3YirHk MTGLiDj2vJQKU69EVIRRCGw7ETUXcvNM/FpxVclBx6ucFlQBRL9rL0TSrtCn2ICBRhSc Gl0yZo78T9Ijan3P8z7o4IxEA1EvrkbctveswrTtE3kQHWaTqEp3LNUC9ukklHiQssNN 5geg== X-Gm-Message-State: AOAM532pz1/4W6clmABtcyDnsEwb7dI45ZuhnIa3HG6HdW3S+O5Mbivc 4f9SKBbSUbovdQSh3+M/EQPT+7Tk+iJhJDlGpiuKWIWw3X0= X-Google-Smtp-Source: ABdhPJzIfXWEoPr+pejl9ICIZBfdEPcdhSa0BRgky84fzVsWoAMK+i7zNMib2U+DpXd++dQwMqw6Op9w7E45OQMrsVg= X-Received: by 2002:ac2:59da:: with SMTP id x26mr449757lfn.346.1599836132004; Fri, 11 Sep 2020 07:55:32 -0700 (PDT) MIME-Version: 1.0 References: <20200910084258.22293-1-songmuchun@bytedance.com> In-Reply-To: From: Shakeel Butt Date: Fri, 11 Sep 2020 07:55:20 -0700 Message-ID: Subject: Re: [External] Re: [PATCH] mm: memcontrol: Add the missing numa stat of anon and file for cgroup v2 To: Muchun Song Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Cgroups , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 235E137608 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Thu, Sep 10, 2020 at 8:52 PM Muchun Song wrote: > > On Fri, Sep 11, 2020 at 12:02 AM Shakeel Butt wrote: > > > > On Thu, Sep 10, 2020 at 1:46 AM Muchun Song wrote: > > > > > > In the cgroup v1, we have a numa_stat interface. This is useful for > > > providing visibility into the numa locality information within an > > > memcg since the pages are allowed to be allocated from any physical > > > node. One of the use cases is evaluating application performance by > > > combining this information with the application's CPU allocation. > > > But the cgroup v2 does not. So this patch adds the missing information. > > > > > > Signed-off-by: Muchun Song > > > --- > > > > I am actually working on exposing this info on v2 as well. > > > > > mm/memcontrol.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- > > > 1 file changed, 44 insertions(+), 2 deletions(-) > > > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > > index 75cd1a1e66c8..c779673f29b2 100644 > > > --- a/mm/memcontrol.c > > > +++ b/mm/memcontrol.c > > > @@ -1492,10 +1492,34 @@ static bool mem_cgroup_wait_acct_move(struct mem_cgroup *memcg) > > > return false; > > > } > > > > > > +#ifdef CONFIG_NUMA > > > +static unsigned long memcg_node_page_state(struct mem_cgroup *memcg, > > > + unsigned int nid, > > > + enum node_stat_item idx) > > > +{ > > > + long x; > > > + struct mem_cgroup_per_node *pn; > > > + struct lruvec *lruvec = mem_cgroup_lruvec(memcg, NODE_DATA(nid)); > > > + > > > + VM_BUG_ON(nid >= nr_node_ids); > > > + > > > + pn = container_of(lruvec, struct mem_cgroup_per_node, lruvec); > > > + x = atomic_long_read(&pn->lruvec_stat[idx]); > > > +#ifdef CONFIG_SMP > > > + if (x < 0) > > > + x = 0; > > > +#endif > > > + return x; > > > +} > > > +#endif > > > + > > > static char *memory_stat_format(struct mem_cgroup *memcg) > > > { > > > struct seq_buf s; > > > int i; > > > +#ifdef CONFIG_NUMA > > > + int nid; > > > +#endif > > > > > > seq_buf_init(&s, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); > > > if (!s.buffer) > > > @@ -1512,12 +1536,30 @@ static char *memory_stat_format(struct mem_cgroup *memcg) > > > * Current memory state: > > > */ > > > > > > > Let's not break the parsers of memory.stat. I would prefer a separate > > interface like v1 i.e. memory.numa_stat. > > It is also a good idea to expose a new interface like memory.numa_stat. > > > > > > - seq_buf_printf(&s, "anon %llu\n", > > > + seq_buf_printf(&s, "anon %llu", > > > (u64)memcg_page_state(memcg, NR_ANON_MAPPED) * > > > PAGE_SIZE); > > > - seq_buf_printf(&s, "file %llu\n", > > > +#ifdef CONFIG_NUMA > > > + for_each_node_state(nid, N_MEMORY) > > > + seq_buf_printf(&s, " N%d=%llu", nid, > > > + (u64)memcg_node_page_state(memcg, nid, > > > + NR_ANON_MAPPED) * > > > + PAGE_SIZE); > > > +#endif > > > + seq_buf_putc(&s, '\n'); > > > + > > > + seq_buf_printf(&s, "file %llu", > > > (u64)memcg_page_state(memcg, NR_FILE_PAGES) * > > > PAGE_SIZE); > > > +#ifdef CONFIG_NUMA > > > + for_each_node_state(nid, N_MEMORY) > > > + seq_buf_printf(&s, " N%d=%llu", nid, > > > + (u64)memcg_node_page_state(memcg, nid, > > > + NR_FILE_PAGES) * > > > + PAGE_SIZE); > > > +#endif > > > + seq_buf_putc(&s, '\n'); > > > + > > > > The v1's numa_stat exposes the LRUs, why NR_ANON_MAPPED and NR_FILE_PAGES? > > If we want to expose the anon per node, we need to add inactive anon and > active anon together. Why not use NR_ANON_MAPPED directly? > Active anon plus inactive anon is not equal to NR_ANON_MAPPED. The shmem related memory is on anon LRUs but not accounted in NR_ANON_MAPPED. Similarly file LRU can contain MADV_FREE pages which are not accounted in NR_FILE_PAGES. > > > > Also I think exposing slab_[un]reclaimable per node would be beneficial as well. > > Yeah, I agree with you. Maybe kernel_stack and percpu also should > be exposed. > > > > > > seq_buf_printf(&s, "kernel_stack %llu\n", > > > (u64)memcg_page_state(memcg, NR_KERNEL_STACK_KB) * > > > 1024); > > > -- > > > 2.20.1 > > > > > > > -- > Yours, > Muchun