All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] x86, numa, emu: move size calculation into if block
@ 2011-03-03  1:25 Yinghai Lu
  2011-03-03  1:28 ` [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there Yinghai Lu
  2011-03-03  6:21 ` [PATCH 1/2] x86, numa, emu: move size calculation into if block Tejun Heo
  0 siblings, 2 replies; 5+ messages in thread
From: Yinghai Lu @ 2011-03-03  1:25 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tejun Heo,
	David Rientjes
  Cc: linux-kernel@vger.kernel.org



don't need to assign them that early.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 arch/x86/mm/numa_64.c        |   11 +++++------
 arch/x86/mm/numa_emulation.c |    3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)

Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ 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 */
 }
 
Index: linux-2.6/arch/x86/mm/numa_emulation.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_emulation.c
+++ 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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there
  2011-03-03  1:25 [PATCH 1/2] x86, numa, emu: move size calculation into if block Yinghai Lu
@ 2011-03-03  1:28 ` Yinghai Lu
  2011-03-03  6:22   ` Tejun Heo
  2011-03-03  6:21 ` [PATCH 1/2] x86, numa, emu: move size calculation into if block Tejun Heo
  1 sibling, 1 reply; 5+ messages in thread
From: Yinghai Lu @ 2011-03-03  1:28 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tejun Heo,
	David Rientjes
  Cc: linux-kernel@vger.kernel.org


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

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 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(-)

Index: linux-2.6/arch/x86/mm/numa_64.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_64.c
+++ 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;
 }
 
 /**
Index: linux-2.6/arch/x86/mm/numa_emulation.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_emulation.c
+++ linux-2.6/arch/x86/mm/numa_emulation.c
@@ -301,7 +301,7 @@ void __init numa_emulation(struct numa_m
 	const u64 max_addr = max_pfn << PAGE_SHIFT;
 	u8 *phys_dist = NULL;
 	size_t phys_size = 0;
-	int i, j, ret;
+	int i, j, ret, new_nr;
 
 	if (!emu_cmdline)
 		goto no_emu;
@@ -380,28 +380,39 @@ void __init numa_emulation(struct numa_m
 		if (emu_nid_to_phys[i] == NUMA_NO_NODE)
 			emu_nid_to_phys[i] = 0;
 
+	/* Transform distance table */
+	numa_reset_distance();
 	/*
-	 * Transform distance table.  numa_set_distance() ignores all
-	 * out-of-bound distances.  Just call it for every possible node
-	 * combination.
+	 * allocate numa_distance at first,
+	 *  it will set new numa_dist_cnt and default values
 	 */
-	numa_reset_distance();
-	for (i = 0; i < MAX_NUMNODES; i++) {
-		for (j = 0; j < MAX_NUMNODES; j++) {
-			int physi = emu_nid_to_phys[i];
-			int physj = emu_nid_to_phys[j];
-			int dist;
-
-			if (physi >= numa_dist_cnt || physj >= numa_dist_cnt)
-				dist = physi == physj ?
-					LOCAL_DISTANCE : REMOTE_DISTANCE;
-			else
+	new_nr = numa_alloc_distance();
+	if (new_nr < 0)
+		goto free_temp_phys;
+
+	/*
+	 * only set it when we have old phys_dist,
+	 * numa_alloc_distance() already set default values
+	 */
+	if (phys_dist)
+		for (i = 0; i < new_nr; i++) {
+			for (j = 0; j < new_nr; j++) {
+				int physi = emu_nid_to_phys[i];
+				int physj = emu_nid_to_phys[j];
+				int dist;
+
+				/* really need this check ? */
+				if (physi >= numa_dist_cnt ||
+				    physj >= numa_dist_cnt)
+					continue;
+
 				dist = phys_dist[physi * numa_dist_cnt + physj];
 
-			numa_set_distance(i, j, dist);
+				numa_set_distance(i, j, dist);
+			}
 		}
-	}
 
+free_temp_phys:
 	/* free the copied physical distance table */
 	if (phys_dist)
 		memblock_x86_free_range(__pa(phys_dist), __pa(phys_dist) + phys_size);
Index: linux-2.6/arch/x86/mm/numa_internal.h
===================================================================
--- linux-2.6.orig/arch/x86/mm/numa_internal.h
+++ 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,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] x86, numa, emu: move size calculation into if block
  2011-03-03  1:25 [PATCH 1/2] x86, numa, emu: move size calculation into if block Yinghai Lu
  2011-03-03  1:28 ` [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there Yinghai Lu
@ 2011-03-03  6:21 ` Tejun Heo
  1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2011-03-03  6:21 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, David Rientjes,
	linux-kernel@vger.kernel.org

Hey, Yinghai.

On Wed, Mar 02, 2011 at 05:25:06PM -0800, Yinghai Lu wrote:
> don't need to assign them that early.

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

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there
  2011-03-03  1:28 ` [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there Yinghai Lu
@ 2011-03-03  6:22   ` Tejun Heo
  2011-03-10  8:55     ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2011-03-03  6:22 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, David Rientjes,
	linux-kernel@vger.kernel.org

On Wed, Mar 02, 2011 at 05:28:32PM -0800, Yinghai Lu wrote:
> 
> 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
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

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

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there
  2011-03-03  6:22   ` Tejun Heo
@ 2011-03-10  8:55     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2011-03-10  8:55 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Yinghai Lu, Thomas Gleixner, H. Peter Anvin, David Rientjes,
	linux-kernel@vger.kernel.org


* Tejun Heo <tj@kernel.org> wrote:

> On Wed, Mar 02, 2011 at 05:28:32PM -0800, Yinghai Lu wrote:
> > 
> > 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
> > 
> > Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-03-10  8:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-03  1:25 [PATCH 1/2] x86, numa, emu: move size calculation into if block Yinghai Lu
2011-03-03  1:28 ` [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there Yinghai Lu
2011-03-03  6:22   ` Tejun Heo
2011-03-10  8:55     ` Ingo Molnar
2011-03-03  6:21 ` [PATCH 1/2] x86, numa, emu: move size calculation into if block Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.