numa: Auto-enable NUMA when any memory devices are possible
Let's auto-enable it also when maxmem is specified but no slots are defined. This will result in us properly creating ACPI srat tables, indicating the maximum possible PFN to the guest OS. Based on this, e.g., Linux will enable the swiotlb properly. This avoids having to manually force the switolb on (swiotlb=force) in Linux in case we're booting only using DMA memory (e.g., 2GB on x86-64), and virtio-mem adds memory later on that really needs the swiotlb to be used for DMA. Let's take care of backwards compatibility if somebody has a setup that specifies "maxram" without "slots". Reported-by: Alex Shi <alex.shi@linux.alibaba.com> Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Cc: Sergio Lopez <slp@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Richard Henderson <rth@twiddle.net> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: qemu-arm@nongnu.org <qemu-arm@nongnu.org> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20200626072248.78761-22-david@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
0bc7806c5a
commit
195784a0cf
|
@ -2373,6 +2373,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
|
||||||
hc->unplug = virt_machine_device_unplug_cb;
|
hc->unplug = virt_machine_device_unplug_cb;
|
||||||
mc->nvdimm_supported = true;
|
mc->nvdimm_supported = true;
|
||||||
mc->auto_enable_numa_with_memhp = true;
|
mc->auto_enable_numa_with_memhp = true;
|
||||||
|
mc->auto_enable_numa_with_memdev = true;
|
||||||
mc->default_ram_id = "mach-virt.ram";
|
mc->default_ram_id = "mach-virt.ram";
|
||||||
|
|
||||||
object_class_property_add(oc, "acpi", "OnOffAuto",
|
object_class_property_add(oc, "acpi", "OnOffAuto",
|
||||||
|
@ -2485,6 +2486,7 @@ static void virt_machine_5_0_options(MachineClass *mc)
|
||||||
virt_machine_5_1_options(mc);
|
virt_machine_5_1_options(mc);
|
||||||
compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
|
compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
|
||||||
mc->numa_mem_supported = true;
|
mc->numa_mem_supported = true;
|
||||||
|
mc->auto_enable_numa_with_memdev = false;
|
||||||
}
|
}
|
||||||
DEFINE_VIRT_MACHINE(5, 0)
|
DEFINE_VIRT_MACHINE(5, 0)
|
||||||
|
|
||||||
|
|
|
@ -688,8 +688,9 @@ void numa_complete_configuration(MachineState *ms)
|
||||||
NodeInfo *numa_info = ms->numa_state->nodes;
|
NodeInfo *numa_info = ms->numa_state->nodes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If memory hotplug is enabled (slots > 0) but without '-numa'
|
* If memory hotplug is enabled (slot > 0) or memory devices are enabled
|
||||||
* options explicitly on CLI, guestes will break.
|
* (ms->maxram_size > ram_size) but without '-numa' options explicitly on
|
||||||
|
* CLI, guests will break.
|
||||||
*
|
*
|
||||||
* Windows: won't enable memory hotplug without SRAT table at all
|
* Windows: won't enable memory hotplug without SRAT table at all
|
||||||
*
|
*
|
||||||
|
@ -704,9 +705,9 @@ void numa_complete_configuration(MachineState *ms)
|
||||||
* assume there is just one node with whole RAM.
|
* assume there is just one node with whole RAM.
|
||||||
*/
|
*/
|
||||||
if (ms->numa_state->num_nodes == 0 &&
|
if (ms->numa_state->num_nodes == 0 &&
|
||||||
((ms->ram_slots > 0 &&
|
((ms->ram_slots && mc->auto_enable_numa_with_memhp) ||
|
||||||
mc->auto_enable_numa_with_memhp) ||
|
(ms->maxram_size > ms->ram_size && mc->auto_enable_numa_with_memdev) ||
|
||||||
mc->auto_enable_numa)) {
|
mc->auto_enable_numa)) {
|
||||||
NumaNodeOptions node = { };
|
NumaNodeOptions node = { };
|
||||||
parse_numa_node(ms, &node, &error_abort);
|
parse_numa_node(ms, &node, &error_abort);
|
||||||
numa_info[0].node_mem = ram_size;
|
numa_info[0].node_mem = ram_size;
|
||||||
|
|
|
@ -464,6 +464,7 @@ static void microvm_class_init(ObjectClass *oc, void *data)
|
||||||
mc->max_cpus = 288;
|
mc->max_cpus = 288;
|
||||||
mc->has_hotpluggable_cpus = false;
|
mc->has_hotpluggable_cpus = false;
|
||||||
mc->auto_enable_numa_with_memhp = false;
|
mc->auto_enable_numa_with_memhp = false;
|
||||||
|
mc->auto_enable_numa_with_memdev = false;
|
||||||
mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
|
mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
|
||||||
mc->nvdimm_supported = false;
|
mc->nvdimm_supported = false;
|
||||||
mc->default_ram_id = "microvm.ram";
|
mc->default_ram_id = "microvm.ram";
|
||||||
|
|
|
@ -1975,6 +1975,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
|
||||||
mc->get_default_cpu_node_id = x86_get_default_cpu_node_id;
|
mc->get_default_cpu_node_id = x86_get_default_cpu_node_id;
|
||||||
mc->possible_cpu_arch_ids = x86_possible_cpu_arch_ids;
|
mc->possible_cpu_arch_ids = x86_possible_cpu_arch_ids;
|
||||||
mc->auto_enable_numa_with_memhp = true;
|
mc->auto_enable_numa_with_memhp = true;
|
||||||
|
mc->auto_enable_numa_with_memdev = true;
|
||||||
mc->has_hotpluggable_cpus = true;
|
mc->has_hotpluggable_cpus = true;
|
||||||
mc->default_boot_order = "cad";
|
mc->default_boot_order = "cad";
|
||||||
mc->hot_add_cpu = pc_hot_add_cpu;
|
mc->hot_add_cpu = pc_hot_add_cpu;
|
||||||
|
|
|
@ -444,6 +444,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
|
||||||
m->numa_mem_supported = true;
|
m->numa_mem_supported = true;
|
||||||
compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
|
compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
|
||||||
compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
|
compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
|
||||||
|
m->auto_enable_numa_with_memdev = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL,
|
DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL,
|
||||||
|
|
|
@ -372,6 +372,7 @@ static void pc_q35_5_0_machine_options(MachineClass *m)
|
||||||
m->numa_mem_supported = true;
|
m->numa_mem_supported = true;
|
||||||
compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
|
compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len);
|
||||||
compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
|
compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len);
|
||||||
|
m->auto_enable_numa_with_memhp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_Q35_MACHINE(v5_0, "pc-q35-5.0", NULL,
|
DEFINE_Q35_MACHINE(v5_0, "pc-q35-5.0", NULL,
|
||||||
|
|
|
@ -207,6 +207,7 @@ struct MachineClass {
|
||||||
const char **valid_cpu_types;
|
const char **valid_cpu_types;
|
||||||
strList *allowed_dynamic_sysbus_devices;
|
strList *allowed_dynamic_sysbus_devices;
|
||||||
bool auto_enable_numa_with_memhp;
|
bool auto_enable_numa_with_memhp;
|
||||||
|
bool auto_enable_numa_with_memdev;
|
||||||
void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
|
void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
|
||||||
int nb_nodes, ram_addr_t size);
|
int nb_nodes, ram_addr_t size);
|
||||||
bool ignore_boot_device_suffixes;
|
bool ignore_boot_device_suffixes;
|
||||||
|
|
Loading…
Reference in New Issue