All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Sergio Lopez <slp@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	"qemu-arm @ nongnu . org" <qemu-arm@nongnu.org>,
	Igor Mammedov <imammedo@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Alex Shi <alex.shi@linux.alibaba.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [PULL 24/41] numa: Auto-enable NUMA when any memory devices are possible
Date: Fri, 3 Jul 2020 05:04:34 -0400	[thread overview]
Message-ID: <20200703090252.368694-25-mst@redhat.com> (raw)
In-Reply-To: <20200703090252.368694-1-mst@redhat.com>

From: David Hildenbrand <david@redhat.com>

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>
---
 include/hw/boards.h |  1 +
 hw/arm/virt.c       |  2 ++
 hw/core/numa.c      | 11 ++++++-----
 hw/i386/microvm.c   |  1 +
 hw/i386/pc.c        |  1 +
 hw/i386/pc_piix.c   |  1 +
 hw/i386/pc_q35.c    |  1 +
 7 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 18815d9be2..426ce5f625 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -207,6 +207,7 @@ struct MachineClass {
     const char **valid_cpu_types;
     strList *allowed_dynamic_sysbus_devices;
     bool auto_enable_numa_with_memhp;
+    bool auto_enable_numa_with_memdev;
     void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes,
                                  int nb_nodes, ram_addr_t size);
     bool ignore_boot_device_suffixes;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index cd0834ce7f..f97be80a86 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2373,6 +2373,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     hc->unplug = virt_machine_device_unplug_cb;
     mc->nvdimm_supported = true;
     mc->auto_enable_numa_with_memhp = true;
+    mc->auto_enable_numa_with_memdev = true;
     mc->default_ram_id = "mach-virt.ram";
 
     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);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    mc->auto_enable_numa_with_memdev = false;
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
diff --git a/hw/core/numa.c b/hw/core/numa.c
index e9aec69afd..6a20ce7cf1 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -688,8 +688,9 @@ void numa_complete_configuration(MachineState *ms)
     NodeInfo *numa_info = ms->numa_state->nodes;
 
     /*
-     * If memory hotplug is enabled (slots > 0) but without '-numa'
-     * options explicitly on CLI, guestes will break.
+     * If memory hotplug is enabled (slot > 0) or memory devices are enabled
+     * (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
      *
@@ -704,9 +705,9 @@ void numa_complete_configuration(MachineState *ms)
      * assume there is just one node with whole RAM.
      */
     if (ms->numa_state->num_nodes == 0 &&
-        ((ms->ram_slots > 0 &&
-        mc->auto_enable_numa_with_memhp) ||
-        mc->auto_enable_numa)) {
+        ((ms->ram_slots && mc->auto_enable_numa_with_memhp) ||
+         (ms->maxram_size > ms->ram_size && mc->auto_enable_numa_with_memdev) ||
+         mc->auto_enable_numa)) {
             NumaNodeOptions node = { };
             parse_numa_node(ms, &node, &error_abort);
             numa_info[0].node_mem = ram_size;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 5e931975a0..81d0888930 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -464,6 +464,7 @@ static void microvm_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = 288;
     mc->has_hotpluggable_cpus = false;
     mc->auto_enable_numa_with_memhp = false;
+    mc->auto_enable_numa_with_memdev = false;
     mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE;
     mc->nvdimm_supported = false;
     mc->default_ram_id = "microvm.ram";
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 576f2502f9..61acc9e530 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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->possible_cpu_arch_ids = x86_possible_cpu_arch_ids;
     mc->auto_enable_numa_with_memhp = true;
+    mc->auto_enable_numa_with_memdev = true;
     mc->has_hotpluggable_cpus = true;
     mc->default_boot_order = "cad";
     mc->hot_add_cpu = pc_hot_add_cpu;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1d832b2878..fae487f57d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -444,6 +444,7 @@ static void pc_i440fx_5_0_machine_options(MachineClass *m)
     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, 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,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 047ea8db28..acd6d405f0 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -372,6 +372,7 @@ static void pc_q35_5_0_machine_options(MachineClass *m)
     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, 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,
-- 
MST



  parent reply	other threads:[~2020-07-03  9:14 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03  9:03 [PULL 00/41] virtio,acpi: features, fixes, cleanups Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 01/41] tests: disassemble-aml.sh: generate AML in readable format Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 02/41] Revert "tests/migration: Reduce autoconverge initial bandwidth" Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 03/41] virtio-balloon: always indicate S_DONE when migration fails Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 04/41] pc: Support coldplugging of virtio-pmem-pci devices on all buses Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 05/41] exec: Introduce ram_block_discard_(disable|require)() Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 06/41] vfio: Convert to ram_block_discard_disable() Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 07/41] accel/kvm: " Michael S. Tsirkin
