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>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	xen-devel@lists.xensource.com
Subject: [Qemu-devel] [PULL 01/36] xen: fix ram init regression
Date: Mon, 4 Jul 2016 19:46:06 +0300	[thread overview]
Message-ID: <20160704194606-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1467650742-17580-1-git-send-email-mst@redhat.com>

From: Gerd Hoffmann <kraxel@redhat.com>

Commit "8156d48 pc: allow raising low memory via max-ram-below-4g
option" causes a regression on xen, because it uses a different
memory split.

This patch initializes max-ram-below-4g to zero and leaves the
initialization to the memory initialization functions.  That way
they can pick different default values (max-ram-below-4g is zero
still) or use the user supplied value (max-ram-below-4g is non-zero).

Also skip the whole ram split calculation on Xen.  xen_ram_init()
does its own split calculation anyway so it is superfluous, also
this way xen_ram_init can actually see whenever max-ram-below-4g
is zero or not.

Reported-by: Anthony PERARD <anthony.perard@citrix.com>
Tested-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/pc.c      |  2 +-
 hw/i386/pc_piix.c | 50 ++++++++++++++++++++++++++++----------------------
 hw/i386/pc_q35.c  |  3 +++
 xen-hvm.c         |  3 +++
 4 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 44a8f3b..cd1745e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1919,7 +1919,7 @@ static void pc_machine_initfn(Object *obj)
                         pc_machine_get_hotplug_memory_region_size,
                         NULL, NULL, NULL, &error_abort);
 
