From: Shivank Garg <shivankg@amd.com>
To: <akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>
Cc: <vbabka@suse.cz>, <hillf.zj@alibaba-inc.com>,
<mgorman@techsingularity.net>, <hannes@cmpxchg.org>,
<shivankg@amd.com>
Subject: [PATCH] mm/vmstat: Fix placement of per-node stats in /proc/zoneinfo
Date: Thu, 25 Jul 2024 16:26:26 +0530 [thread overview]
Message-ID: <20240725105626.824-1-shivankg@amd.com> (raw)
The per-node stats in /proc/zoneinfo output are incorrectly inserted
between the first populated zone title and its specific stats. This
creates confusion while reading or parsing its output.
Output of /proc/zoneinfo
Node 0, zone DMA
per-node stats
nr_inactive_anon 2096
...
pages free 2814
boost 0
...
nr_free_pages 2814
...
Node 0, zone DMA32
pages free 357384
boost 0
...
...
Node 1, zone Normal
per-node stats
nr_inactive_anon 87606
...
pages free 51836334
boost 0
...
Node 1, zone Movable
pages free 0
boost 0
This patch relocates the per-node stats at the beginning for each node,
followed by the individual zone statistics. This fix results in a clearer
and more consistent output format.
/proc/zoneinfo output with proposed fix:
Node 0, per-node stats
nr_inactive_anon 2783
nr_active_anon 36
...
Node 0, zone DMA
pages free 3584
boost 0
min 46
...
...
Remove is_zone_first_populated() as it is not used anywhere else.
Fixes: e2ecc8a79ed4 ("mm, vmstat: print node-based stats in zoneinfo file")
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
mm/vmstat.c | 36 +++++++++++-------------------------
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 8507c497218b..1b32fab265e1 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1663,36 +1663,11 @@ static const struct seq_operations pagetypeinfo_op = {
.show = pagetypeinfo_show,
};
-static bool is_zone_first_populated(pg_data_t *pgdat, struct zone *zone)
-{
- int zid;
-
- for (zid = 0; zid < MAX_NR_ZONES; zid++) {
- struct zone *compare = &pgdat->node_zones[zid];
-
- if (populated_zone(compare))
- return zone == compare;
- }
-
- return false;
-}
-
static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
struct zone *zone)
{
int i;
seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name);
- if (is_zone_first_populated(pgdat, zone)) {
- seq_printf(m, "\n per-node stats");
- for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) {
- unsigned long pages = node_page_state_pages(pgdat, i);
-
- if (vmstat_item_print_in_thp(i))
- pages /= HPAGE_PMD_NR;
- seq_printf(m, "\n %-12s %lu", node_stat_name(i),
- pages);
- }
- }
seq_printf(m,
"\n pages free %lu"
"\n boost %lu"
@@ -1773,7 +1748,18 @@ static void zoneinfo_show_print(struct seq_file *m, pg_data_t *pgdat,
*/
static int zoneinfo_show(struct seq_file *m, void *arg)
{
+ int i;
pg_data_t *pgdat = (pg_data_t *)arg;
+
+ seq_printf(m, "Node %d, per-node stats", pgdat->node_id);
+ for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) {
+ unsigned long pages = node_page_state_pages(pgdat, i);
+
+ if (vmstat_item_print_in_thp(i))
+ pages /= HPAGE_PMD_NR;
+ seq_printf(m, "\n %-12s %lu", node_stat_name(i), pages);
+ }
+ seq_putc(m, '\n');
walk_zones_in_node(m, pgdat, false, false, zoneinfo_show_print);
return 0;
}
--
2.34.1
next reply other threads:[~2024-07-25 10:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 10:56 Shivank Garg [this message]
2024-07-25 19:47 ` Andrew Morton
2024-07-26 4:16 ` Garg, Shivank
2024-08-02 5:18 ` Shivank Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240725105626.824-1-shivankg@amd.com \
--to=shivankg@amd.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=hillf.zj@alibaba-inc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox