aboutsummaryrefslogtreecommitdiff
path: root/numa.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-01-13 14:38:21 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-01-13 14:38:21 +0000
commitb6af8ea60282df514f87d32e36afd1c9aeee28c8 (patch)
tree4b99d36284c8500225cd3bdf29b4287df51d16d9 /numa.c
parentfdbd92f738693abfda60d2d1fc075cd796f33f80 (diff)
parent8ed877b78498c89aa7ce5c76aa20841ff5072796 (diff)
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging
x86 and machine queue, 2017-01-17 Includes i386, CPU, NUMA, and memory backends changes. i386: target/i386: Fix bad patch application to translate.c CPU: qmp: Report QOM type name on query-cpu-definitions NUMA: numa: make -numa parser dynamically allocate CPUs masks Memory backends: qom: remove unused header monitor: reuse user_creatable_add_opts() instead of user_creatable_add() monitor: fix qmp/hmp query-memdev not reporting IDs of memory backends # gpg: Signature made Thu 12 Jan 2017 17:53:11 GMT # gpg: using RSA key 0x2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/x86-and-machine-pull-request: qmp: Report QOM type name on query-cpu-definitions numa: make -numa parser dynamically allocate CPUs masks target/i386: Fix bad patch application to translate.c monitor: fix qmp/hmp query-memdev not reporting IDs of memory backends monitor: reuse user_creatable_add_opts() instead of user_creatable_add() qom: remove unused header Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'numa.c')
-rw-r--r--numa.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/numa.c b/numa.c
index 9c09e45e7d..379bc8a140 100644
--- a/numa.c
+++ b/numa.c
@@ -266,20 +266,19 @@ static char *enumerate_cpus(unsigned long *cpus, int max_cpus)
static void validate_numa_cpus(void)
{
int i;
- DECLARE_BITMAP(seen_cpus, MAX_CPUMASK_BITS);
+ unsigned long *seen_cpus = bitmap_new(max_cpus);
- bitmap_zero(seen_cpus, MAX_CPUMASK_BITS);
for (i = 0; i < nb_numa_nodes; i++) {
- if (bitmap_intersects(seen_cpus, numa_info[i].node_cpu,
- MAX_CPUMASK_BITS)) {
+ if (bitmap_intersects(seen_cpus, numa_info[i].node_cpu, max_cpus)) {
bitmap_and(seen_cpus, seen_cpus,
- numa_info[i].node_cpu, MAX_CPUMASK_BITS);
+ numa_info[i].node_cpu, max_cpus);
error_report("CPU(s) present in multiple NUMA nodes: %s",
enumerate_cpus(seen_cpus, max_cpus));
+ g_free(seen_cpus);
exit(EXIT_FAILURE);
}
bitmap_or(seen_cpus, seen_cpus,
- numa_info[i].node_cpu, MAX_CPUMASK_BITS);
+ numa_info[i].node_cpu, max_cpus);
}
if (!bitmap_full(seen_cpus, max_cpus)) {
@@ -291,12 +290,17 @@ static void validate_numa_cpus(void)
"in NUMA config");
g_free(msg);
}
+ g_free(seen_cpus);
}
void parse_numa_opts(MachineClass *mc)
{
int i;
+ for (i = 0; i < MAX_NODES; i++) {
+ numa_info[i].node_cpu = bitmap_new(max_cpus);
+ }
+
if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
exit(1);
}
@@ -362,7 +366,7 @@ void parse_numa_opts(MachineClass *mc)
numa_set_mem_ranges();
for (i = 0; i < nb_numa_nodes; i++) {
- if (!bitmap_empty(numa_info[i].node_cpu, MAX_CPUMASK_BITS)) {
+ if (!bitmap_empty(numa_info[i].node_cpu, max_cpus)) {
break;
}
}
@@ -397,6 +401,7 @@ void numa_post_machine_init(void)
CPU_FOREACH(cpu) {
for (i = 0; i < nb_numa_nodes; i++) {
+ assert(cpu->cpu_index < max_cpus);
if (test_bit(cpu->cpu_index, numa_info[i].node_cpu)) {
cpu->numa_node = i;
}
@@ -518,6 +523,9 @@ static int query_memdev(Object *obj, void *opaque)
m->value = g_malloc0(sizeof(*m->value));
+ m->value->id = object_property_get_str(obj, "id", NULL);
+ m->value->has_id = !!m->value->id;
+
m->value->size = object_property_get_int(obj, "size",
&error_abort);
m->value->merge = object_property_get_bool(obj, "merge",
@@ -555,6 +563,8 @@ int numa_get_node_for_cpu(int idx)
{
int i;
+ assert(idx < max_cpus);
+
for (i = 0; i < nb_numa_nodes; i++) {
if (test_bit(idx, numa_info[i].node_cpu)) {
break;