Skip to contentSkip to conversation

x86: Fix calculation of size of numa_distance

PATCH In review Jack Steiner 3 participants 3 messages Feb 25, 2011

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

PATCH 1/1 x86: Fix calculation of size of numa_distance

Fix the calculation of the size of numa_distance array. It is 2-dimemsional array. This fixes early panics seen on large numa systems.

arch/x86/mm/numa_64.c +2 -1
Index: linux/arch/x86/mm/numa_64.c
===================================================================
@@ -414,7 +414,8 @@ static int __init numa_alloc_distance(vo
 
 	for_each_node_mask(i, nodes_parsed)
 		cnt = i;
-	size = ++cnt * sizeof(numa_distance[0]);
+	cnt++;
+	size = cnt * cnt * sizeof(numa_distance[0]);
 
 	phys = memblock_find_in_range(0, (u64)max_pfn_mapped << PAGE_SHIFT,
 				      size, PAGE_SIZE);
#1 lore raw
Quoted 10 lines · Jack Steiner

Fix the calculation of the size of numa_distance array. It is 2-dimemsional array. This fixes early panics seen on large numa systems.

Index: linux/arch/x86/mm/numa_64.c
===================================================================

arch/x86/mm/numa_64.c static int __init numa_alloc_distance(vo · line 421

Quoted 9 lines
arch/x86/mm/numa_64.c +2 -1
@@ -414,7 +414,8 @@ static int __init numa_alloc_distance(vo
 
 	for_each_node_mask(i, nodes_parsed)
 		cnt = i;
-	size = ++cnt * sizeof(numa_distance[0]);
+	cnt++;
+	size = cnt * cnt * sizeof(numa_distance[0]);
 
 	phys = memblock_find_in_range(0, (u64)max_pfn_mapped << PAGE_SHIFT,
 				      size, PAGE_SIZE);

Tejun has queued up a fix for this already. Tejun, mind sending the fix to me ASAP?

Thanks,

Ingo

#2 lore raw

[GIT PULL tip:x86/mm] fix incorrect NUMA distance table size calculation

Please pull from the following branch to receive NUMA distance table size fix.

git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc.git x86-mm

David Rientjes (1):
x86-64, NUMA: Fix size of numa_distance array

 arch/x86/mm/numa_64.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Thanks.

Signature · 1 line
tejun