[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V11 05/11] NUMA: Add numa_info structure to contain
From: |
Wanlong Gao |
Subject: |
[Qemu-devel] [PATCH V11 05/11] NUMA: Add numa_info structure to contain numa nodes info |
Date: |
Fri, 30 Aug 2013 11:10:44 +0800 |
Add the numa_info structure to contain the numa nodes memory,
VCPUs information and the future added numa nodes host memory
policies.
Reviewed-by: Eduardo Habkost <address@hidden>
Signed-off-by: Andre Przywara <address@hidden>
Signed-off-by: Wanlong Gao <address@hidden>
---
hw/i386/pc.c | 4 ++--
include/sysemu/sysemu.h | 8 ++++++--
monitor.c | 2 +-
numa.c | 23 ++++++++++++-----------
vl.c | 7 +++----
5 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3a620a1..2243184 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -653,14 +653,14 @@ static FWCfgState *bochs_bios_init(void)
unsigned int apic_id = x86_cpu_apic_id_from_index(i);
assert(apic_id < apic_id_limit);
for (j = 0; j < nb_numa_nodes; j++) {
- if (test_bit(i, node_cpumask[j])) {
+ if (test_bit(i, numa_info[j].node_cpu)) {
numa_fw_cfg[apic_id + 1] = cpu_to_le64(j);
break;
}
}
}
for (i = 0; i < nb_numa_nodes; i++) {
- numa_fw_cfg[apic_id_limit + 1 + i] = cpu_to_le64(node_mem[i]);
+ numa_fw_cfg[apic_id_limit + 1 + i] =
cpu_to_le64(numa_info[i].node_mem);
}
fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, numa_fw_cfg,
(1 + apic_id_limit + nb_numa_nodes) *
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 9440edb..e1e4320 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -9,6 +9,7 @@
#include "qapi-types.h"
#include "qemu/notify.h"
#include "qemu/main-loop.h"
+#include "qemu/bitmap.h"
/* vl.c */
@@ -130,8 +131,11 @@ extern QEMUClockType rtc_clock;
#define MAX_CPUMASK_BITS 255
extern int nb_numa_nodes;
extern int nb_numa_mem_nodes;
-extern uint64_t node_mem[MAX_NODES];
-extern unsigned long *node_cpumask[MAX_NODES];
+typedef struct node_info {
+ uint64_t node_mem;
+ DECLARE_BITMAP(node_cpu, MAX_CPUMASK_BITS);
+} NodeInfo;
+extern NodeInfo numa_info[MAX_NODES];
extern QemuOptsList qemu_numa_opts;
int numa_init_func(QemuOpts *opts, void *opaque);
void set_numa_nodes(void);
diff --git a/monitor.c b/monitor.c
index ee9744c..e5fc240 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1826,7 +1826,7 @@ static void do_info_numa(Monitor *mon, const QDict *qdict)
}
monitor_printf(mon, "\n");
monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
- node_mem[i] >> 20);
+ numa_info[i].node_mem >> 20);
}
}
diff --git a/numa.c b/numa.c
index 035fb86..3e2dfc1 100644
--- a/numa.c
+++ b/numa.c
@@ -53,7 +53,7 @@ static int numa_node_parse(NumaNodeOptions *opts)
}
for (cpus = opts->cpus; cpus; cpus = cpus->next) {
- bitmap_set(node_cpumask[nodenr], cpus->value, 1);
+ bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
}
if (opts->has_mem) {
@@ -64,7 +64,7 @@ static int numa_node_parse(NumaNodeOptions *opts)
fprintf(stderr, "qemu: invalid numa mem size: %s\n", opts->mem);
return -1;
}
- node_mem[nodenr] = mem_size;
+ numa_info[nodenr].node_mem = mem_size;
}
return 0;
@@ -88,7 +88,7 @@ static int numa_mem_parse(NumaMemOptions *opts)
if (opts->has_size) {
mem_size = opts->size;
- node_mem[nodenr] = mem_size;
+ numa_info[nodenr].node_mem = mem_size;
}
return 0;
@@ -160,7 +160,7 @@ void set_numa_nodes(void)
* and distribute the available memory equally across all nodes
*/
for (i = 0; i < nb_numa_nodes; i++) {
- if (node_mem[i] != 0) {
+ if (numa_info[i].node_mem != 0) {
break;
}
}
@@ -172,15 +172,16 @@ void set_numa_nodes(void)
* the final node gets the rest.
*/
for (i = 0; i < nb_numa_nodes - 1; i++) {
- node_mem[i] = (ram_size / nb_numa_nodes) & ~((1 << 23UL) - 1);
- usedmem += node_mem[i];
+ numa_info[i].node_mem = (ram_size / nb_numa_nodes) &
+ ~((1 << 23UL) - 1);
+ usedmem += numa_info[i].node_mem;
}
- node_mem[i] = ram_size - usedmem;
+ numa_info[i].node_mem = ram_size - usedmem;
}
uint64_t numa_total = 0;
for (i = 0; i < nb_numa_nodes; i++) {
- numa_total += node_mem[i];
+ numa_total += numa_info[i].node_mem;
}
if (numa_total != ram_size) {
fprintf(stderr, "qemu: numa nodes total memory size "
@@ -189,7 +190,7 @@ void set_numa_nodes(void)
}
for (i = 0; i < nb_numa_nodes; i++) {
- if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) {
+ if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) {
break;
}
}
@@ -199,7 +200,7 @@ void set_numa_nodes(void)
*/
if (i == nb_numa_nodes) {
for (i = 0; i < max_cpus; i++) {
- set_bit(i, node_cpumask[i % nb_numa_nodes]);
+ set_bit(i, numa_info[i % nb_numa_nodes].node_cpu);
}
}
}
@@ -212,7 +213,7 @@ void set_numa_modes(void)
for (cpu = first_cpu; cpu != NULL; cpu = cpu->next_cpu) {
for (i = 0; i < nb_numa_nodes; i++) {
- if (test_bit(cpu->cpu_index, node_cpumask[i])) {
+ if (test_bit(cpu->cpu_index, numa_info[i].node_cpu)) {
cpu->numa_node = i;
}
}
diff --git a/vl.c b/vl.c
index 0828aa3..99667a0 100644
--- a/vl.c
+++ b/vl.c
@@ -251,8 +251,7 @@ static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
int nb_numa_nodes;
int nb_numa_mem_nodes;
-uint64_t node_mem[MAX_NODES];
-unsigned long *node_cpumask[MAX_NODES];
+NodeInfo numa_info[MAX_NODES];
uint8_t qemu_uuid[16];
@@ -2887,8 +2886,8 @@ int main(int argc, char **argv, char **envp)
translation = BIOS_ATA_TRANSLATION_AUTO;
for (i = 0; i < MAX_NODES; i++) {
- node_mem[i] = 0;
- node_cpumask[i] = bitmap_new(MAX_CPUMASK_BITS);
+ numa_info[i].node_mem = 0;
+ bitmap_zero(numa_info[i].node_cpu, MAX_CPUMASK_BITS);
}
nb_numa_nodes = 0;
--
1.8.4
- [Qemu-devel] [PATCH V11 00/11] Add support for binding guest numa nodes to host numa nodes, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 03/11] NUMA: check if the total numa memory size is equal to ram_size, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 02/11] NUMA: split -numa option, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 07/11] NUMA: set guest numa nodes memory policy, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 06/11] NUMA: parse guest numa nodes memory policy, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 08/11] NUMA: add qmp command set-mem-policy to set memory policy for NUMA node, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 05/11] NUMA: Add numa_info structure to contain numa nodes info,
Wanlong Gao <=
- [Qemu-devel] [PATCH V11 04/11] NUMA: move numa related code to numa.c, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 09/11] NUMA: add hmp command set-mem-policy, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 01/11] NUMA: add NumaOptions, NumaNodeOptions and NumaMemOptions, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 10/11] NUMA: add qmp command query-numa, Wanlong Gao, 2013/08/29
- [Qemu-devel] [PATCH V11 11/11] NUMA: convert hmp command info_numa to use qmp command query_numa, Wanlong Gao, 2013/08/29