From patchwork Tue Dec 8 04:18:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11957515 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 54D87C4361B for ; Tue, 8 Dec 2020 04:20:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB6F6239EB for ; Tue, 8 Dec 2020 04:20:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB6F6239EB 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 6D7B28D001A; Mon, 7 Dec 2020 23:20:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 685138D0002; Mon, 7 Dec 2020 23:20:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 576158D001A; Mon, 7 Dec 2020 23:20:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0210.hostedemail.com [216.40.44.210]) by kanga.kvack.org (Postfix) with ESMTP id 3C21A8D0002 for ; Mon, 7 Dec 2020 23:20:54 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0B2FD181AEF21 for ; Tue, 8 Dec 2020 04:20:54 +0000 (UTC) X-FDA: 77568814428.28.skin76_0a0e5d1273e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id D93056C3E for ; Tue, 8 Dec 2020 04:20:53 +0000 (UTC) X-HE-Tag: skin76_0a0e5d1273e4 X-Filterd-Recvd-Size: 5944 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Dec 2020 04:20:53 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id c12so5553115pfo.10 for ; Mon, 07 Dec 2020 20:20:52 -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=INwAUa8avMAOYbaB9rtoZiE/Uy1WuPgrXID/tKq7Y4o=; b=h/6saWcxTLU/DKFG4oIjuuEDovFaZD1Ql3H24mQ6ZWdxdgezFfyhebiqTeFEKAN3Tl En+Ha/3H7N2CkoQD6qgmYoM/vrvVSNRjDmmsaVrJDh4wkkCNV6OOZCERX4tO5/u3g2Tz d7YAzvkgah5iQyIP3ylMC62iw7/Y3NPAhGBMnlBQ58mB9zlkWhPTclA3CuPDSbnlXSc7 9WCjSpbQgg1FBySH7zUl9Dnrh4UF2wRMw34n+1CsWqJChlCjwVWi7Rgz0V+nli8AHDW8 n4KJWsxHERxQ0QGjcsNOdDjH2hjXp2mZhsBTJkMe+Dzhho2XWjyUNIBrnxu9VyX71VBT wFhg== 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=INwAUa8avMAOYbaB9rtoZiE/Uy1WuPgrXID/tKq7Y4o=; b=bJ9jYNSdmmhWjd98LEyvjwVav9RviTK0ZfXomXo6PIbVUDKo48O20EVpm2JoU4uuQm PomMSlvnFTxtCUPJN419PKwlid5igpaNb8jw/q/2jR5yxbU+sh7iI1g6gW4G1ish5aIu s7pvMHV0ZcWl+LURaq7EKSm7aLDrahYR1EbLK3pIcyIllPx+8FiQDQ1Ok+Op3AYmOFgv 7y3MDrYXIai83UB8hhBUOaeBNNKvSgbKfSAYCOBVn2DisJlFyM5E1Owx2xZB4gPYhYWp ushp0FiSXMgdfNBTTcFrln7qwv++7reoXb6PBpoGHcVZkq13FAGF3vsTjyTuXsihliHg U/QA== X-Gm-Message-State: AOAM530BdlXhZtktRNABf6c6Vi1ZWfqN8AbilIbnHf462dm9BZhMnf5Q ul4Br5SoongrGFLppvylQ8m0RA== X-Google-Smtp-Source: ABdhPJwg6s8o790FlKSFquJnMGwqcffA65CpEykidVkNyFYWLAYFLP1GVkP70naEE9TEtRS09jE/VA== X-Received: by 2002:a17:90a:6fc7:: with SMTP id e65mr2280093pjk.116.1607401251862; Mon, 07 Dec 2020 20:20:51 -0800 (PST) Received: from localhost.localdomain ([103.136.221.70]) by smtp.gmail.com with ESMTPSA id mr7sm1031166pjb.31.2020.12.07.20.20.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 20:20:51 -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 v3 0/7] Convert all THP vmstat counters to pages Date: Tue, 8 Dec 2020 12:18:40 +0800 Message-Id: <20201208041847.72122-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") - Not committed which is the first commit in this series ("mm: memcontrol: fix NR_ANON_THPS account") 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. As Hugh said, "It does need to be recognized that, with these changes, 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." This was inspired by Johannes and Roman. Thanks to them. 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 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: make the slab calculation consistent drivers/base/node.c | 15 ++---- fs/proc/meminfo.c | 10 ++-- mm/filemap.c | 4 +- mm/huge_memory.c | 9 ++-- mm/khugepaged.c | 4 +- mm/memcontrol.c | 139 ++++++++++++++++++++++++++-------------------------- mm/page_alloc.c | 7 ++- mm/rmap.c | 19 ++++--- mm/shmem.c | 3 +- 9 files changed, 107 insertions(+), 103 deletions(-)