From: Yinghai Lu <yinghai@kernel.org>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
"H. Peter Anvin" <hpa@zytor.com>, Tejun Heo <tj@kernel.org>,
David Rientjes <rientjes@google.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there
Date: Wed, 02 Mar 2011 17:28:32 -0800 [thread overview]
Message-ID: <4D6EEEC0.3040001@kernel.org> (raw)
In-Reply-To: <4D6EEDF2.6090201@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,
next prev parent reply other threads:[~2011-03-03 1:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2011-03-03 6:22 ` [PATCH 2/2] x86, numa, emu: only transform numa_distance if SLIT is there 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D6EEEC0.3040001@kernel.org \
--to=yinghai@kernel.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rientjes@google.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.