All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pasic@linux.ibm.com, pbonzini@redhat.com, ehabkost@redhat.com
Subject: [PATCH v4 05/80] initialize MachineState::ram in NUMA case
Date: Fri, 31 Jan 2020 16:08:35 +0100	[thread overview]
Message-ID: <1580483390-131164-6-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1580483390-131164-1-git-send-email-imammedo@redhat.com>

In case of NUMA there are 2 cases to consider:
 1. '-numa node,memdev', the only one that will be available
    for 5.0 and newer machine types.

    In this case reuse current behavior, with only difference
    memdevs are put into MachineState::ram container +
    a temporary glue to keep memory_region_allocate_system_memory()
    working until all boards converted.

 2. fake NUMA ("-numa node mem" and default RAM splitting)
    the later has been deprecated and will be removed but the former
    is going to stay available for compat reasons for 5.0 and
    older machine types

    it takes allocate_system_memory_nonnuma() path, like non-NUMA
    case and falls under conversion to memdev.  So extend non-NUMA
    MachineState::ram initialization introduced in previous patch
    to take care of fake NUMA case.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
CC: ehabkost@redhat.com
CC: pbonzini@redhat.com
CC: pasic@linux.ibm.com
---
 include/sysemu/numa.h |  1 +
 hw/core/numa.c        | 43 ++++++++++++++++++++++++++++++-------------
 vl.c                  |  2 +-
 3 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h
index ba693cc..ad58ee8 100644
--- a/include/sysemu/numa.h
+++ b/include/sysemu/numa.h
@@ -112,5 +112,6 @@ void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes,
                                   int nb_nodes, ram_addr_t size);
 void numa_cpu_pre_plug(const struct CPUArchId *slot, DeviceState *dev,
                        Error **errp);
+bool numa_uses_legacy_mem(void);
 
 #endif
diff --git a/hw/core/numa.c b/hw/core/numa.c
index 8264336..e6baf2c 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -52,6 +52,11 @@ QemuOptsList qemu_numa_opts = {
 };
 
 static int have_memdevs;
+bool numa_uses_legacy_mem(void)
+{
+    return !have_memdevs;
+}
+
 static int have_mem;
 static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one.
                              * For all nodes, nodeid < max_numa_nodeid
@@ -652,6 +657,23 @@ void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes,
     nodes[i].node_mem = size - usedmem;
 }
 
+static void numa_init_memdev_container(MachineState *ms, MemoryRegion *ram)
+{
+    int i;
+    uint64_t addr = 0;
+
+    for (i = 0; i < ms->numa_state->num_nodes; i++) {
+        uint64_t size = ms->numa_state->nodes[i].node_mem;
+        HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev;
+        if (!backend) {
+            continue;
+        }
+        MemoryRegion *seg = machine_consume_memdev(ms, backend);
+        memory_region_add_subregion(ram, addr, seg);
+        addr += size;
+    }
+}
+
 void numa_complete_configuration(MachineState *ms)
 {
     int i;
@@ -734,6 +756,12 @@ void numa_complete_configuration(MachineState *ms)
             exit(1);
         }
 
+        if (!numa_uses_legacy_mem() && mc->default_ram_id) {
+            ms->ram = g_new(MemoryRegion, 1);
+            memory_region_init(ms->ram, OBJECT(ms), mc->default_ram_id,
+                               ram_size);
+            numa_init_memdev_container(ms, ms->ram);
+        }
         /* QEMU needs at least all unique node pair distances to build
          * the whole NUMA distance table. QEMU treats the distance table
          * as symmetric by default, i.e. distance A->B == distance B->A.
@@ -800,27 +828,16 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
                                           const char *name,
                                           uint64_t ram_size)
 {
-    uint64_t addr = 0;
-    int i;
     MachineState *ms = MACHINE(qdev_get_machine());
 
     if (ms->numa_state == NULL ||
-        ms->numa_state->num_nodes == 0 || !have_memdevs) {
+        ms->numa_state->num_nodes == 0 || numa_uses_legacy_mem()) {
         allocate_system_memory_nonnuma(mr, owner, name, ram_size);
         return;
     }
 
     memory_region_init(mr, owner, name, ram_size);
-    for (i = 0; i < ms->numa_state->num_nodes; i++) {
-        uint64_t size = ms->numa_state->nodes[i].node_mem;
-        HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev;
-        if (!backend) {
-            continue;
-        }
-        MemoryRegion *seg = machine_consume_memdev(ms, backend);
-        memory_region_add_subregion(mr, addr, seg);
-        addr += size;
-    }
+    numa_init_memdev_container(ms, mr);
 }
 
 static void numa_stat_memory_devices(NumaNodeMem node_mem[])
diff --git a/vl.c b/vl.c
index 2367cb6..2ef9237 100644
--- a/vl.c
+++ b/vl.c
@@ -4324,7 +4324,7 @@ int main(int argc, char **argv, char **envp)
     parse_numa_opts(current_machine);
 
     if (machine_class->default_ram_id && current_machine->ram_size &&
-        !current_machine->ram_memdev_id) {
+        numa_uses_legacy_mem() && !current_machine->ram_memdev_id) {
         create_default_memdev(current_machine, mem_path, mem_prealloc);
     }
     /* do monitor/qmp handling at preconfig state if requested */
-- 
2.7.4



  parent reply	other threads:[~2020-01-31 15:16 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 15:08 [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 02/80] machine: introduce memory-backend property Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 03/80] machine: alias -mem-path and -mem-prealloc into memory-foo backend Igor Mammedov
