From patchwork Thu Jul 25 10:56:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivank Garg X-Patchwork-Id: 13741795 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 0041FC3DA5D for ; Thu, 25 Jul 2024 10:57:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A2C66B008C; Thu, 25 Jul 2024 06:57:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6532B6B0092; Thu, 25 Jul 2024 06:57:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A4AA6B0093; Thu, 25 Jul 2024 06:57:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2BF326B008C for ; Thu, 25 Jul 2024 06:57:20 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B21FAC0294 for ; Thu, 25 Jul 2024 10:57:19 +0000 (UTC) X-FDA: 82377973398.07.A399B02 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2059.outbound.protection.outlook.com [40.107.100.59]) by imf07.hostedemail.com (Postfix) with ESMTP id C8BAA40006 for ; Thu, 25 Jul 2024 10:57:16 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=5fGXOppS; spf=pass (imf07.hostedemail.com: domain of shivankg@amd.com designates 40.107.100.59 as permitted sender) smtp.mailfrom=shivankg@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721904972; 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:dkim-signature; bh=hF44TkvbQjejf4C0rmC8LLHrtpXhCjEZR7KxT/EdJWk=; b=yzSllkHElKJTgM9FDDGWxHcIDdQINcEhRGHbC3umvM+xjtxINNICgpN8XD3bQaOvDXK64V RlLmLtKyI/ca7UOYrUpyuA6hH8ZBBF5B+cZ3/to+ZILmpvLxX9R9fw0IhtmsBXfmcYXjp1 HpZjT0IE4z7FCcO+Wjr4DbhYCvPdewA= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=5fGXOppS; spf=pass (imf07.hostedemail.com: domain of shivankg@amd.com designates 40.107.100.59 as permitted sender) smtp.mailfrom=shivankg@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1721904972; a=rsa-sha256; cv=pass; b=psT34/XiE68uejsvEVoFvI9b4T1Pih877I03LsziV07QadHpuVDzRh+3GZkhSItP0bEeOs wFyq7/xtivHEghgGy6Kvz297umcq63ubLgEUjFojKULlVtraeNg71VWDdrnEXJtPWNltKu /YSE2Q9+7OiJcJnI92sOTGdH2iESRjI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DX9d6gV4urvEfJitsw3FY6R1rscA9jlmCRZDgUw7hgBs8sc55jD6Zqhyp2+zuyGFBY0W6rF9v8neExrKHbZp7K8rfI3kS/hqy265cyu849jv5NExCruvQs/GBWZxyr655BZdpi46FvwzYQoUMWyoX50Ce0i879deAu7i7kXxobzi4HJk2o7TER4K7dry8jtwQo3qcqaiXzGL6PxuvmSxUCJnU6aTdqoysakojyG9rrI7eB6o6+hrc9Y1anQWRg2e0fv4m7cqFwVsVjpipU+GhXxeAnM+9WQcym8Nok81/ZfsiKbs7B0V0vrpj+SaYsuH8L2Ak6+HzaCytgCo8ezt9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hF44TkvbQjejf4C0rmC8LLHrtpXhCjEZR7KxT/EdJWk=; b=Emxv+/ecKbMWnzo5bosVGvywD6dC28ucGEUKcBvZYOVik5RHVyEoCwRd8ZC7Z/s5MWsx8dUCQj3EHzK2fcx6gDsyax/rK67qBIbQE7yHO5K7rYAYZAB3VfrKJIgR2mJFkY6RsLNFgkuQGoAcEzhaa/+RKYr7xGdf1pmg5rbJq3wl0Zv72ckR7SvNMAkHNXgtYbMtUvEc7ytUlielnf6E6CIMTGWw2XJBtaD+VMwqyDY7LBbZLsqYJAwmPVZ23RRcZEodiC3dzlajcYOXAoltRYmvHpSQ2B+28QUZCwNEf7+HlFRGoPm37mm4zCj2dnE47DAtxQVZUyM1K4J2KsmvLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hF44TkvbQjejf4C0rmC8LLHrtpXhCjEZR7KxT/EdJWk=; b=5fGXOppSMLMViCYpV3W7MAMrcc8lrP2z9TBpJbIOIrZMTF9c4GzmHg5vm7hk3zATDecKf8w/neP3NsFWn19mhLm9wTdRA7IwGdQb52h4iUm8HzWUvRgzFGEzOaOcSzES9r7kpIttDlCBU9G5Ox38e5sxc0pSONbwCbKWG68FoAo= Received: from MN0P220CA0002.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:52e::31) by BY5PR12MB4290.namprd12.prod.outlook.com (2603:10b6:a03:20e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.28; Thu, 25 Jul 2024 10:57:13 +0000 Received: from BL6PEPF00022575.namprd02.prod.outlook.com (2603:10b6:208:52e:cafe::dd) by MN0P220CA0002.outlook.office365.com (2603:10b6:208:52e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20 via Frontend Transport; Thu, 25 Jul 2024 10:57:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00022575.mail.protection.outlook.com (10.167.249.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Thu, 25 Jul 2024 10:57:12 +0000 Received: from BLR-L-SHIVAGAR.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 25 Jul 2024 05:57:09 -0500 From: Shivank Garg To: , , CC: , , , , Subject: [PATCH] mm/vmstat: Fix placement of per-node stats in /proc/zoneinfo Date: Thu, 25 Jul 2024 16:26:26 +0530 Message-ID: <20240725105626.824-1-shivankg@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00022575:EE_|BY5PR12MB4290:EE_ X-MS-Office365-Filtering-Correlation-Id: be345bad-2640-4e88-65ad-08dcac9889dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: ix4YwE59UCITS1WdiVfv0yvV0fKh0zD+gY6cHzsapG2gx8Wdg4QKkBmozLXg/osVK3vble+xZSgf/D7xgOs+jRY+pVloE8zisJADyTghPD+xsiAoF8KSHzTG6XTAhiLudb/4f/ebE4B1lfaze3QAJXUxeUMPWDN0QNGBKrpZi3fO6I+tT5Lij+Vly+YPDNj+DhjMxf4gjzYiKjUk2ukiMN5HRkC5d4rMwctx9T7+Xe/MUL/yVUES8/N0Hi6nSKu394VOx9vWLegYNcUmM61p/3tX62i79lopOeQL9RZBUjgGdjdpQ6K2RpRU1eHZ2t+oj8tuDJaP2Kf1SkVHjGAcii3R/5V3mXv2/Gx71on1jjjOM4jHnPi94t5zvDiDZzradfl2YRaUm3c+/D2fbXq7T1Vc2RNa52/VZ+ieV0JFbTyO+e6m4fxFdk2ONe8xZ8FAhT+MT7gkXrXH2QJU2/WtoHztn4ILosA/bUbZ43Dr4bdquVnHzXXpg0g9z+1ZidztYvuDhdbvsSlt60h5/R+T+Q9zW2VxQ9NmEIvLTZgNeQd9psuDFiG4dqKu498bwRU7oG8iYTyhTeV/SnC6mmeI4aO0HGyVz0NepowaER7ZddvXFVPwkIlu5qG1eeECbL9aHLZPoJ78pproXUI+LPxcfeAriotnY3eLOQF8MsNyYWzGSHrb33VWCfflvWE4Tdx7CKVRgf2kjqAvFTsChHIMWHXVKF7DKL2zqlQHtTFK/tEnMq6dXLXDUXE7snyRNMGv8HfNUmA+G7dOsXYS/KhKpfQWgsVt8gLO+7b0zf+2AuqoZm5+kBmK5Crb8rWsjxyBqgUD8w6ybkupWxu3N/Ot/hYl8aof1mZ0ChmETgan0fwFN+R9tSYdm0lTeBcfW0+VNIFZQyA76Q6FV4fDVTze3SGnz9TqQv728I1XRnz+lAgklLrfdGZluO7SbUHzyNAtctsHJkeEoJns8IBr44o90AiGe1b8qt/4OIU6WcGK+bikRs77pWwcDds+PTQOxJwdc9DQx/7tXF+Q9evuWf7eXCyM70IrtKIB+CgiOroZxBCsF7cebUDW5AXEeLoIrtYafyyTq5x6hUDyx/mX5ESCNQlroUHWOGMecEDNERubY9hDb+VKfVJa1b8g4i88TM9ep79+WZN4cK9IxkRnDt2RtLVqKflF94ba13n9o/zPPzc0sphUrFvnL2w/kIRCorXk5bMO703fbX4a2q9I3ZymLOn+sMUarf1Lpgz8pY6jY1MVau6m/C22aLhXve1HOTeWmPtsFNF6DrORSfBb0oC9nrr7HehnSVybeE0oqQJDYUCcEJVE4V8fOBmK1TdttsnZg8J33Mvr9y9dx7MGEumSnYfzMjwcimBqE4zvBWegvoib23cIk0pe6gTfPa9xfJpUZLe++212NfKwFQA/u6BpAI3jLBPCLTi89JN+Egf4v5wDiALf1X1WyoXLJrDPwTBn X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2024 10:57:12.6915 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be345bad-2640-4e88-65ad-08dcac9889dc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00022575.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4290 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C8BAA40006 X-Stat-Signature: xcratewfs67k7q1wiprtof68jxj4gr6g X-Rspam-User: X-HE-Tag: 1721905036-354137 X-HE-Meta: U2FsdGVkX19SwBo7O3kMYxzUYs+r/q/6YN1hU0HnLRh/xIRv9KIfsHeLGK19FF8h7UImPzA1N14fBF29pdV1r28MxXi0KTu/itcMFpAdoDHfxhQcaKGOh7WFWadmcoSfJLV7hO8VZk5I1GPXzybiSyXSE5AUfdzbAWp9U2nYzTUbD3tiJCd7n4SSUFqhfqkljcZm5Z67GGhJ5Vq6ZIskIqXLPbaYeqXDQe5M4ReCmevQ5fqVxFipFWZ8jw3nhv2CmTrPHGXGKMzFvpkdKL1ue48byqls7aKzBOilfapo8SkGMsRm55LpweQt7u6TmSkKTemOyDpZ0wT2S0UhK/OfPFmgHcM8fBRhOHzz581njwB2tEa8pzCIZUEjqrtS9WZdhwaYH7CZeOPrQ2fCUY6eYS3XerdAdMh6sxLVudxA4ZRpsfSLsxyEwWRbS+UqgoNLaZpg3x9krnj+doK6bRLUmZpq8Zs3TI25Cv+aUi1U6zw7FqUE9dz9ydeCElXzrr8bwo6Q7Hv3joPbdnB7viUlP/HoETtIOtndm6lJG8Lb+we8IV71A1AROTGuf3ynapg4pde2pC1slipa5SRnx61B+sPbLF8TZHhVWvzWGxN4euMkAEFNhHxrCetuBlvWsfToKl0RejoD+U4a20oim5yJEBUKMgDwp4fNQflSMApSimFv95EcIyO3Jvhv3ybYDZtnMbB4lf4PJfXL5eJVrqlJXSZmBvnS7GdLwso+M2Mqo9ZyLRabGL3Eyu7SmvDodldUm5mziTdFfDvOGbV8c/n49fPz2TXGX7Jjsg8Vq5wprTVVrLwZwLZQb/V4Ek5vmuqIQlw88hn5SpuEcYiO1rBbuA3kdRx6Bkv5vAUlwrJfUUg2Dm8B0eFPV0FbSypYhdnIQTAFdBKfBpyHM2r6JbPVK2CEFBZZX4px+ACDwBoXC06mhIzoveOSexUHuwhIJwLf5YQ301/2clB5G/WgwKG u/VZqKoo P61fKZA23Kh/eMYP8Yfa5KB1yE4xvCfPIEwt5XuYBUVB92d4zY/lqugmupWAc6oT54lB1vhKsz8yKYRRgFgTVHHJ16RDKXDAyZKsfvab8LV152r5Y64H8UTdCeFzxwqGUknPaC1y7TmOEJ6u+ICOyA4jH9PO8QbmEN/6V+BzYK1RNDrFe6ZaP3zmH83q5otKUqrA8zxMe72YybYkhWH4Q6cDUMFp/AwM69ykRDOaFAMTe2xLI6rGcQJJ76UysF7PpvWUmdrXn+xReFR41Fs+6E1vz4d7Op+Upu01nvO/WWaH+I4TbMVW8VcOTasD8y805TgSSqgmZ1V3R1UFPiOVvYba5WE67Cxn7/b6tsw7H/xErBm4/ngkisF3XxfQClN2wypbh 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: List-Subscribe: List-Unsubscribe: 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 --- 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; }