Skip to contentSkip to conversation

x86, numa, emu: move size calculation into if block

PATCH In review Yinghai Lu 3 participants 5 messages Mar 3, 2011 – Mar 10, 2011

Subsystems (2)
lore
Share & tools
lore

Yinghai Lu

author
#0 lore raw

PATCH 1/2 x86, numa, emu: move size calculation into if block

don't need to assign them that early.

---
 arch/x86/mm/numa_64.c        |   11 +++++------
 arch/x86/mm/numa_emulation.c |    3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/mm/numa_64.c +5 -6
Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
@@ -390,13 +390,12 @@ static void __init numa_nodemask_from_me
  */
 void __init numa_reset_distance(void)
 {
-	size_t size = numa_distance_cnt * numa_distance_cnt * sizeof(numa_distance[0]);
-
 	/* numa_distance could be 1LU marking allocation failure, test cnt */
-	if (numa_distance_cnt)
-		memblock_x86_free_range(__pa(numa_distance),
-					__pa(numa_distance) + size);
-	numa_distance_cnt = 0;
+	if (numa_distance_cnt) {
+		size_t size = numa_distance_cnt * numa_distance_cnt * sizeof(numa_distance[0]);
+		memblock_x86_free_range(__pa(numa_distance), __pa(numa_distance) + size);
+		numa_distance_cnt = 0;
+	}
 	numa_distance = NULL;	/* enable table creation */
 }
 
arch/x86/mm/numa_emulation.c +2 -1
Index: linux-2.6/arch/x86/mm/numa_emulation.c
===================================================================
@@ -300,7 +300,7 @@ void __init numa_emulation(struct numa_m
 	static struct numa_meminfo pi __initdata;
 	const u64 max_addr = max_pfn << PAGE_SHIFT;
 	u8 *phys_dist = NULL;
-	size_t phys_size = numa_dist_cnt * numa_dist_cnt * sizeof(phys_dist[0]);
+	size_t phys_size = 0;
 	int i, j, ret;
 
 	if (!emu_cmdline)
@@ -341,6 +341,7 @@ void __init numa_emulation(struct numa_m
 	if (numa_dist_cnt) {
 		u64 phys;
 
+		phys_size = numa_dist_cnt * numa_dist_cnt * sizeof(phys_dist[0]);
 		phys = memblock_find_in_range(0,
 					      (u64)max_pfn_mapped << PAGE_SHIFT,
 					      phys_size, PAGE_SIZE);
author
#1 lore raw

PATCH 2/2 x86, numa, emu: only transform numa_distance if SLIT is there

during copying should only copy with NEW numa_dist_cnt size. need to call numa_alloc_dist() at first, and it will set default values.

So we will not need to go over the big matrix without meaning.

Need to make numa_alloc_distance to return new numa_dist_cnt

---
 arch/x86/mm/numa_64.c        |    4 +--
 arch/x86/mm/numa_emulation.c |   45 ++++++++++++++++++++++++++-----------------
 arch/x86/mm/numa_internal.h  |    1 
 3 files changed, 31 insertions(+), 19 deletions(-)
arch/x86/mm/numa_64.c +2 -2
Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
@@ -399,7 +399,7 @@ void __init numa_reset_distance(void)
 	numa_distance = NULL;	/* enable table creation */
 }
 
-static int __init numa_alloc_distance(void)
+int __init numa_alloc_distance(void)
 {
 	nodemask_t nodes_parsed;
 	size_t size;
@@ -435,7 +435,7 @@ static int __init numa_alloc_distance(vo
 				LOCAL_DISTANCE : REMOTE_DISTANCE;
 	printk(KERN_DEBUG "NUMA: Initialized distance table, cnt=%d\n", cnt);
 
-	return 0;
+	return cnt;
 }
 
 /**
arch/x86/mm/numa_emulation.c +28 -17

63 lines not on this page · raw message

arch/x86/mm/numa_internal.h +1 -0
Index: linux-2.6/arch/x86/mm/numa_internal.h
===================================================================
@@ -18,6 +18,7 @@ struct numa_meminfo {
 void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi);
 int __init numa_cleanup_meminfo(struct numa_meminfo *mi);
 void __init numa_reset_distance(void);
+int numa_alloc_distance(void);
 
 #ifdef CONFIG_NUMA_EMU
 void __init numa_emulation(struct numa_meminfo *numa_meminfo,
#2 lore raw

Re: [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there

Quoted 9 lines · Yinghai Lu

during copying should only copy with NEW numa_dist_cnt size. need to call numa_alloc_dist() at first, and it will set default values.

So we will not need to go over the big matrix without meaning.

Need to make numa_alloc_distance to return new numa_dist_cnt

I'm not taking this. You can't send the same change twice and expect different result.

Signature · 1 line
tejun
#3 lore raw

Re: [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there

Quoted 5 lines · Tejun Heo
Quoted 4 lines · Yinghai Lu

during copying should only copy with NEW numa_dist_cnt size. need to call numa_alloc_dist() at first, and it will set default values.

Quoted 8 lines
Quoted 5 lines

So we will not need to go over the big matrix without meaning.

Need to make numa_alloc_distance to return new numa_dist_cnt

I'm not taking this. You can't send the same change twice and expect different result.

Ping: what's the status of this - Yinghai, are you working on an improved version of these (and related) patches, as per the review suggestions from Tejun - or are you dropping them?

Thanks,

Ingo

#4 lore raw
In reply to Yinghai Lu

Hey, Yinghai.

Quoted 1 line · Yinghai Lu

don't need to assign them that early.

You know I'm not gonna take this, right? Don't make it uglier.

Thanks.

Signature · 1 line
tejun