Skip to contentSkip to conversation

x86/mm: Optimize the for loop in numa_nodemask_from_meminfo()

PATCH New Yuntao Wang 1 participant 1 message Dec 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/mm: Optimize the for loop in numa_nodemask_from_meminfo()

Since only the first mi->nr_blks elements of the mi->blk array contain valid data, we do not need to iterate over the entire array.

---
 arch/x86/mm/numa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/numa.c +1 -1
index b29ceb19e46e..e84f14a9462d 100644
@@ -339,7 +339,7 @@ static void __init numa_nodemask_from_meminfo(nodemask_t *nodemask,
 {
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(mi->blk); i++)
+	for (i = 0; i < mi->nr_blks; i++)
 		if (mi->blk[i].start != mi->blk[i].end &&
 		    mi->blk[i].nid != NUMA_NO_NODE)
 			node_set(mi->blk[i].nid, *nodemask);
Signature · 1 line
2.43.0