From patchwork Tue Aug 16 08:44:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 12944487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C101DC2BB41 for ; Tue, 16 Aug 2022 08:38:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59E968D0001; Tue, 16 Aug 2022 04:38:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 526FE6B0075; Tue, 16 Aug 2022 04:38:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C7728D0001; Tue, 16 Aug 2022 04:38:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2A3BB6B0073 for ; Tue, 16 Aug 2022 04:38:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id F1AE91A0381 for ; Tue, 16 Aug 2022 08:38:47 +0000 (UTC) X-FDA: 79804805094.22.DFBBCC5 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf20.hostedemail.com (Postfix) with ESMTP id BB4311C01AC for ; Tue, 16 Aug 2022 08:38:46 +0000 (UTC) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M6PZv4SZ8zXdkF; Tue, 16 Aug 2022 16:34:31 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 16:38:42 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 16:38:42 +0800 From: Kefeng Wang To: Andrew Morton , Greg Kroah-Hartman , CC: , Liu Shixin , "Kefeng Wang" Subject: [PATCH RFC] mm, proc: add PcpFree to meminfo Date: Tue, 16 Aug 2022 16:44:26 +0800 Message-ID: <20220816084426.135528-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660639127; a=rsa-sha256; cv=none; b=U/BlI3i7RGoTN5qkTJnwPGhJ/Kklcys6DXKJMFaNStQkIg7om3euHdyJokp9iSmcREHNTq zyMlx7/QdTqixA8jQPKXm5kXBBLR9y++NNxNKGcV6nnKJkowjE9OjGk5dAn4tFKXMfl/TG aQaaBm6BzhDWJdHaAP8Tjh2AzleaCWE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660639127; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=q3K/vAv6ehxviN1sahcqwzC2jNqRMshwqYp0ncUEUjA=; b=oUJrK7Q8h/Mx2EmxyXKTXXHsTfUMzgYg5bvbWkBRhtVrNyNR2uIUGuvWtJxKAMtApxf/of UKrMggN51gGrLU70QJTKIfMumrND3SLOq3p+B6Cu+1IaZ4Jw22/mNtf9fnH7CNCOB0RTvL /p2IrML4SkRX600CBpozCPc1v8fw8HY= Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BB4311C01AC X-Stat-Signature: 7xjd3y3rmingaxjc8wcqagim3q1e95y7 X-Rspam-User: X-HE-Tag: 1660639126-850542 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: From: Liu Shixin The page on pcplist could be used, but not counted into memory free or avaliable, and pcp_free is only showed by show_mem(). Since commit d8a759b57035 ("mm, page_alloc: double zone's batchsize"), there is a significant decrease in the display of free memory, with a large number of cpus and nodes, the number of pages in the percpu list can be very large, so it is better to let user to know the pcp count. Signed-off-by: Liu Shixin Signed-off-by: Kefeng Wang --- drivers/base/node.c | 14 +++++++++++++- fs/proc/meminfo.c | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index eb0f43784c2b..846864e45db6 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -375,6 +375,9 @@ static ssize_t node_read_meminfo(struct device *dev, struct sysinfo i; unsigned long sreclaimable, sunreclaimable; unsigned long swapcached = 0; + unsigned long free_pcp = 0; + struct zone *zone; + int cpu; si_meminfo_node(&i, nid); sreclaimable = node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B); @@ -382,9 +385,17 @@ static ssize_t node_read_meminfo(struct device *dev, #ifdef CONFIG_SWAP swapcached = node_page_state_pages(pgdat, NR_SWAPCACHE); #endif + for_each_populated_zone(zone) { + if (zone_to_nid(zone) != nid) + continue; + for_each_online_cpu(cpu) + free_pcp += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count; + } + len = sysfs_emit_at(buf, len, "Node %d MemTotal: %8lu kB\n" "Node %d MemFree: %8lu kB\n" + "Node %d PcpFree: %8lu kB\n" "Node %d MemUsed: %8lu kB\n" "Node %d SwapCached: %8lu kB\n" "Node %d Active: %8lu kB\n" @@ -397,7 +408,8 @@ static ssize_t node_read_meminfo(struct device *dev, "Node %d Mlocked: %8lu kB\n", nid, K(i.totalram), nid, K(i.freeram), - nid, K(i.totalram - i.freeram), + nid, K(free_pcp), + nid, K(i.totalram - i.freeram - free_pcp), nid, K(swapcached), nid, K(node_page_state(pgdat, NR_ACTIVE_ANON) + node_page_state(pgdat, NR_ACTIVE_FILE)), diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 6e89f0e2fd20..672c784dfc8a 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -38,6 +38,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v) unsigned long pages[NR_LRU_LISTS]; unsigned long sreclaimable, sunreclaim; int lru; + unsigned long free_pcp = 0; + struct zone *zone; + int cpu; si_meminfo(&i); si_swapinfo(&i); @@ -55,8 +58,14 @@ static int meminfo_proc_show(struct seq_file *m, void *v) sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B); sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B); + for_each_populated_zone(zone) { + for_each_online_cpu(cpu) + free_pcp += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count; + } + show_val_kb(m, "MemTotal: ", i.totalram); show_val_kb(m, "MemFree: ", i.freeram); + show_val_kb(m, "PcpFree: ", free_pcp); show_val_kb(m, "MemAvailable: ", available); show_val_kb(m, "Buffers: ", i.bufferram); show_val_kb(m, "Cached: ", cached);