2020-07-03  9:03   ` Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 08/41] s390x/pv: " Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 09/41] virtio-balloon: Rip out qemu_balloon_inhibit() Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 10/41] target/i386: sev: Use ram_block_discard_disable() Michael S. Tsirkin
2020-07-03  9:03 ` [PULL 11/41] migration/rdma: " Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 12/41] migration/colo: " Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 13/41] virtio-mem: Paravirtualized memory hot(un)plug Michael S. Tsirkin
2020-07-03  9:18   ` David Hildenbrand
2020-07-03  9:32     ` David Hildenbrand
2020-07-03 10:23     ` Michael S. Tsirkin
2020-07-03 10:24       ` David Hildenbrand
2020-07-03  9:04 ` [PULL 14/41] virtio-pci: Proxy for virtio-mem Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 15/41] MAINTAINERS: Add myself as virtio-mem maintainer Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 16/41] hmp: Handle virtio-mem when printing memory device info Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 17/41] numa: Handle virtio-mem in NUMA stats Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 18/41] pc: Support for virtio-mem-pci Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 19/41] virtio-mem: Allow notifiers for size changes Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 20/41] virtio-pci: Send qapi events when the virtio-mem " Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 21/41] virtio-mem: Migration sanity checks Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 22/41] virtio-mem: Add trace events Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 23/41] virtio-mem: Exclude unplugged memory during migration Michael S. Tsirkin
2020-07-03  9:04 ` Michael S. Tsirkin [this message]
2020-07-03  9:04 ` [PULL 25/41] tests/acpi: remove stale allowed tables Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 26/41] docs: vhost-user: add Virtio status protocol feature Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 27/41] MAINTAINERS: add VT-d entry Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 28/41] net: introduce qemu_get_peer Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 29/41] vhost_net: use the function qemu_get_peer Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 30/41] virtio-bus: introduce queue_enabled method Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 31/41] virtio-pci: implement " Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 32/41] vhost: check the existence of vhost_set_iotlb_callback Michael S. Tsirkin
2020-07-03  9:04 ` [PULL 33/41] vhost: introduce new VhostOps vhost_dev_start Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 34/41] vhost: implement vhost_dev_start method Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 35/41] vhost: introduce new VhostOps vhost_vq_get_addr Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 36/41] vhost: implement vhost_vq_get_addr method Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 37/41] vhost: introduce new VhostOps vhost_force_iommu Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 38/41] vhost: implement vhost_force_iommu method Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 39/41] vhost_net: introduce set_config & get_config Michael S. Tsirkin
2020-07-03  9:05 ` [PULL 40/41] vhost-vdpa: introduce vhost-vdpa backend Michael S. Tsirkin
2020-07-08  0:07   ` Bruce Rogers
2020-07-08  4:17     ` Cindy Lu
2020-07-03  9:05 ` [PULL 41/41] vhost-vdpa: introduce vhost-vdpa net client Michael S. Tsirkin
2020-07-03  9:31 ` [PULL 00/41] virtio,acpi: features, fixes, cleanups no-reply
2020-07-03 11:58 ` Michael S. Tsirkin
2020-07-04 14:05 ` Peter Maydell
2020-07-04 18:36   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200703090252.368694-25-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.shi@linux.alibaba.com \
    --cc=david@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=slp@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.