From patchwork Fri Dec 11 04:19:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11967209 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 E6F53C4361B for ; Fri, 11 Dec 2020 04:23:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 538C123ED2 for ; Fri, 11 Dec 2020 04:23:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 538C123ED2 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 BE8296B006C; Thu, 10 Dec 2020 23:23:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B99346B006E; Thu, 10 Dec 2020 23:23:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A890E6B0070; Thu, 10 Dec 2020 23:23:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id 92CD36B006C for ; Thu, 10 Dec 2020 23:23:26 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 63E7B180AD802 for ; Fri, 11 Dec 2020 04:23:26 +0000 (UTC) X-FDA: 77579707212.21.sand85_300cf40273fe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 3C3B3180442C4 for ; Fri, 11 Dec 2020 04:23:26 +0000 (UTC) X-HE-Tag: sand85_300cf40273fe X-Filterd-Recvd-Size: 7657 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 04:23:25 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id e2so6293987pgi.5 for ; Thu, 10 Dec 2020 20:23:25 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=+zNdjlNjaGbBbTl1joNFBgmnXlFZ8pwX/30snPIOtJc=; b=1XiX5y0gJqbD5SSIiumZ0LyPZNM1ekosj+wN+jmqz4Ib2jLVWgjuCp2gKxmvofctEf o3J0QyOC89ir8SyzeYt99WS5VUbpEO1OD0lVZwJV11nzX8zLpcPF4Aat9WzIpoDxUZ/D AnUZwFPC04zWG63iJBONvyedsRogVFB1S6ZRxCLS8ywA8NY36S94ra0DufLlrOnRnawL W4ZogsZtWEgQYVR2y4tzXeLpigm1HAJSHvf7pfe41BBxlbcpPfbdLyLo1YVH9Udzs+f5 Jkyy5hE2kUJeB3FLEnOglA71C3Z67W5YhPHafNMjSIs6bvYaooS0m2QwqcioXcEm+dQA ielA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+zNdjlNjaGbBbTl1joNFBgmnXlFZ8pwX/30snPIOtJc=; b=cIJh3W8gADeF3ghyPmY6vzFrEbDhqqBsnNUX1LaR6EGZBPHwt7zkGl8yqBW/PKsp7O hEQ1CYgUGVC13c+2GZthscKmpe7bojf6qzBKMYk5fCL4W/JuJtSZy4UCrPzymYinpRXi gD3NxWpSV1eaP9y9xTXxXYfWfEwVnLzU2r2+gsS4J4rKfkDsgoLr2HHKgBXxMOWlhUu9 fcZOYeFKk6Yxb1XXuIDF6JVx3px4hecGEFAVqaF7ncGbW5AIcFlhLKMnFIHiCx324zL4 Okwtw+KJ0VM3eXdnLSCM/hT42D+RqtvqbioZif5pRmjuMnq9P8J2OQku51xdO/ayjvkz sodQ== X-Gm-Message-State: AOAM531JZnnXwvg1MkXKLmUVOUbLIcoooQKV9iM9hpkqdlwy9wlRpx2+ slS6AlMHpW3pnWzg4RRVw5DQIA== X-Google-Smtp-Source: ABdhPJxr55yXFTu3oGTg5HJKqTWWlt1XbAYA22QdUZ72kpiYjt+UFd6FsjrFKMq14umappTGj9ibRA== X-Received: by 2002:a63:da03:: with SMTP id c3mr9789954pgh.133.1607660604856; Thu, 10 Dec 2020 20:23:24 -0800 (PST) Received: from localhost.localdomain ([103.136.221.66]) by smtp.gmail.com with ESMTPSA id 19sm8623352pfu.85.2020.12.10.20.23.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Dec 2020 20:23: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, 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 3/7] mm: memcontrol: convert NR_FILE_THPS account to pages Date: Fri, 11 Dec 2020 12:19:50 +0800 Message-Id: <20201211041954.79543-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201211041954.79543-1-songmuchun@bytedance.com> References: <20201211041954.79543-1-songmuchun@bytedance.com> 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: The unit of NR_FILE_THPS is HPAGE_PMD_NR. Converrt NR_FILE_THPS account to pages. Signed-off-by: Muchun Song --- drivers/base/node.c | 3 +-- fs/proc/meminfo.c | 2 +- include/linux/mmzone.h | 3 ++- mm/filemap.c | 2 +- mm/huge_memory.c | 3 ++- mm/khugepaged.c | 2 +- mm/memcontrol.c | 5 ++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 6da0c3508bc9..d5952f754911 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -466,8 +466,7 @@ static ssize_t node_read_meminfo(struct device *dev, HPAGE_PMD_NR), nid, K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR), - nid, K(node_page_state(pgdat, NR_FILE_THPS) * - HPAGE_PMD_NR), + nid, K(node_page_state(pgdat, NR_FILE_THPS)), nid, K(node_page_state(pgdat, NR_FILE_PMDMAPPED) * HPAGE_PMD_NR) #endif diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index a635c8a84ddf..7ea4679880c8 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -135,7 +135,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) show_val_kb(m, "ShmemPmdMapped: ", global_node_page_state(NR_SHMEM_PMDMAPPED) * HPAGE_PMD_NR); show_val_kb(m, "FileHugePages: ", - global_node_page_state(NR_FILE_THPS) * HPAGE_PMD_NR); + global_node_page_state(NR_FILE_THPS)); show_val_kb(m, "FilePmdMapped: ", global_node_page_state(NR_FILE_PMDMAPPED) * HPAGE_PMD_NR); #endif diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 4ac95448421c..67b6598c9ea4 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -215,7 +215,8 @@ enum node_stat_item { */ static __always_inline bool vmstat_item_print_in_thp(enum node_stat_item item) { - return item == NR_ANON_THPS; + return item == NR_ANON_THPS || + item == NR_FILE_THPS; } /* diff --git a/mm/filemap.c b/mm/filemap.c index 78090ee08ac2..9cc8b3ac9eac 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -207,7 +207,7 @@ static void unaccount_page_cache_page(struct address_space *mapping, if (PageTransHuge(page)) __dec_lruvec_page_state(page, NR_SHMEM_THPS); } else if (PageTransHuge(page)) { - __dec_lruvec_page_state(page, NR_FILE_THPS); + __mod_lruvec_page_state(page, NR_FILE_THPS, -HPAGE_PMD_NR); filemap_nr_thps_dec(mapping); } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 66ec454120de..1e24165fa53a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2748,7 +2748,8 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) if (PageSwapBacked(head)) __dec_lruvec_page_state(head, NR_SHMEM_THPS); else - __dec_lruvec_page_state(head, NR_FILE_THPS); + __mod_lruvec_page_state(head, NR_FILE_THPS, + -HPAGE_PMD_NR); } __split_huge_page(page, list, end); diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 494d3cb0b58a..76b3e064a72a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1869,7 +1869,7 @@ static void collapse_file(struct mm_struct *mm, if (is_shmem) __inc_lruvec_page_state(new_page, NR_SHMEM_THPS); else { - __inc_lruvec_page_state(new_page, NR_FILE_THPS); + __mod_lruvec_page_state(new_page, NR_FILE_THPS, HPAGE_PMD_NR); filemap_nr_thps_inc(mapping); } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b18e25a5cdf3..04985c8c6a0a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1533,7 +1533,7 @@ static struct memory_stat memory_stats[] = { * constant(e.g. powerpc). */ { "anon_thp", PAGE_SIZE, NR_ANON_THPS }, - { "file_thp", 0, NR_FILE_THPS }, + { "file_thp", PAGE_SIZE, NR_FILE_THPS }, { "shmem_thp", 0, NR_SHMEM_THPS }, #endif { "inactive_anon", PAGE_SIZE, NR_INACTIVE_ANON }, @@ -1565,8 +1565,7 @@ static int __init memory_stats_init(void) for (i = 0; i < ARRAY_SIZE(memory_stats); i++) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (memory_stats[i].idx == NR_FILE_THPS || - memory_stats[i].idx == NR_SHMEM_THPS) + if (memory_stats[i].idx == NR_SHMEM_THPS) memory_stats[i].ratio = HPAGE_PMD_SIZE; #endif VM_BUG_ON(!memory_stats[i].ratio);