[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 09/13] numa: introduce '-numa cpu' cpu option
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [RFC 09/13] numa: introduce '-numa cpu' cpu option |
Date: |
Wed, 18 Jan 2017 18:13:25 +0100 |
It allows to specify mapping of a CPU to NUMA node on CLI.
Option should be repeated for each present/possible CPU.
Example for PC machine:
-numa node,nodeid=0 -numa node,nodeid=1 \
-numa cpu,socket-id=0,core-id=0,thread-id=0,node-id=0 \
-numa cpu,socket-id=1,core-id=0,thread-id=0,node-id=1
Signed-off-by: Igor Mammedov <address@hidden>
---
include/sysemu/numa.h | 2 +-
numa.c | 30 +++++++++++++++++++++++++++---
qapi-schema.json | 3 ++-
vl.c | 2 +-
4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index b8015a5..d4b139e 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -24,7 +24,7 @@ typedef struct node_info {
} NodeInfo;
extern NodeInfo numa_info[MAX_NODES];
-void parse_numa_opts(MachineClass *mc);
+void parse_numa_opts(MachineState *ms);
void query_numa_node_mem(uint64_t node_mem[]);
extern QemuOptsList qemu_numa_opts;
void numa_set_mem_node_id(ram_addr_t addr, uint64_t size, uint32_t node);
diff --git a/numa.c b/numa.c
index 5f68497..0164cd7 100644
--- a/numa.c
+++ b/numa.c
@@ -37,6 +37,8 @@
#include "hw/mem/pc-dimm.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
+#include "qapi/qobject-output-visitor.h"
+#include "qapi/qobject-input-visitor.h"
QemuOptsList qemu_numa_opts = {
.name = "numa",
@@ -213,11 +215,13 @@ static void numa_node_parse(NumaNodeOptions *node,
QemuOpts *opts, Error **errp)
static int parse_numa(void *opaque, QemuOpts *opts, Error **errp)
{
+ Visitor *v;
NumaOptions *object = NULL;
+ MachineState *ms = MACHINE(opaque);
Error *err = NULL;
{
- Visitor *v = opts_visitor_new(opts);
+ v = opts_visitor_new(opts);
visit_type_NumaOptions(v, NULL, &object, &err);
visit_free(v);
}
@@ -234,6 +238,25 @@ static int parse_numa(void *opaque, QemuOpts *opts, Error
**errp)
}
nb_numa_nodes++;
break;
+ case NUMA_OPTIONS_KIND_CPU: {
+ QObject *qobj;
+
+ v = qobject_output_visitor_new(&qobj);
+ visit_type_CpuInstanceProperties(v, "cpu", &object->u.cpu.data, &err);
+ visit_complete(v, &qobj);
+ visit_free(v);
+ if (err) {
+ goto end;
+ }
+ v = qobject_input_visitor_new(qobj, true);
+ object_property_set(OBJECT(ms), v, "cpu", &err);
+ visit_free(v);
+ qobject_decref(qobj);
+ if (err) {
+ goto end;
+ }
+ break;
+ }
default:
abort();
}
@@ -293,15 +316,16 @@ static void validate_numa_cpus(void)
g_free(seen_cpus);
}
-void parse_numa_opts(MachineClass *mc)
+void parse_numa_opts(MachineState *ms)
{
int i;
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
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)) {
+ if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, ms, NULL)) {
exit(1);
}
diff --git a/qapi-schema.json b/qapi-schema.json
index ddc8783..69c059b 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -5543,7 +5543,8 @@
##
{ 'union': 'NumaOptions',
'data': {
- 'node': 'NumaNodeOptions' }}
+ 'node': 'NumaNodeOptions',
+ 'cpu': 'CpuInstanceProperties' }}
##
# @NumaNodeOptions:
diff --git a/vl.c b/vl.c
index afe40ce..d724523 100644
--- a/vl.c
+++ b/vl.c
@@ -4485,7 +4485,7 @@ int main(int argc, char **argv, char **envp)
default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
- parse_numa_opts(machine_class);
+ parse_numa_opts(current_machine);
if (qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, NULL)) {
--
2.7.4
- [Qemu-devel] [RFC 05/13] pc: move pcms->possible_cpus init out of pc_cpus_init(), (continued)
- [Qemu-devel] [RFC 05/13] pc: move pcms->possible_cpus init out of pc_cpus_init(), Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 06/13] pc: calculate topology only once when possible_cpus is initialised, Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 08/13] pc: add writeonly 'cpu' property to PCMachine, Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 07/13] pc: pass apic_id to pc_find_cpu_slot() directly so lookup could be done without CPU object, Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 09/13] numa: introduce '-numa cpu' cpu option,
Igor Mammedov <=
- [Qemu-devel] [RFC 10/13] numa: replace cpu_index_to_socket_id() with cpu_index_to_instance_props(), Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 11/13] numa: use new machine.cpu property with -numa cpus=... CLI, Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 13/13] pc: cpu: make sure that cpu.node-id matches -numa mapping, Igor Mammedov, 2017/01/18
- [Qemu-devel] [RFC 12/13] pc: drop usage of legacy numa_get_node_for_cpu(), Igor Mammedov, 2017/01/18