Skip to contentSkip to conversation

mm-show_mem-optimize-si_meminfo_node-by-reducing-redundant-code.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message May 12, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/show_mem: optimize si_meminfo_node by reducing redundant code
has been removed from the -mm tree. Its filename was
mm-show_mem-optimize-si_meminfo_node-by-reducing-redundant-code.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Ye Liu <[email protected]>
Subject: mm/show_mem: optimize si_meminfo_node by reducing redundant code
Date: Tue, 25 Mar 2025 15:38:03 +0800

Refactors the si_meminfo_node() function by reducing redundant code and improving readability.

Moved the calculation of managed_pages inside the existing loop that processes pgdat->node_zones, eliminating the need for a separate loop.

Simplified the logic by removing unnecessary preprocessor conditionals.

Ensured that both totalram, totalhigh, and other memory statistics are consistently set without duplication.

This change results in cleaner and more efficient code without altering functionality.

---

 mm/show_mem.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
mm/show_mem.c renamed from mm/show_mem.c~mm-show_mem-optimize-si_meminfo_node-by-reducing-redundant-code +5 -11
@@ -94,26 +94,20 @@ void si_meminfo_node(struct sysinfo *val
 	unsigned long free_highpages = 0;
 	pg_data_t *pgdat = NODE_DATA(nid);
 
-	for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++)
-		managed_pages += zone_managed_pages(&pgdat->node_zones[zone_type]);
-	val->totalram = managed_pages;
-	val->sharedram = node_page_state(pgdat, NR_SHMEM);
-	val->freeram = sum_zone_node_page_state(nid, NR_FREE_PAGES);
-#ifdef CONFIG_HIGHMEM
 	for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) {
 		struct zone *zone = &pgdat->node_zones[zone_type];
-
+		managed_pages += zone_managed_pages(zone);
 		if (is_highmem(zone)) {
 			managed_highpages += zone_managed_pages(zone);
 			free_highpages += zone_page_state(zone, NR_FREE_PAGES);
 		}
 	}
+
+	val->totalram = managed_pages;
+	val->sharedram = node_page_state(pgdat, NR_SHMEM);
+	val->freeram = sum_zone_node_page_state(nid, NR_FREE_PAGES);
 	val->totalhigh = managed_highpages;
 	val->freehigh = free_highpages;
-#else
-	val->totalhigh = managed_highpages;
-	val->freehigh = free_highpages;
-#endif
 	val->mem_unit = PAGE_SIZE;
 }
 #endif

_

Patches currently in -mm which might be from [email protected] are

mm-rmap-rename-page__anon_vma-to-anon_vma-for-consistency.patch mm-rmap-fix-typo-in-comment-in-page_address_in_vma.patch mm-io-mapping-precompute-remap-protection-flags-for-clarity.patch mm-debug_page_alloc-improve-error-message-for-invalid-guardpage-minorder.patch mm-numa-remove-unnecessary-local-variable-in-alloc_node_data.patch