2020-02-03  9:04   ` Michael S. Tsirkin
2020-02-03  9:27     ` Igor Mammedov
2020-02-03  9:42       ` Michael S. Tsirkin
2020-02-03 10:40         ` Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 04/80] machine: introduce convenience MachineState::ram Igor Mammedov
2020-01-31 15:08 ` Igor Mammedov [this message]
2020-01-31 15:08 ` [PATCH v4 06/80] vl.c: move -m parsing after memory backends has been processed Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 07/80] vl.c: ensure that ram_size matches size of machine.memory-backend Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 08/80] alpha/dp264: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 09/80] arm/aspeed: actually check RAM size Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 10/80] arm/aspeed: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 11/80] arm/collie: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 12/80] arm/cubieboard: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 13/80] arm/digic_boards: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 14/80] arm/highbank: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 15/80] arm/imx25_pdk: drop RAM size fixup Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 16/80] arm/imx25_pdk: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 17/80] arm/integratorcp: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 18/80] arm/kzm: drop RAM size fixup Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 19/80] arm/kzm: use memdev for RAM Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 20/80] arm/mcimx6ul-evk: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 21/80] arm/mcimx7d-sabre: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 22/80] arm/mps2-tz: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 23/80] arm/mps2: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 24/80] arm/musicpal: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 25/80] arm/nseries: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 26/80] arm/omap_sx1: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 27/80] arm/palm: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 28/80] arm/raspi: " Igor Mammedov
2020-01-31 15:08 ` [PATCH v4 29/80] arm/sabrelite: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 30/80] arm/sbsa-ref: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 31/80] arm/versatilepb: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 32/80] arm/vexpress: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 33/80] arm/virt: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 34/80] arm/xilinx_zynq: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 35/80] arm/xilinx_zynq: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 36/80] arm/xlnx-versal-virt: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 37/80] arm/xlnx-zcu102: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 38/80] s390x/s390-virtio-ccw: " Igor Mammedov
2020-02-05 20:11   ` Halil Pasic
2020-02-06 13:15     ` Igor Mammedov
2020-02-10 19:33       ` Halil Pasic
2020-01-31 15:09 ` [PATCH v4 39/80] null-machine: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 40/80] cris/axis_dev88: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 41/80] hppa: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 42/80] x86/microvm: " Igor Mammedov
2020-02-03  8:58   ` Michael S. Tsirkin
2020-01-31 15:09 ` [PATCH v4 43/80] x86/pc: " Igor Mammedov
2020-02-03  9:07   ` Michael S. Tsirkin
2020-02-03  9:45     ` Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 44/80] lm32/lm32_boards: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 45/80] lm32/milkymist: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 46/80] m68k/an5206: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 47/80] m68k/q800: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 48/80] m68k/mcf5208: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 49/80] m68k/next-cube: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 50/80] mips/boston: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 51/80] mips/mips_fulong2e: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 52/80] mips/mips_fulong2e: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 53/80] mips/mips_jazz: " Igor Mammedov
2020-02-09 16:41   ` Philippe Mathieu-Daudé
2020-02-10 15:06     ` [PATCH v5 81/80] mips/mips_jazz: add max ram size check Igor Mammedov
2020-02-10 17:04       ` Philippe Mathieu-Daudé
2020-01-31 15:09 ` [PATCH v4 54/80] mips/mips_malta: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 55/80] mips/mips_mipssim: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 56/80] mips/mips_r4k: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 57/80] ppc/e500: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 58/80] ppc/e500: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 59/80] ppc/mac_newworld: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 60/80] ppc/mac_oldworld: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 61/80] ppc/pnv: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 62/80] ppc/ppc405_boards: add RAM size checks Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 63/80] ppc/ppc405_boards: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 64/80] ppc/{ppc440_bamboo, sam460ex}: drop RAM size fixup Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 65/80] ppc/{ppc440_bamboo, sam460ex}: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 66/80] ppc/prep: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 67/80] ppc/spapr: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 68/80] ppc/virtex_ml507: remove unused arguments Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 69/80] ppc/virtex_ml507: use memdev for RAM Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 70/80] sparc/leon3: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 71/80] sparc/sun4m: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 72/80] sparc/niagara: " Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 73/80] remove no longer used memory_region_allocate_system_memory() Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 74/80] exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize() Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 75/80] exec: drop bogus mem_path from qemu_ram_alloc_from_fd() Igor Mammedov
2020-02-07 14:42   ` Marc-André Lureau
2020-01-31 15:09 ` [PATCH v4 76/80] make mem_path local variable Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 77/80] hostmem: introduce "prealloc-threads" property Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 78/80] hostmem: fix strict bind policy Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 79/80] tests/numa-test: make top level args dynamic and g_autofree(cli) cleanups Igor Mammedov
2020-01-31 15:09 ` [PATCH v4 80/80] tests:numa-test: use explicit memdev to specify node RAM Igor Mammedov
2020-01-31 16:16 ` [PATCH v4 00/80] refactor main RAM allocation to use hostmem backend no-reply
2020-01-31 16:28 ` no-reply
2020-02-03  9:49   ` Igor Mammedov
2020-02-04 15:08 ` Igor Mammedov
2020-02-04 15:39   ` Igor Mammedov
2020-02-04 22:05     ` Paolo Bonzini
2020-02-05 13:20       ` Philippe Mathieu-Daudé

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=1580483390-131164-6-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.