-    pcms->max_ram_below_4g = 0xe0000000; /* 3.5G */
+    pcms->max_ram_below_4g = 0; /* use default */
     object_property_add(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
                         pc_machine_get_max_ram_below_4g,
                         pc_machine_set_max_ram_below_4g,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c7d70af..a07dc81 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -108,37 +108,43 @@ static void pc_init1(MachineState *machine,
      *    so legacy non-PAE guests can get as much memory as possible in
      *    the 32bit address space below 4G.
      *
+     *  - Note that Xen has its own ram setp code in xen_ram_init(),
+     *    called via xen_hvm_init().
+     *
      * Examples:
      *    qemu -M pc-1.7 -m 4G    (old default)    -> 3584M low,  512M high
      *    qemu -M pc -m 4G        (new default)    -> 3072M low, 1024M high
      *    qemu -M pc,max-ram-below-4g=2G -m 4G     -> 2048M low, 2048M high
      *    qemu -M pc,max-ram-below-4g=4G -m 3968M  -> 3968M low (=4G-128M)
      */
-    lowmem = pcms->max_ram_below_4g;
-    if (machine->ram_size >= pcms->max_ram_below_4g) {
-        if (pcmc->gigabyte_align) {
-            if (lowmem > 0xc0000000) {
-                lowmem = 0xc0000000;
-            }
-            if (lowmem & ((1ULL << 30) - 1)) {
-                error_report("Warning: Large machine and max_ram_below_4g "
-                             "(%" PRIu64 ") not a multiple of 1G; "
-                             "possible bad performance.",
-                             pcms->max_ram_below_4g);
+    if (xen_enabled()) {
+        xen_hvm_init(pcms, &ram_memory);
+    } else {
+        if (!pcms->max_ram_below_4g) {
+            pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
+        }
+        lowmem = pcms->max_ram_below_4g;
+        if (machine->ram_size >= pcms->max_ram_below_4g) {
+            if (pcmc->gigabyte_align) {
+                if (lowmem > 0xc0000000) {
+                    lowmem = 0xc0000000;
+                }
+                if (lowmem & ((1ULL << 30) - 1)) {
+                    error_report("Warning: Large machine and max_ram_below_4g "
+                                 "(%" PRIu64 ") not a multiple of 1G; "
+                                 "possible bad performance.",
+                                 pcms->max_ram_below_4g);
+                }
             }
         }
-    }
 
-    if (machine->ram_size >= lowmem) {
-        pcms->above_4g_mem_size = machine->ram_size - lowmem;
-        pcms->below_4g_mem_size = lowmem;
-    } else {
-        pcms->above_4g_mem_size = 0;
-        pcms->below_4g_mem_size = machine->ram_size;
-    }
-
-    if (xen_enabled()) {
-        xen_hvm_init(pcms, &ram_memory);
+        if (machine->ram_size >= lowmem) {
+            pcms->above_4g_mem_size = machine->ram_size - lowmem;
+            pcms->below_4g_mem_size = lowmem;
+        } else {
+            pcms->above_4g_mem_size = 0;
+            pcms->below_4g_mem_size = machine->ram_size;
+        }
     }
 
     pc_cpus_init(pcms);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 04b2684..cd57bce 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -94,6 +94,9 @@ static void pc_q35_init(MachineState *machine)
     /* Handle the machine opt max-ram-below-4g.  It is basically doing
      * min(qemu limit, user limit).
      */
+    if (!pcms->max_ram_below_4g) {
+        pcms->max_ram_below_4g = 1ULL << 32; /* default: 4G */;
+    }
     if (lowmem > pcms->max_ram_below_4g) {
         lowmem = pcms->max_ram_below_4g;
         if (machine->ram_size - lowmem > lowmem &&
diff --git a/xen-hvm.c b/xen-hvm.c
index 98ea44f..eb57792 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -190,6 +190,9 @@ static void xen_ram_init(PCMachineState *pcms,
     /* Handle the machine opt max-ram-below-4g.  It is basically doing
      * min(xen limit, user limit).
      */
+    if (!user_lowmem) {
+        user_lowmem = HVM_BELOW_4G_RAM_END; /* default */
+    }
     if (HVM_BELOW_4G_RAM_END <= user_lowmem) {
         user_lowmem = HVM_BELOW_4G_RAM_END;
     }
-- 
MST

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	xen-devel@lists.xensource.com, Gerd Hoffmann <kraxel@redhat.com>,
	Anthony PERARD <anthony.perard@citrix.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [PULL 01/36] xen: fix ram init regression
Date: Mon, 4 Jul 2016 19:46:06 +0300	[thread overview]
Message-ID: <20160704194606-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1467650742-17580-1-git-send-email-mst@redhat.com>

From: Gerd Hoffmann <kraxel@redhat.com>

Commit "8156d48 pc: allow raising low memory via max-ram-below-4g
option" causes a regression on xen, because it uses a different
memory split.

This patch initializes max-ram-below-4g to zero and leaves the
initialization to the memory initialization functions.  That way
they can pick different default values (max-ram-below-4g is zero
still) or use the user supplied value (max-ram-below-4g is non-zero).

Also skip the whole ram split calculation on Xen.  xen_ram_init()
does its own split calculation anyway so it is superfluous, also
this way xen_ram_init can actually see whenever max-ram-below-4g
is zero or not.

Reported-by: Anthony PERARD <anthony.perard@citrix.com>
Tested-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/pc.c      |  2 +-
 hw/i386/pc_piix.c | 50 ++++++++++++++++++++++++++++----------------------
 hw/i386/pc_q35.c  |  3 +++
 xen-hvm.c         |  3 +++
 4 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 44a8f3b..cd1745e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1919,7 +1919,7 @@ static void pc_machine_initfn(Object *obj)
                         pc_machine_get_hotplug_memory_region_size,
                         NULL, NULL, NULL, &error_abort);
 
-    pcms->max_ram_below_4g = 0xe0000000; /* 3.5G */
+    pcms->max_ram_below_4g = 0; /* use default */
     object_property_add(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
                         pc_machine_get_max_ram_below_4g,
                         pc_machine_set_max_ram_below_4g,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index c7d70af..a07dc81 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -108,37 +108,43 @@ static void pc_init1(MachineState *machine,
      *    so legacy non-PAE guests can get as much memory as possible in
      *    the 32bit address space below 4G.
      *
+     *  - Note that Xen has its own ram setp code in xen_ram_init(),
+     *    called via xen_hvm_init().
+     *
      * Examples:
      *    qemu -M pc-1.7 -m 4G    (old default)    -> 3584M low,  512M high
      *    qemu -M pc -m 4G        (new default)    -> 3072M low, 1024M high
      *    qemu -M pc,max-ram-below-4g=2G -m 4G     -> 2048M low, 2048M high
      *    qemu -M pc,max-ram-below-4g=4G -m 3968M  -> 3968M low (=4G-128M)
      */
-    lowmem = pcms->max_ram_below_4g;
-    if (machine->ram_size >= pcms->max_ram_below_4g) {
-        if (pcmc->gigabyte_align) {
-            if (lowmem > 0xc0000000) {
-                lowmem = 0xc0000000;
-            }
-            if (lowmem & ((1ULL << 30) - 1)) {
-                error_report("Warning: Large machine and max_ram_below_4g "
-                             "(%" PRIu64 ") not a multiple of 1G; "
-                             "possible bad performance.",
-                             pcms->max_ram_below_4g);
+    if (xen_enabled()) {
+        xen_hvm_init(pcms, &ram_memory);
+    } else {
+        if (!pcms->max_ram_below_4g) {
+            pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */
+        }
+        lowmem = pcms->max_ram_below_4g;
+        if (machine->ram_size >= pcms->max_ram_below_4g) {
+            if (pcmc->gigabyte_align) {
+                if (lowmem > 0xc0000000) {
+                    lowmem = 0xc0000000;
+                }
+                if (lowmem & ((1ULL << 30) - 1)) {
+                    error_report("Warning: Large machine and max_ram_below_4g "
+                                 "(%" PRIu64 ") not a multiple of 1G; "
+                                 "possible bad performance.",
+                                 pcms->max_ram_below_4g);
+                }
             }
         }
-    }
 
-    if (machine->ram_size >= lowmem) {
-        pcms->above_4g_mem_size = machine->ram_size - lowmem;
-        pcms->below_4g_mem_size = lowmem;
-    } else {
-        pcms->above_4g_mem_size = 0;
-        pcms->below_4g_mem_size = machine->ram_size;
-    }
-
-    if (xen_enabled()) {
-        xen_hvm_init(pcms, &ram_memory);
+        if (machine->ram_size >= lowmem) {
+            pcms->above_4g_mem_size = machine->ram_size - lowmem;
+            pcms->below_4g_mem_size = lowmem;
+        } else {
+            pcms->above_4g_mem_size = 0;
+            pcms->below_4g_mem_size = machine->ram_size;
+        }
     }
 
     pc_cpus_init(pcms);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 04b2684..cd57bce 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -94,6 +94,9 @@ static void pc_q35_init(MachineState *machine)
     /* Handle the machine opt max-ram-below-4g.  It is basically doing
      * min(qemu limit, user limit).
      */
+    if (!pcms->max_ram_below_4g) {
+        pcms->max_ram_below_4g = 1ULL << 32; /* default: 4G */;
+    }
     if (lowmem > pcms->max_ram_below_4g) {
         lowmem = pcms->max_ram_below_4g;
         if (machine->ram_size - lowmem > lowmem &&
diff --git a/xen-hvm.c b/xen-hvm.c
index 98ea44f..eb57792 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -190,6 +190,9 @@ static void xen_ram_init(PCMachineState *pcms,
     /* Handle the machine opt max-ram-below-4g.  It is basically doing
      * min(xen limit, user limit).
      */
+    if (!user_lowmem) {
+        user_lowmem = HVM_BELOW_4G_RAM_END; /* default */
+    }
     if (HVM_BELOW_4G_RAM_END <= user_lowmem) {
         user_lowmem = HVM_BELOW_4G_RAM_END;
     }
-- 
MST


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

       reply	other threads:[~2016-07-04 16:46 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1467650742-17580-1-git-send-email-mst@redhat.com>
2016-07-04 16:46 ` Michael S. Tsirkin [this message]
2016-07-04 16:46   ` [PULL 01/36] xen: fix ram init regression Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 02/36] hw/ppc: realize the PCI root bus as part of mac99 init Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 03/36] hw/pci: delay bus_master_enable_region initialization Michael S. Tsirkin
2016-07-09  1:34   ` Mark Cave-Ayland
2016-07-09  7:07     ` Marcel Apfelbaum
2016-07-09  9:09       ` Mark Cave-Ayland
2016-07-11 14:42   ` Leon Alrae
2016-07-11 15:18     ` Marcel Apfelbaum
2016-07-11 18:41       ` Mark Cave-Ayland
2016-07-14 12:40         ` Marcel Apfelbaum
2016-07-04 16:46 ` [Qemu-devel] [PULL 04/36] q35: allow dynamic sysbus Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 05/36] hw/iommu: enable iommu with -device Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 06/36] machine: remove iommu property Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 07/36] piix: Set I440FXState member pci_info.w32 in one place Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 08/36] pc: Eliminate PcPciInfo Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 09/36] virtio: revert host notifiers to old semantics Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 10/36] virtio: set low features early on load Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 11/36] Revert "virtio-net: unbreak self announcement and guest offloads after migration" Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 12/36] pci_register_bar: cleanup Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 13/36] log: Clean up misuse of Range for -dfilter Michael S. Tsirkin
2016-07-04 16:46 ` [Qemu-devel] [PULL 14/36] range: Eliminate direct Range member access Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 15/36] range: Replace internal representation of Range Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 16/36] log: Permit -dfilter 0..0xffffffffffffffff Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 17/36] tests: acpi: add CPU hotplug testcase Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 18/36] tests: add APIC.cphp and DSDT.cphp blobs Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 19/36] tests/acpi: add pxb/pxb-pcie tests Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 20/36] hw/pxb: declare pxb devices as not hot-pluggable Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 21/36] hw/acpi: fix a DSDT table issue when a pxb is present Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 22/36] acpi: refactor pxb crs computation Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 23/36] hw/apci: handle 64-bit MMIO regions correctly Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 24/36] tests/acpi: Add pxb/pxb-pcie tests blobs Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 25/36] change pvscsi_init_msi() type to void Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 26/36] usb xhci: change msi/msix property type Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 27/36] intel-hda: change msi " Michael S. Tsirkin
2016-07-04 16:47 ` [Qemu-devel] [PULL 28/36] mptsas: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 29/36] megasas: change msi/msix " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 30/36] pci bridge dev: change msi " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 31/36] pci: Convert msi_init() to Error and fix callers to check it Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 32/36] megasas: remove unnecessary megasas_use_msi() Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 33/36] mptsas: remove unnecessary internal msi state flag Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 34/36] vmxnet3: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 35/36] e1000e: " Michael S. Tsirkin
2016-07-04 16:48 ` [Qemu-devel] [PULL 36/36] vmw_pvscsi: " 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=20160704194606-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=anthony.perard@citrix.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xensource.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.