From patchwork Sun Dec 6 08:22:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11953739 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=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 620EEC433FE for ; Sun, 6 Dec 2020 08:25:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E4F30230FB for ; Sun, 6 Dec 2020 08:25:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4F30230FB 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 1D59A6B0068; Sun, 6 Dec 2020 03:25:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ABDA8D0002; Sun, 6 Dec 2020 03:25:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C21B8D0001; Sun, 6 Dec 2020 03:25:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id EA5A36B0068 for ; Sun, 6 Dec 2020 03:25:27 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A0FF98249980 for ; Sun, 6 Dec 2020 08:25:27 +0000 (UTC) X-FDA: 77562173094.10.copy68_311440d273d4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 808CB16A4AD for ; Sun, 6 Dec 2020 08:25:27 +0000 (UTC) X-HE-Tag: copy68_311440d273d4 X-Filterd-Recvd-Size: 6043 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Sun, 6 Dec 2020 08:25:26 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id p4so1034414pfg.0 for ; Sun, 06 Dec 2020 00:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=94t92p220d3blDFDgpx+1JH+mQKvnsugZ3wYNVpL5Pc=; b=aPEbZU4OyEStT3F68E8ntmWaoqDSzRPfxpNag1nustiini6Rf/h8SsWgNHnv4nMhTc R5+L+leR3yh0p1Z46A9wM4d+nzaY/GgZwJyBPEZPXBgMmUXiV5wBRVBZSxvRYxmjxtLd v6lQLZXZNUK0DIQFDR2uuU3dQVm3JJDOD6FYURZgGlVg+xMUJhlcxhvFjvsg8lWGFxJA kfXZFS/lzxEWbrwnrtvgXNPh/EKiZqJEIv6TnJu1UodsK0tRvuYxzOJQqSBbIBLxFmXR 3fhfx5Shes7y2EfZXI2Wc1yj+ikUveMtDJd2DyrJNw9155Ig/QQ4g8lwQh8IyrOAfG8a nFDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=94t92p220d3blDFDgpx+1JH+mQKvnsugZ3wYNVpL5Pc=; b=d4XeqkRVjVpRdRvBdmec/tgsLvrSi9DUYEj9yWvuMsxm6UHTxD1sXtgAetfbd/y7HM Su0tAcALtDdRv+6yp/KCTTS2ty3AprXL7Xz39a3kF904kx7N3s4Xh9D4lGPZ0gzLfZ8U pZoR8ZTfVFOBrqjpZv+zzaDA32FyDqOcClKktG+KOZQnnVKLVH+r6j79jKiacu9oeuQw hz+gswcL+xyW2efqnvS777lGbvD5B0v/BQTNyh2EhXmzCzqFDTeMEMI7VLDCgrd3N0cy +egGgGgDN2A8HWYvz4rhZCyeTNWn0vLvOXzi/FAU4HGi0yjat5TknFNaL4cTUGX2jKjY FQEg== X-Gm-Message-State: AOAM530yw69SAf+W+vhXbNFPsb/wU88BeH3CVnyLT3mKdcOY5GNu/B3v dFWc0Nz6w7fcT80OAgE/5puZcQ== X-Google-Smtp-Source: ABdhPJx9N52V9X/vLGy1rmg1UsEWFvMmYT4HwbKlcPc26xtBH3Uc9GcECnSQRz8S83pEQJd6sID7Iw== X-Received: by 2002:a63:48f:: with SMTP id 137mr14064045pge.172.1607243125546; Sun, 06 Dec 2020 00:25:25 -0800 (PST) Received: from localhost.localdomain ([103.136.221.70]) by smtp.gmail.com with ESMTPSA id iq3sm6884104pjb.57.2020.12.06.00.25.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Dec 2020 00:25:24 -0800 (PST) From: Muchun Song To: gregkh@linuxfoundation.org, rafael@kernel.org, adobriyan@gmail.com, akpm@linux-foundation.org, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, hughd@google.com, will@kernel.org, guro@fb.com, rppt@kernel.org, tglx@linutronix.de, esyr@redhat.com, peterx@redhat.com, krisman@collabora.com, surenb@google.com, avagin@openvz.org, elver@google.com, rdunlap@infradead.org, iamjoonsoo.kim@lge.com Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, Muchun Song Subject: [PATCH v2 00/12] Convert all vmstat counters to pages or bytes Date: Sun, 6 Dec 2020 16:22:57 +0800 Message-Id: <20201206082318.11532-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 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: 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. 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(-)