From patchwork Fri Dec 11 04:19:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11967203 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 A03E7C433FE for ; Fri, 11 Dec 2020 04:23:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD61523ED2 for ; Fri, 11 Dec 2020 04:23:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD61523ED2 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 DE4086B0036; Thu, 10 Dec 2020 23:23:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D96326B005D; Thu, 10 Dec 2020 23:23:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C83666B0068; Thu, 10 Dec 2020 23:23:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0064.hostedemail.com [216.40.44.64]) by kanga.kvack.org (Postfix) with ESMTP id B1B066B0036 for ; Thu, 10 Dec 2020 23:23:05 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 75E3E1EF2 for ; Fri, 11 Dec 2020 04:23:05 +0000 (UTC) X-FDA: 77579706330.11.rain36_230a9e7273fe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 58922180F8B80 for ; Fri, 11 Dec 2020 04:23:05 +0000 (UTC) X-HE-Tag: rain36_230a9e7273fe X-Filterd-Recvd-Size: 6533 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 04:23:04 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id j13so1680317pjz.3 for ; Thu, 10 Dec 2020 20:23:04 -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=JadMn18aCnIs/6Vjw45Dh3eAfbEtua6oaOg4kdj6BCQ=; b=eCkNBMu8UVMzizfhgKu+N0keqKcYMkDxoJqXSjBAJuVT24Zx4JcNlyj0zk9vCTikLs lmzn027hZix4kWPCyIGZc1e46yyFv/eFpJz+1yi15kgG+bSNG+uyewJKh+89avQLygjj rQMrtG67rImSPoJJ9pa7mEwIZ4pF1N+8l2eozAfJ5BAejTuj052QDZOo2I0PvwKCgYqx OtShU6qB3lCEaj6fqfhCiiYnLMKVF/kLzQV8XXJ/Pmt+NTyUYCgSL4ZHiYXjxhf5hiLY 41wf3VKfjPgBY/IGXC7MWQBe/DOuf1DDWIrxCUjdMiZHSI3AcnQitgBRtjadqjT0bNko W6eg== 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=JadMn18aCnIs/6Vjw45Dh3eAfbEtua6oaOg4kdj6BCQ=; b=nRa+gB1J2dKy+DV+Djk4JoW8uXjciwmO70JtXcjfzmaZUwOYqXKy8vPuyl/8QH0vcb sAGKG6H1wUXp5k08L5j5o7JyzYAU5DO3qAzrmwh3c0xeKHLBo8f0/1QqMj/eSFrFUwuM jgP5KLjzKYb7++qRRJR+ZFmXXz9PazqXty+GV+Iy+NCW274G5QR2XclCUPsTdGIlRLQ5 RCDx9ErGECPfESOj6/CkyaBS4VnIb1Hipq7h7A0LMFfctipft+5YMOIwb1nHCs/lunPH uQoAue2VjF248BXzTkvdRXYCXjRsWfqCx44/2irq8ImVl0914qQYZDe+4ytfomduRVto 0qVA== X-Gm-Message-State: AOAM532j2Y9uxTERXG8zLxBvdEQigJDcqBvdDJqFLW0yDk406GZ/wyxD jyYbrTVIioSLQsUBblV8KpA0AQ== X-Google-Smtp-Source: ABdhPJyjs37u4Khap3K42fbJclkpOu+lkUmwWGHiGDK8D2XhmsaFMZHcC5foQkbHXZA+aC4clu6KhQ== X-Received: by 2002:a17:902:9a90:b029:da:ba07:efdc with SMTP id w16-20020a1709029a90b02900daba07efdcmr9255576plp.1.1607660583024; Thu, 10 Dec 2020 20:23:03 -0800 (PST) Received: from localhost.localdomain ([103.136.221.66]) by smtp.gmail.com with ESMTPSA id 19sm8623352pfu.85.2020.12.10.20.22.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Dec 2020 20:23:02 -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, shakeelb@google.com, guro@fb.com, samitolvanen@google.com, feng.tang@intel.com, neilb@suse.de, iamjoonsoo.kim@lge.com, rdunlap@infradead.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, Muchun Song Subject: [PATCH v4 0/7] Convert all THP vmstat counters to pages Date: Fri, 11 Dec 2020 12:19:47 +0800 Message-Id: <20201211041954.79543-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. 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. When the unit is bytes or kB, both clearly distinguishable by the B/KB suffix. But for the THP vmstat counters, we may make mistakes. For example, the below is some bug fix for the THP vmstat counters: - 7de2e9f195b9 ("mm: memcontrol: correct the NR_ANON_THPS counter of hierarchical memcg") - The first commit in this series ("fix NR_ANON_THPS accounting in charge moving") This patch series can make the code clear. And make all the unit of the THP vmstat counters in pages. Finally, the unit of the vmstat counters are pages, kB and bytes. The B/KB suffix can tell us that the unit is bytes or kB. The rest which is without suffix are pages. In this series, I changed the following vmstat counters unit from HPAGE_PMD_NR to pages. However, there is no change to the print format of output to user space. - NR_ANON_THPS - NR_FILE_THPS - NR_SHMEM_THPS - NR_SHMEM_PMDMAPPED - NR_FILE_PMDMAPPED Although every THP stats update overflows the per-cpu counter, resorting to atomic global updates. But this change is consistent with 4.7's 8f182270dfec ("mm/swap.c: flush lru pvecs on compound page arrival"): we accepted greater overhead for greater accuracy back then, so I think it's okay to do so for THP stats. Thanks Hugh for mentioning this. This was inspired by Johannes and Roman. Thanks to them. Changes in v3 -> v4: - Rename the first commit subject to "mm: memcontrol: fix NR_ANON_THPS accounting in charge moving". - Fix /proc/vmstat printing. Thanks to Johannes points out that. Changes in v2 -> v3: - Change the series subject from "Convert all vmstat counters to pages or bytes" to "Convert all THP vmstat counters to pages". - Remove convert of KB to B. 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 (7): mm: memcontrol: fix NR_ANON_THPS accounting in charge moving 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: make the slab calculation consistent drivers/base/node.c | 27 +++++----- fs/proc/meminfo.c | 10 ++-- include/linux/mmzone.h | 13 +++++ mm/filemap.c | 4 +- mm/huge_memory.c | 9 ++-- mm/khugepaged.c | 4 +- mm/memcontrol.c | 132 +++++++++++++++++++++++-------------------------- mm/page_alloc.c | 7 ++- mm/rmap.c | 19 ++++--- mm/shmem.c | 3 +- mm/vmstat.c | 11 ++++- 11 files changed, 130 insertions(+), 109 deletions(-)