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=-8.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, 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 9CAFCC433FE for ; Mon, 7 Dec 2020 14:53:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2D34D2337F for ; Mon, 7 Dec 2020 14:53:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D34D2337F 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 638D88D0002; Mon, 7 Dec 2020 09:53:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C2378D0001; Mon, 7 Dec 2020 09:53:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 463B18D0002; Mon, 7 Dec 2020 09:53:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 2B50C8D0001 for ; Mon, 7 Dec 2020 09:53:09 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E2B45181AEF1A for ; Mon, 7 Dec 2020 14:53:08 +0000 (UTC) X-FDA: 77566778856.17.salt39_05082fb273df Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id C3100180D0180 for ; Mon, 7 Dec 2020 14:53:08 +0000 (UTC) X-HE-Tag: salt39_05082fb273df X-Filterd-Recvd-Size: 7686 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 14:53:08 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id m9so9080466pgb.4 for ; Mon, 07 Dec 2020 06:53:08 -0800 (PST) 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=67q06ahdve+maXXaXcuBF0/78g4V9jwMrZzg/oICieI=; b=H7aX76AZlFayE7q9/thM8tX2F4CdIfANhGAWc55owFDZkkd+M4/VnK4QkPZJOC60Il EqBdwBRnmbarXV5lwcCaaR18VtKxpNVNexjWgzxL2TVVoO5rGJ+9h7sBWeNQUnPfoghd U3WdTdhzvGFyXigIEPMlH+PTwGgOMAFWPps5TizIkVykOzrbp2mE4EqKuy0qWsH5I4BZ 8loNvDefr/DQ6mBNOMsP+yXbizUQ+t7/FONemwW2+Y8ew8nBBdKo4dGV5x8zmT64fL4+ SrYoVyCXwR3cyegtYMDWqbTxYLtNBTmcbRa188Vt8Co6ggvMmxOL3gmvOYgehOb4IeM2 xC3g== 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=67q06ahdve+maXXaXcuBF0/78g4V9jwMrZzg/oICieI=; b=A8Ti8V1hXX7dgi5FQnYKofkLDeM+G9X+/7S2ln7x6yl8//Fm1mBlyZdR8DC38n3yIX H7CIGgJJ3Tps6stWJ06qH2kGHJ3BW4Kgq3H5jUG8N8YZItY+7SBJPAZ/XfFkUItQomZV U6bQ/c47RxU1ZwaQKPwbm8QMYCJQBaFZp+ZxH6QWgKcp01TzIn1a3cHAfRFLBvQGN+ns rrd4BifQmr28sEHtXLVkHb30pSGVYhzqtRDgIYvI6zkWzGEI4+rTNvFykdiXVk4he02Y jGpwpqx7fxJiKFJLX1jvvkOKzHWe0kHO+jZqSDYlkFKJP7eDxenvo/PIhzgmreGe8Tyx ImqQ== X-Gm-Message-State: AOAM531uAa5za34NcJa7OKsqTbAck231q8Y6xk4Rh8ol8nyFuIUcPcpu c1UzOfBzo+42tl98m39/Ukjhh8LTheHYTOTJLMRa+A== X-Google-Smtp-Source: ABdhPJwJ4IWHc9o4dLsL8uDmX/narH/dl/xqmI8YYc9Xn9QfxasAXfpW6XsPkLCBTKXQ0jbtCkPsQdCgDzMGRkbdCXc= X-Received: by 2002:a63:c15:: with SMTP id b21mr18447984pgl.341.1607352787255; Mon, 07 Dec 2020 06:53:07 -0800 (PST) MIME-Version: 1.0 References: <20201206101451.14706-1-songmuchun@bytedance.com> <20201207130018.GJ25569@dhcp22.suse.cz> In-Reply-To: <20201207130018.GJ25569@dhcp22.suse.cz> From: Muchun Song Date: Mon, 7 Dec 2020 22:52:30 +0800 Message-ID: Subject: Re: [External] Re: [RESEND PATCH v2 00/12] Convert all vmstat counters to pages or bytes To: Michal Hocko Cc: Greg KH , rafael@kernel.org, Alexey Dobriyan , Andrew Morton , Johannes Weiner , Vladimir Davydov , Hugh Dickins , Will Deacon , Roman Gushchin , Mike Rapoport , Thomas Gleixner , esyr@redhat.com, peterx@redhat.com, krisman@collabora.com, Suren Baghdasaryan , avagin@openvz.org, Marco Elver , Randy Dunlap , Joonsoo Kim , LKML , linux-fsdevel , Linux Memory Management List , Cgroups 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 Mon, Dec 7, 2020 at 9:00 PM Michal Hocko wrote: > > On Sun 06-12-20 18:14:39, Muchun Song wrote: > > Hi, > > > > This patch series is aimed to convert all THP vmstat counters to pages > > and some KiB vmstat counters to bytes. > > > > The unit of some vmstat counters are pages, some are bytes, some are > > HPAGE_PMD_NR, and some are KiB. When we want to expose these vmstat > > counters to the userspace, we have to know the unit of the vmstat counters > > is which one. It makes the code complex. Because there are too many choices, > > the probability of making a mistake will be greater. > > > > For example, the below is some bug fix: > > - 7de2e9f195b9 ("mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg") > > - not committed(it is the first commit in this series) ("mm: memcontrol: fix NR_ANON_THPS account") > > > > This patch series can make the code simple (161 insertions(+), 187 deletions(-)). > > And make the unit of the vmstat counters are either pages or bytes. Fewer choices > > means lower probability of making mistakes :). > > > > This was inspired by Johannes and Roman. Thanks to them. > > It would be really great if you could summarize the current and after > the patch state so that exceptions are clear and easier to review. The Agree. Will do in the next version. Thanks. > existing situation is rather convoluted but we have at least units part > of the name so it is not too hard to notice that. Reducing exeptions > sounds nice but I am not really sure it is such an improvement it is > worth a lot of code churn. Especially when it comes to KB vs B. Counting There are two vmstat counters (NR_KERNEL_STACK_KB and NR_KERNEL_SCS_KB) whose units are KB. If we do this, all vmstat counter units are either pages or bytes in the end. When we expose those counters to userspace, it can be easy. You can reference to: [RESEND PATCH v2 11/12] mm: memcontrol: make the slab calculation consistent >From this point of view, I think that it is worth doing this. Right? > THPs as regular pages sounds like a good plan to me because we can > expect that THP will be of a different size in the future - especially > for file THPs. It can be easy to convert. > > > Changes in v1 -> v2: > > - Change the series subject from "Convert all THP vmstat counters to pages" > > to "Convert all vmstat counters to pages or bytes". > > - Convert NR_KERNEL_SCS_KB account to bytes. > > - Convert vmstat slab counters to bytes. > > - Remove {global_}node_page_state_pages. > > > > Muchun Song (12): > > mm: memcontrol: fix NR_ANON_THPS account > > mm: memcontrol: convert NR_ANON_THPS account to pages > > mm: memcontrol: convert NR_FILE_THPS account to pages > > mm: memcontrol: convert NR_SHMEM_THPS account to pages > > mm: memcontrol: convert NR_SHMEM_PMDMAPPED account to pages > > mm: memcontrol: convert NR_FILE_PMDMAPPED account to pages > > mm: memcontrol: convert kernel stack account to bytes > > mm: memcontrol: convert NR_KERNEL_SCS_KB account to bytes > > mm: memcontrol: convert vmstat slab counters to bytes > > mm: memcontrol: scale stat_threshold for byted-sized vmstat > > mm: memcontrol: make the slab calculation consistent > > mm: memcontrol: remove {global_}node_page_state_pages > > > > drivers/base/node.c | 25 ++++----- > > fs/proc/meminfo.c | 22 ++++---- > > include/linux/mmzone.h | 21 +++----- > > include/linux/vmstat.h | 21 ++------ > > kernel/fork.c | 8 +-- > > kernel/power/snapshot.c | 2 +- > > kernel/scs.c | 4 +- > > mm/filemap.c | 4 +- > > mm/huge_memory.c | 9 ++-- > > mm/khugepaged.c | 4 +- > > mm/memcontrol.c | 131 ++++++++++++++++++++++++------------------------ > > mm/oom_kill.c | 2 +- > > mm/page_alloc.c | 17 +++---- > > mm/rmap.c | 19 ++++--- > > mm/shmem.c | 3 +- > > mm/vmscan.c | 2 +- > > mm/vmstat.c | 54 ++++++++------------ > > 17 files changed, 161 insertions(+), 187 deletions(-) > > > > -- > > 2.11.0 > > -- > Michal Hocko > SUSE Labs -- Yours, Muchun