public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] NUMA emulation x86_64: numa=fake parameter for custom nodes distance
@ 2011-11-18 11:55 Petr Holasek
  2011-11-18 11:55 ` [PATCH 2/2] NUMA emulation x86_64: Documentation changes in boot-options.txt Petr Holasek
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Petr Holasek @ 2011-11-18 11:55 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton
  Cc: linux-kernel, x86, Anton Arapov, Petr Holasek

As default, when numa emulation is turned on, node distance table
uses physical distance, so for 4 nodes emulated on 1 physical table is

node   0   1   2   3
0:  10  10  10  10
1:  10  10  10  10
2:  10  10  10  10
3:  10  10  10  10

This patch adds new [distance] argument to

numa=fake=<number/size of nodes>[,distance]

When distance argument is used, it sets linear distance between nodes
like that:

    __distance__
___|___     ____|___     ________     ________
|       |   |        |   |        |   |        |
| node1 |---| node 2 |---| node 3 |---| node 4 |
|_______|   |________|   |________|   |________|
|                        |             |
|                        |             |
|____distance * 2________|             |
|                                      |
|____________distance * 3______________|

This feature might be useful for testing some numa awareness features in
both user and kernel spaces.

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 arch/x86/mm/numa_emulation.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
index d0ed086..1824972 100644
--- a/arch/x86/mm/numa_emulation.c
+++ b/arch/x86/mm/numa_emulation.c
@@ -309,6 +309,8 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 	u8 *phys_dist = NULL;
 	size_t phys_size = numa_dist_cnt * numa_dist_cnt * sizeof(phys_dist[0]);
 	int max_emu_nid, dfl_phys_nid;
+	unsigned long dist_level;
+	char *c;
 	int i, j, ret;
 
 	if (!emu_cmdline)
@@ -404,6 +406,17 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 		if (emu_nid_to_phys[i] == NUMA_NO_NODE)
 			emu_nid_to_phys[i] = dfl_phys_nid;
 
+	/* load distance level parameter */
+	dist_level = -1;
+	c = strchr(emu_cmdline, ',');
+	if (c) {
+		c++;
+		ret = kstrtoul(c, 10, &dist_level);
+		if (ret < 0 || dist_level < LOCAL_DISTANCE ||
+				dist_level * max_emu_nid > ULONG_MAX)
+			dist_level = -1;
+	}
+
 	/* transform distance table */
 	numa_reset_distance();
 	for (i = 0; i < max_emu_nid + 1; i++) {
@@ -418,6 +431,9 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt)
 			else
 				dist = phys_dist[physi * numa_dist_cnt + physj];
 
+			if (dist_level != -1 && i != j)
+				dist = abs(i - j) * dist_level;
+
 			numa_set_distance(i, j, dist);
 		}
 	}
-- 
1.7.6.4


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

end of thread, other threads:[~2011-11-21 22:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 11:55 [PATCH 1/2] NUMA emulation x86_64: numa=fake parameter for custom nodes distance Petr Holasek
2011-11-18 11:55 ` [PATCH 2/2] NUMA emulation x86_64: Documentation changes in boot-options.txt Petr Holasek
2011-11-18 19:53 ` [PATCH 1/2] NUMA emulation x86_64: numa=fake parameter for custom nodes distance Andrew Morton
2011-11-19  0:31   ` Petr Holasek
2011-11-20  2:09     ` David Rientjes
2011-11-21 20:41       ` Petr Holasek
2011-11-21 22:24         ` David Rientjes
2011-11-20  2:06 ` [PATCH 1/2] " David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox