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.7 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 AF29CC43461 for ; Fri, 11 Sep 2020 03:52:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F2E71221E5 for ; Fri, 11 Sep 2020 03:52:24 +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="vS8pt+Nf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2E71221E5 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 2DAE7900006; Thu, 10 Sep 2020 23:52:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28A898E0001; Thu, 10 Sep 2020 23:52:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12B1F900006; Thu, 10 Sep 2020 23:52:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id EED938E0001 for ; Thu, 10 Sep 2020 23:52:23 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id AB90A8248068 for ; Fri, 11 Sep 2020 03:52:23 +0000 (UTC) X-FDA: 77249408166.17.sheet25_4f06e7c270eb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 81810180D0180 for ; Fri, 11 Sep 2020 03:52:23 +0000 (UTC) X-HE-Tag: sheet25_4f06e7c270eb X-Filterd-Recvd-Size: 7321 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 03:52:22 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id b124so6194118pfg.13 for ; Thu, 10 Sep 2020 20:52:22 -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=9IV7HFefw1NIebU4itnNPdbQ5lYPIj2T1tDtgZeUqmc=; b=vS8pt+NfBa8G2NMGBwUEeLv/u22mt84ER/i3XbVd5kfjLV6iWfj5LWSD9iDugOdnJi pnvRudVBrBizJJ2mMTSXO7123cysHit9IRTi5qxshFE/l7znxMilhIyVgzMTUvlwwIVl 5AsiwAofwATThXaG71cGe9qJ5ra5/xRjuLPd+L0OFDGgo44tZC0UBijE2aHZuWcaxczx qFpOsOWdJz4NGHwe5S27nH4cb8sWsXOnqCFD7HKGxVRjRnIEHhv/G8beTkJBMWa48og/ hwbTtHoUabIfXa/kz0FZFks5V6kzqblc0tEHNIurI3lJQddNf7TkTdF8QrPjis93fL1d fwVQ== 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=9IV7HFefw1NIebU4itnNPdbQ5lYPIj2T1tDtgZeUqmc=; b=o/X81cTVftneq5zjg//9s6zsDlQcp7mCDD3tbS9G86F9oRyh2fsl282oW36T9FnLoW vcvwdQguEGASS31PTqNEPnKpJzfvQRS2QKhcTvItrjgxLcbgIp7Bgw8Yr/HFGRYViCeJ 8FHTFnIFugg1jI0kSd47UPEi0Q34n+2rfC8wXa11wixuUoBBL//jPeb3TfLwOYjXV93X ZnzdOa5IcSERPZj3kv2A9dh45ff7oK8iVA04ejMRkmr52hWofwo+VgpheTsm05UjEazX kNb9sHKE/h/AunMUBe/Sz4/qDB7FVo9A8QVyVpS+HKhGCRpztKf4PqxapCWwYIewXDoQ feEw== X-Gm-Message-State: AOAM531tmcXlR1ZUHzCnkbC3ljrmHhNrb/jgfqhfkjD3XbCyNkHsQPko 07YesIV+JC4iyTu9/SwbCJ2GGcWNTKCgOBxYp/p3KA== X-Google-Smtp-Source: ABdhPJxibbvSxKxO41BlACQqUJkBTdPD+KmfwtRs9Q8JsaaA0IpfDaDkzF2vKoPJHR+yf3YXwcRu+z8uwQCaNwHKXUs= X-Received: by 2002:a62:38ce:0:b029:138:838f:dd53 with SMTP id f197-20020a6238ce0000b0290138838fdd53mr328874pfa.2.1599796341600; Thu, 10 Sep 2020 20:52:21 -0700 (PDT) MIME-Version: 1.0 References: <20200910084258.22293-1-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Fri, 11 Sep 2020 11:51:42 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm: memcontrol: Add the missing numa stat of anon and file for cgroup v2 To: Shakeel Butt Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Cgroups , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 81810180D0180 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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 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? > > 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