From: Tejun Heo <tj@kernel.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Yinghai Lu <yinghai@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>
Cc: David Rientjes <rientjes@google.com>,
linux-kernel@vger.kernel.org,
Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH 1/3 tip:x86/mm] x86-64, NUMA: Prepare numa_emulation() for moving NUMA emulation into a separate file
Date: Fri, 18 Feb 2011 14:58:36 +0100 [thread overview]
Message-ID: <20110218135836.GG21209@htj.dyndns.org> (raw)
Update numa_emulation() such that, it
- takes @numa_meminfo and @numa_dist_cnt instead of directly
referencing the global variables.
- copies the distance table by iterating each distance with
node_distance() instead of memcpy'ing the distance table.
- tests emu_cmdline to determine whether emulation is requested and
fills emu_nid_to_phys[] with identity mapping if emulation is not
used. This allows the caller to call numa_emulation()
unconditionally and makes return value unncessary.
- defines dummy version if CONFIG_NUMA_EMU is disabled.
This patch doesn't introduce any behavior change.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
---
These three patches move NUMA emulation into a separate file. Once
reviewed, I'll push them through misc#x86-numa branch.
Thanks.
arch/x86/mm/numa_64.c | 56 +++++++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 23 deletions(-)
Index: work/arch/x86/mm/numa_64.c
===================================================================
--- work.orig/arch/x86/mm/numa_64.c
+++ work/arch/x86/mm/numa_64.c
@@ -797,17 +797,20 @@ static int __init split_nodes_size_inter
* Sets up the system RAM area from start_pfn to last_pfn according to the
* numa=fake command-line option.
*/
-static bool __init numa_emulation(void)
+static void __init numa_emulation(struct numa_meminfo *numa_meminfo,
+ int numa_dist_cnt)
{
static struct numa_meminfo ei __initdata;
static struct numa_meminfo pi __initdata;
const u64 max_addr = max_pfn << PAGE_SHIFT;
- int phys_dist_cnt = numa_distance_cnt;
u8 *phys_dist = NULL;
int i, j, ret;
+ if (!emu_cmdline)
+ goto no_emu;
+
memset(&ei, 0, sizeof(ei));
- pi = numa_meminfo;
+ pi = *numa_meminfo;
for (i = 0; i < MAX_NUMNODES; i++)
emu_nid_to_phys[i] = NUMA_NO_NODE;
@@ -830,19 +833,19 @@ static bool __init numa_emulation(void)
}
if (ret < 0)
- return false;
+ goto no_emu;
if (numa_cleanup_meminfo(&ei) < 0) {
pr_warning("NUMA: Warning: constructed meminfo invalid, disabling emulation\n");
- return false;
+ goto no_emu;
}
/*
* Copy the original distance table. It's temporary so no need to
* reserve it.
*/
- if (phys_dist_cnt) {
- size_t size = phys_dist_cnt * sizeof(numa_distance[0]);
+ if (numa_dist_cnt) {
+ size_t size = numa_dist_cnt * sizeof(phys_dist[0]);
u64 phys;
phys = memblock_find_in_range(0,
@@ -850,14 +853,18 @@ static bool __init numa_emulation(void)
size, PAGE_SIZE);
if (phys == MEMBLOCK_ERROR) {
pr_warning("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n");
- return false;
+ goto no_emu;
}
phys_dist = __va(phys);
- memcpy(phys_dist, numa_distance, size);
+
+ for (i = 0; i < numa_dist_cnt; i++)
+ for (j = 0; j < numa_dist_cnt; j++)
+ phys_dist[i * numa_dist_cnt + j] =
+ node_distance(i, j);
}
/* commit */
- numa_meminfo = ei;
+ *numa_meminfo = ei;
/*
* Transform __apicid_to_node table to use emulated nids by
@@ -886,18 +893,27 @@ static bool __init numa_emulation(void)
int physj = emu_nid_to_phys[j];
int dist;
- if (physi >= phys_dist_cnt || physj >= phys_dist_cnt)
+ if (physi >= numa_dist_cnt || physj >= numa_dist_cnt)
dist = physi == physj ?
LOCAL_DISTANCE : REMOTE_DISTANCE;
else
- dist = phys_dist[physi * phys_dist_cnt + physj];
+ dist = phys_dist[physi * numa_dist_cnt + physj];
numa_set_distance(i, j, dist);
}
}
- return true;
+ return;
+
+no_emu:
+ /* No emulation. Build identity emu_nid_to_phys[] for numa_add_cpu() */
+ for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++)
+ emu_nid_to_phys[i] = i;
}
-#endif /* CONFIG_NUMA_EMU */
+#else /* CONFIG_NUMA_EMU */
+static inline void numa_emulation(struct numa_meminfo *numa_meminfo,
+ int numa_dist_cnt)
+{ }
+#endif /* CONFIG_NUMA_EMU */
static int __init dummy_numa_init(void)
{
@@ -945,15 +961,9 @@ void __init initmem_init(void)
if (numa_cleanup_meminfo(&numa_meminfo) < 0)
continue;
-#ifdef CONFIG_NUMA_EMU
- /*
- * If requested, try emulation. If emulation is not used,
- * build identity emu_nid_to_phys[] for numa_add_cpu()
- */
- if (!emu_cmdline || !numa_emulation())
- for (j = 0; j < ARRAY_SIZE(emu_nid_to_phys); j++)
- emu_nid_to_phys[j] = j;
-#endif
+
+ numa_emulation(&numa_meminfo, numa_distance_cnt);
+
if (numa_register_memblks(&numa_meminfo) < 0)
continue;
next reply other threads:[~2011-02-18 13:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-18 13:58 Tejun Heo [this message]
2011-02-18 13:59 ` [PATCH 2/3 tip:x86/mm] x86-64, NUMA: Move NUMA emulation into numa_emulation.c Tejun Heo
2011-02-18 17:58 ` Yinghai Lu
2011-02-20 21:58 ` David Rientjes
2011-02-24 19:38 ` Yinghai Lu
2011-02-21 8:26 ` [PATCH UPDATED " Tejun Heo
2011-02-21 17:10 ` Yinghai Lu
2011-02-22 10:14 ` Tejun Heo
2011-02-18 14:00 ` [PATCH 3/3 tip:x86/mm] x86-64, NUMA: Add proper function comments to global functions 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=20110218135836.GG21209@htj.dyndns.org \
--to=tj@kernel.org \
--cc=gorcunov@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rientjes@google.com \
--cc=tglx@linutronix.de \
--cc=yinghai@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®