[PATCH 00/86] refactor main RAM allocation to use hostmem backend

Igor Mammedov posted 86 patches 4 years, 4 months ago
Test asan failed
Test checkpatch failed
Test FreeBSD failed
Test docker-mingw@fedora failed
Test docker-clang@ubuntu failed
Test docker-quick@centos7 failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1577797450-88458-1-git-send-email-imammedo@redhat.com
Maintainers: Andrew Baumann <Andrew.Baumann@microsoft.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Andrew Jeffery <andrew@aj.id.au>, Sergio Lopez <slp@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, Aurelien Jarno <aurelien@aurel32.net>, Christian Borntraeger <borntraeger@de.ibm.com>, Paul Burton <pburton@wavecomp.com>, Artyom Tarasenko <atar4qemu@gmail.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Igor Mammedov <imammedo@redhat.com>, Andrzej Zaborowski <balrogg@gmail.com>, Thomas Huth <thuth@redhat.com>, Aleksandar Markovic <amarkovic@wavecomp.com>, KONRAD Frederic <frederic.konrad@adacore.com>, David Hildenbrand <david@redhat.com>, Michael Walle <michael@walle.cc>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, Eduardo Habkost <ehabkost@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Andrey Smirnov <andrew.smirnov@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Rob Herring <robh@kernel.org>, Jan Kiszka <jan.kiszka@web.de>, Beniamino Galvani <b.galvani@gmail.com>, "Cédric Le Goater" <clg@kaod.org>, Fabien Chouteau <chouteau@adacore.com>, Leif Lindholm <leif.lindholm@linaro.org>, Thomas Huth <huth@tuxfamily.org>, Peter Chubb <peter.chubb@nicta.com.au>, Radoslaw Biernacki <radoslaw.biernacki@linaro.org>, Cornelia Huck <cohuck@redhat.com>, "Hervé Poussineau" <hpoussin@reactos.org>, Antony Pavlov <antonynpavlov@gmail.com>, Jean-Christophe Dubois <jcd@tribudubois.net>, Helge Deller <deller@gmx.de>, Alistair Francis <alistair@alistair23.me>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, Joel Stanley <joel@jms.id.au>, BALATON Zoltan <balaton@eik.bme.hu>, Richard Henderson <rth@twiddle.net>
There is a newer version of this series
hw/alpha/alpha_sys.h          |   2 +-
include/hw/boards.h           |  51 ++++---------
include/hw/misc/aspeed_sdmc.h |   2 +
include/hw/ppc/ppc4xx.h       |   9 +--
include/sysemu/hostmem.h      |  20 ++++-
include/sysemu/numa.h         |   5 +-
include/sysemu/sysemu.h       |   2 -
backends/hostmem-file.c       |   8 --
backends/hostmem-memfd.c      |   1 -
backends/hostmem-ram.c        |   2 -
backends/hostmem.c            |  53 ++++++++++----
exec.c                        |  66 ++---------------
hw/alpha/dp264.c              |   2 +-
hw/alpha/typhoon.c            |   8 +-
hw/arm/aspeed.c               |  13 +---
hw/arm/collie.c               |  15 ++--
hw/arm/cubieboard.c           |  25 ++-----
hw/arm/digic_boards.c         |  35 +++++----
hw/arm/highbank.c             |  10 +--
hw/arm/imx25_pdk.c            |  13 ++--
hw/arm/integratorcp.c         |   9 +--
hw/arm/kzm.c                  |  13 ++--
hw/arm/mcimx6ul-evk.c         |  25 +++----
hw/arm/mcimx7d-sabre.c        |  25 +++----
hw/arm/mps2-tz.c              |  13 +++-
hw/arm/mps2.c                 |  13 +++-
hw/arm/musicpal.c             |  16 ++--
hw/arm/nseries.c              |  31 ++++----
hw/arm/omap_sx1.c             |  18 +++--
hw/arm/palm.c                 |  18 +++--
hw/arm/raspi.c                |  32 +++-----
hw/arm/sabrelite.c            |  23 ++----
hw/arm/sbsa-ref.c             |   8 +-
hw/arm/versatilepb.c          |   7 +-
hw/arm/vexpress.c             |  14 ++--
hw/arm/virt.c                 |   9 +--
hw/arm/xilinx_zynq.c          |  20 +++--
hw/arm/xlnx-versal-virt.c     |   7 +-
hw/arm/xlnx-zcu102.c          |   7 +-
hw/core/machine.c             |  41 +++++++++--
hw/core/null-machine.c        |   7 +-
hw/core/numa.c                | 167 +++++++++---------------------------------
hw/cris/axis_dev88.c          |   8 +-
hw/hppa/machine.c             |  10 +--
hw/i386/microvm.c             |  12 ++-
hw/i386/pc.c                  |  20 +++--
hw/i386/pc_piix.c             |   2 +-
hw/i386/pc_q35.c              |   2 +-
hw/lm32/lm32_boards.c         |  36 +++++----
hw/lm32/milkymist.c           |  19 +++--
hw/m68k/an5206.c              |   5 +-
hw/m68k/mcf5208.c             |   5 +-
hw/m68k/next-cube.c           |   5 +-
hw/mips/boston.c              |  11 ++-
hw/mips/mips_fulong2e.c       |  15 ++--
hw/mips/mips_jazz.c           |   7 +-
hw/mips/mips_malta.c          |  10 +--
hw/mips/mips_mipssim.c        |   9 +--
hw/mips/mips_r4k.c            |  12 +--
hw/misc/aspeed_sdmc.c         | 112 +++++++++++-----------------
hw/ppc/e500.c                 |  17 ++---
hw/ppc/e500plat.c             |   1 +
hw/ppc/mac_newworld.c         |   6 +-
hw/ppc/mac_oldworld.c         |   6 +-
hw/ppc/mpc8544ds.c            |   1 +
hw/ppc/pnv.c                  |   8 +-
hw/ppc/ppc405_boards.c        |  45 +++++++-----
hw/ppc/ppc440_bamboo.c        |  12 ++-
hw/ppc/ppc4xx_devs.c          |  30 ++++----
hw/ppc/prep.c                 |  15 ++--
hw/ppc/sam460ex.c             |   6 +-
hw/ppc/spapr.c                |  17 +----
hw/ppc/virtex_ml507.c         |  18 ++---
hw/s390x/s390-virtio-ccw.c    |   7 +-
hw/sparc/leon3.c              |   6 +-
hw/sparc/sun4m.c              |  73 +++++++++---------
hw/sparc64/niagara.c          |   7 +-
qemu-deprecated.texi          |  33 ---------
qemu-options.hx               |  20 ++---
tests/numa-test.c             |  90 +++++++++++++----------
vl.c                          |  37 +++++++++-
81 files changed, 713 insertions(+), 907 deletions(-)
[PATCH 00/86] refactor main RAM allocation to use hostmem backend
Posted by Igor Mammedov 4 years, 4 months ago
Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory)
and consolidates it around hostmem backend. It allows to
 * resolve conflicts between global -mem-prealloc and hostmem's "policy" option
   fixing premature allocation before binding policy is applied
 * simplify complicated memory allocation routines which had to deal with 2 ways
   to allocate RAM.
 * it allows to reuse hostmem backends of a choice for main RAM without adding
   extra CLI options to duplicate hostmem features.
   Recent case was -mem-shared, to enable vhost-user on targets that don't
   support hostmem backends [1] (ex: s390)
 * move RAM allocation from individual boards into generic machine code and
   provide them with prepared MemoryRegion.
 * clean up deprecated NUMA features which were tied to the old API (see patches)
    - "numa: remove deprecated -mem-path fallback to anonymous RAM"
    - "numa: remove deprecated implicit RAM distribution between nodes"
    - "forbid '-numa node,mem' for 5.0 and newer machine types"

Conversion introduces a new machine.ram-memdev property and wrapper code that
aliases global -mem-path and -mem-alloc into automatically created hostmem
backend properties (provided ram-memdev was not set explicitly by user).
And then follows bulk of trivial patches that incrementally convert individual
boards to using machine.ram-memdev provided MemoryRegion.

Board conversion typically involves:
 * providing MachineClass::default_ram_size and MachineClass::default_ram_id
   so generic code could create default backend if user didn't explicitly provide
   ram-memdev or -m options
 * dropping memory_region_allocate_system_memory() call
 * using covinience MachineState::ram MemoryRegion, which points to MemoryRegion
   allocated by ram-memdev
On top of that for some boards:
 * added missing ram_size checks (typically it were boards with fixed ram size)
 * ram_size fixups were replaced by checks and hard errors, forcing user to
   provide correct "-m" values instead of ignoring it and continuing running.
   
After all boards are converted the old API is removed and memory allocation
routines are cleaned up.

git tree for testing:
  https://github.com/imammedo/qemu convert_main_ram_to_memdev_v1

Igor Mammedov (86):
  numa: remove not needed check
  numa: properly check if numa is supported
  numa: remove deprecated -mem-path fallback to anonymous RAM
  machine: introduce ram-memdev property
  machine: alias -mem-path and -mem-prealloc into memory-foo backend
  machine: introduce convenience MachineState::ram
  initialize MachineState::ram in NUMA case
  alpha:dp264: use memdev for RAM
  arm:aspeed: convert valid RAM sizes to data
  arm:aspeed: actually check RAM size
  hw:aspeed: drop warning and bogus ram_size fixup
  arm:aspeed: use memdev for RAM
  arm:collie: use memdev for RAM
  arm:cubieboard: use memdev for RAM
  arm:digic_boards: use memdev for RAM
  arm:highbank: use memdev for RAM
  arm:imx25_pdk: drop RAM size fixup
  arm:imx25_pdk: use memdev for RAM
  arm:integratorcp: use memdev for RAM
  arm:kzm: drop RAM size fixup
  arm:kzm: use memdev for RAM
  arm:mcimx6ul-evk: use memdev for RAM
  arm:mcimx7d-sabre: use memdev for RAM
  arm:mps2-tz: use memdev for RAM
  arm:mps2: use memdev for RAM
  arm:musicpal: use memdev for RAM
  arm:nseries: use memdev for RAM
  arm:omap_sx1: use memdev for RAM
  arm:palm: use memdev for RAM
  arm:raspi: use memdev for RAM
  arm:sabrelite: use memdev for RAM
  arm:sbsa-ref: use memdev for RAM
  arm:versatilepb: use memdev for RAM
  arm:vexpress: use memdev for RAM
  arm:virt: use memdev for RAM
  arm:xilinx_zynq: drop RAM size fixup
  arm:xilinx_zynq: use memdev for RAM
  arm:xlnx-versal-virt: use memdev for RAM
  arm:xlnx-zcu102: use memdev for RAM
  s390x:s390-virtio-ccw: use memdev for RAM
  null-machine: use memdev for RAM
  cris:axis_dev88: use memdev for RAM
  hppa: drop RAM size fixup
  hppa: use memdev for RAM
  x86:microvm: use memdev for RAM
  x86:pc: use memdev for RAM
  lm32:lm32_boards: use memdev for RAM
  lm32:milkymist: use memdev for RAM
  m68k:an5206: use memdev for RAM
  m68k:mcf5208: use memdev for RAM
  m68k:next-cube: use memdev for RAM
  mips:boston-cube: use memdev for RAM
  mips:mips_fulong2e: drop RAM size fixup
  mips:mips_fulong2e: use memdev for RAM
  mips:mips_jazz: use memdev for RAM
  mips:mips_malta: use memdev for RAM
  mips:mips_mipssim: use memdev for RAM
  mips:mips_r4k: use memdev for RAM
  ppc:e500: drop RAM size fixup
  ppc:e500: use memdev for RAM
  ppc:mac_newworld: use memdev for RAM
  ppc:mac_oldworld: use memdev for RAM
  ppc:pnv: use memdev for RAM
  ppc:ppc405_boards: add RAM size checks
  ppc:ppc405_boards: use memdev for RAM
  ppc:ppc440_bamboo/sam460ex: drop RAM size fixup
  ppc:ppc440_bamboo/sam460ex: use memdev for RAM
  ppc:prep: use memdev for RAM
  ppc:spapr: use memdev for RAM
  ppc:virtex_ml507: remove unused arguments
  ppc:virtex_ml507: use memdev for RAM
  sparc:leon3: use memdev for RAM
  sparc:sun4m: use memdev for RAM
  sparc:niagara: use memdev for RAM
  remove no longer used memory_region_allocate_system_memory()
  post conversion default_ram_id cleanup
  exec: cleanup qemu_minrampagesize()/qemu_maxrampagesize()
  exec: drop bogus mem_path from qemu_ram_alloc_from_fd()
  make mem_path local variable
  hostmem: introduce "prealloc-threads" property
  hostmem: fix strict bind policy
  numa: forbid '-numa node,mem' for 5.0 and newer machine types
  tests:numa-test: make top level args dynamic and g_autofree(cli)
    cleanups
  tests:numa-test: use explicit memdev to specify node RAM
  numa: make exit() usage consistent
  numa: remove deprecated implicit RAM distribution between nodes

 hw/alpha/alpha_sys.h          |   2 +-
 include/hw/boards.h           |  51 ++++---------
 include/hw/misc/aspeed_sdmc.h |   2 +
 include/hw/ppc/ppc4xx.h       |   9 +--
 include/sysemu/hostmem.h      |  20 ++++-
 include/sysemu/numa.h         |   5 +-
 include/sysemu/sysemu.h       |   2 -
 backends/hostmem-file.c       |   8 --
 backends/hostmem-memfd.c      |   1 -
 backends/hostmem-ram.c        |   2 -
 backends/hostmem.c            |  53 ++++++++++----
 exec.c                        |  66 ++---------------
 hw/alpha/dp264.c              |   2 +-
 hw/alpha/typhoon.c            |   8 +-
 hw/arm/aspeed.c               |  13 +---
 hw/arm/collie.c               |  15 ++--
 hw/arm/cubieboard.c           |  25 ++-----
 hw/arm/digic_boards.c         |  35 +++++----
 hw/arm/highbank.c             |  10 +--
 hw/arm/imx25_pdk.c            |  13 ++--
 hw/arm/integratorcp.c         |   9 +--
 hw/arm/kzm.c                  |  13 ++--
 hw/arm/mcimx6ul-evk.c         |  25 +++----
 hw/arm/mcimx7d-sabre.c        |  25 +++----
 hw/arm/mps2-tz.c              |  13 +++-
 hw/arm/mps2.c                 |  13 +++-
 hw/arm/musicpal.c             |  16 ++--
 hw/arm/nseries.c              |  31 ++++----
 hw/arm/omap_sx1.c             |  18 +++--
 hw/arm/palm.c                 |  18 +++--
 hw/arm/raspi.c                |  32 +++-----
 hw/arm/sabrelite.c            |  23 ++----
 hw/arm/sbsa-ref.c             |   8 +-
 hw/arm/versatilepb.c          |   7 +-
 hw/arm/vexpress.c             |  14 ++--
 hw/arm/virt.c                 |   9 +--
 hw/arm/xilinx_zynq.c          |  20 +++--
 hw/arm/xlnx-versal-virt.c     |   7 +-
 hw/arm/xlnx-zcu102.c          |   7 +-
 hw/core/machine.c             |  41 +++++++++--
 hw/core/null-machine.c        |   7 +-
 hw/core/numa.c                | 167 +++++++++---------------------------------
 hw/cris/axis_dev88.c          |   8 +-
 hw/hppa/machine.c             |  10 +--
 hw/i386/microvm.c             |  12 ++-
 hw/i386/pc.c                  |  20 +++--
 hw/i386/pc_piix.c             |   2 +-
 hw/i386/pc_q35.c              |   2 +-
 hw/lm32/lm32_boards.c         |  36 +++++----
 hw/lm32/milkymist.c           |  19 +++--
 hw/m68k/an5206.c              |   5 +-
 hw/m68k/mcf5208.c             |   5 +-
 hw/m68k/next-cube.c           |   5 +-
 hw/mips/boston.c              |  11 ++-
 hw/mips/mips_fulong2e.c       |  15 ++--
 hw/mips/mips_jazz.c           |   7 +-
 hw/mips/mips_malta.c          |  10 +--
 hw/mips/mips_mipssim.c        |   9 +--
 hw/mips/mips_r4k.c            |  12 +--
 hw/misc/aspeed_sdmc.c         | 112 +++++++++++-----------------
 hw/ppc/e500.c                 |  17 ++---
 hw/ppc/e500plat.c             |   1 +
 hw/ppc/mac_newworld.c         |   6 +-
 hw/ppc/mac_oldworld.c         |   6 +-
 hw/ppc/mpc8544ds.c            |   1 +
 hw/ppc/pnv.c                  |   8 +-
 hw/ppc/ppc405_boards.c        |  45 +++++++-----
 hw/ppc/ppc440_bamboo.c        |  12 ++-
 hw/ppc/ppc4xx_devs.c          |  30 ++++----
 hw/ppc/prep.c                 |  15 ++--
 hw/ppc/sam460ex.c             |   6 +-
 hw/ppc/spapr.c                |  17 +----
 hw/ppc/virtex_ml507.c         |  18 ++---
 hw/s390x/s390-virtio-ccw.c    |   7 +-
 hw/sparc/leon3.c              |   6 +-
 hw/sparc/sun4m.c              |  73 +++++++++---------
 hw/sparc64/niagara.c          |   7 +-
 qemu-deprecated.texi          |  33 ---------
 qemu-options.hx               |  20 ++---
 tests/numa-test.c             |  90 +++++++++++++----------
 vl.c                          |  37 +++++++++-
 81 files changed, 713 insertions(+), 907 deletions(-)

-- 
2.7.4


Re: [PATCH 00/86] refactor main RAM allocation to use hostmem backend
Posted by Philippe Mathieu-Daudé 4 years, 4 months ago
Hi Igor,

On 12/31/19 2:02 PM, Igor Mammedov wrote:
> Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory)
> and consolidates it around hostmem backend. It allows to
>   * resolve conflicts between global -mem-prealloc and hostmem's "policy" option
>     fixing premature allocation before binding policy is applied
>   * simplify complicated memory allocation routines which had to deal with 2 ways
>     to allocate RAM.
>   * it allows to reuse hostmem backends of a choice for main RAM without adding
>     extra CLI options to duplicate hostmem features.
>     Recent case was -mem-shared, to enable vhost-user on targets that don't
>     support hostmem backends [1] (ex: s390)
>   * move RAM allocation from individual boards into generic machine code and
>     provide them with prepared MemoryRegion.
>   * clean up deprecated NUMA features which were tied to the old API (see patches)
>      - "numa: remove deprecated -mem-path fallback to anonymous RAM"
>      - "numa: remove deprecated implicit RAM distribution between nodes"
>      - "forbid '-numa node,mem' for 5.0 and newer machine types"
> 
> Conversion introduces a new machine.ram-memdev property and wrapper code that
> aliases global -mem-path and -mem-alloc into automatically created hostmem
> backend properties (provided ram-memdev was not set explicitly by user).
> And then follows bulk of trivial patches that incrementally convert individual
> boards to using machine.ram-memdev provided MemoryRegion.
> 
> Board conversion typically involves:
>   * providing MachineClass::default_ram_size and MachineClass::default_ram_id
>     so generic code could create default backend if user didn't explicitly provide
>     ram-memdev or -m options
>   * dropping memory_region_allocate_system_memory() call
>   * using covinience MachineState::ram MemoryRegion, which points to MemoryRegion
>     allocated by ram-memdev
> On top of that for some boards:
>   * added missing ram_size checks (typically it were boards with fixed ram size)
>   * ram_size fixups were replaced by checks and hard errors, forcing user to
>     provide correct "-m" values instead of ignoring it and continuing running.
>     
> After all boards are converted the old API is removed and memory allocation
> routines are cleaned up.

I'm replying to the cover because multiple patches are concerned.

Compiling arm/lm32/mips64el/ppc on 32-bit host I get:

   CC      hw/arm/digic_boards.o
hw/arm/digic_boards.c: In function 'digic4_board_init':
hw/arm/digic_boards.c:57:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/digic_boards.o' failed
make: *** [hw/arm/digic_boards.o] Error 1
   CC      hw/arm/musicpal.o
hw/arm/musicpal.c: In function 'musicpal_init':
hw/arm/musicpal.c:1598:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/musicpal.o' failed
make: *** [hw/arm/musicpal.o] Error 1
   CC      hw/arm/nseries.o
hw/arm/nseries.c: In function 'n8x0_init':
hw/arm/nseries.c:1316:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/nseries.o' failed
make: *** [hw/arm/nseries.o] Error 1
   CC      hw/arm/omap_sx1.o
hw/arm/omap_sx1.c: In function 'sx1_init':
hw/arm/omap_sx1.c:119:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/omap_sx1.o' failed
make: *** [hw/arm/omap_sx1.o] Error 1
   CC      hw/arm/palm.o
hw/arm/palm.c: In function 'palmte_init':
hw/arm/palm.c:202:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/palm.o' failed
make: *** [hw/arm/palm.o] Error 1
   CC      hw/arm/collie.o
hw/arm/collie.c: In function 'collie_init':
hw/arm/collie.c:32:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/collie.o' failed
make: *** [hw/arm/collie.o] Error 1
   CC      hw/arm/mps2.o
hw/arm/mps2.c: In function 'mps2_common_init':
hw/arm/mps2.c:121:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/mps2.o' failed
make: *** [hw/arm/mps2.o] Error 1
   CC      hw/arm/mps2-tz.o
hw/arm/mps2-tz.c: In function 'mps2tz_common_init':
hw/arm/mps2-tz.c:391:22: error: format '%lli' expects argument of type 
'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
[-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/arm/mps2-tz.o' failed
make: *** [hw/arm/mps2-tz.o] Error 1
   CC      hw/lm32/lm32_boards.o
hw/lm32/lm32_boards.c: In function 'lm32_evr_init':
hw/lm32/lm32_boards.c:89:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
hw/lm32/lm32_boards.c: In function 'lm32_uclinux_init':
hw/lm32/lm32_boards.c:179:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/lm32/lm32_boards.o' failed
make: *** [hw/lm32/lm32_boards.o] Error 1
   CC      hw/lm32/milkymist.o
hw/lm32/milkymist.c: In function 'milkymist_init':
hw/lm32/milkymist.c:100:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
   CC      hw/mips/mips_fulong2e.o
hw/mips/mips_fulong2e.c: In function 'mips_fulong2e_init':
hw/mips/mips_fulong2e.c:317:22: error: format '%ld' expects argument of 
type 'long int', but argument 2 has type 'long long int' [-Werror=format=]
          error_report("Invalid RAM size, should be %ld", 256 * MiB);
                       ^
cc1: all warnings being treated as errors
   CC      hw/ppc/ppc405_boards.o
hw/ppc/ppc405_boards.c: In function 'ref405ep_init':
hw/ppc/ppc405_boards.c:165:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
hw/ppc/ppc405_boards.c: In function 'taihu_405ep_init':
hw/ppc/ppc405_boards.c:435:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/ppc/ppc405_boards.o' failed
make: *** [hw/ppc/ppc405_boards.o] Error 1
   CC      hw/ppc/ppc4xx_devs.o
hw/ppc/ppc4xx_devs.c: In function 'ppc4xx_sdram_adjust':
hw/ppc/ppc4xx_devs.c:704:39: error: format '%lli' expects argument of 
type 'long long int', but argument 3 has type 'ram_addr_t {aka const 
unsigned int}' [-Werror=format=]
              char *t = g_strdup_printf("%s%" PRIi64 "%s", s, 
sdram_bank_sizes[i],
                                        ^
hw/ppc/ppc4xx_devs.c:709:22: error: format '%lli' expects argument of 
type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
int}' [-Werror=format=]
          error_report("Invalid RAM size, unable to fit all RAM into RAM 
banks"
                       ^
cc1: all warnings being treated as errors
rules.mak:69: recipe for target 'hw/ppc/ppc4xx_devs.o' failed
make: *** [hw/ppc/ppc4xx_devs.o] Error 1
   CC      hw/ppc/e500.o
hw/ppc/e500.c: In function 'ppce500_init':
hw/ppc/e500.c:909:22: error: format '%ld' expects argument of type 'long 
int', but argument 2 has type 'long long int' [-Werror=format=]
          error_report("RAM size must be multiple of %ld", RAM_SIZES_ALIGN);
                       ^
cc1: all warnings being treated as errors


Re: [PATCH 00/86] refactor main RAM allocation to use hostmem backend
Posted by Igor Mammedov 4 years, 4 months ago
On Tue, 31 Dec 2019 16:58:10 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> Hi Igor,
> 
> On 12/31/19 2:02 PM, Igor Mammedov wrote:
> > Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory)
> > and consolidates it around hostmem backend. It allows to
> >   * resolve conflicts between global -mem-prealloc and hostmem's "policy" option
> >     fixing premature allocation before binding policy is applied
> >   * simplify complicated memory allocation routines which had to deal with 2 ways
> >     to allocate RAM.
> >   * it allows to reuse hostmem backends of a choice for main RAM without adding
> >     extra CLI options to duplicate hostmem features.
> >     Recent case was -mem-shared, to enable vhost-user on targets that don't
> >     support hostmem backends [1] (ex: s390)
> >   * move RAM allocation from individual boards into generic machine code and
> >     provide them with prepared MemoryRegion.
> >   * clean up deprecated NUMA features which were tied to the old API (see patches)
> >      - "numa: remove deprecated -mem-path fallback to anonymous RAM"
> >      - "numa: remove deprecated implicit RAM distribution between nodes"
> >      - "forbid '-numa node,mem' for 5.0 and newer machine types"
> > 
> > Conversion introduces a new machine.ram-memdev property and wrapper code that
> > aliases global -mem-path and -mem-alloc into automatically created hostmem
> > backend properties (provided ram-memdev was not set explicitly by user).
> > And then follows bulk of trivial patches that incrementally convert individual
> > boards to using machine.ram-memdev provided MemoryRegion.
> > 
> > Board conversion typically involves:
> >   * providing MachineClass::default_ram_size and MachineClass::default_ram_id
> >     so generic code could create default backend if user didn't explicitly provide
> >     ram-memdev or -m options
> >   * dropping memory_region_allocate_system_memory() call
> >   * using covinience MachineState::ram MemoryRegion, which points to MemoryRegion
> >     allocated by ram-memdev
> > On top of that for some boards:
> >   * added missing ram_size checks (typically it were boards with fixed ram size)
> >   * ram_size fixups were replaced by checks and hard errors, forcing user to
> >     provide correct "-m" values instead of ignoring it and continuing running.
> >     
> > After all boards are converted the old API is removed and memory allocation
> > routines are cleaned up.
> 
> I'm replying to the cover because multiple patches are concerned.
> 
> Compiling arm/lm32/mips64el/ppc on 32-bit host I get:
Thanks for spotting it.
I was thinking that travis-ci did 32-bit builds (I was wrong).
I'll dig up 32-bit machine and try to fix build issues.

> 
>    CC      hw/arm/digic_boards.o
> hw/arm/digic_boards.c: In function 'digic4_board_init':
> hw/arm/digic_boards.c:57:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/digic_boards.o' failed
> make: *** [hw/arm/digic_boards.o] Error 1
>    CC      hw/arm/musicpal.o
> hw/arm/musicpal.c: In function 'musicpal_init':
> hw/arm/musicpal.c:1598:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/musicpal.o' failed
> make: *** [hw/arm/musicpal.o] Error 1
>    CC      hw/arm/nseries.o
> hw/arm/nseries.c: In function 'n8x0_init':
> hw/arm/nseries.c:1316:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/nseries.o' failed
> make: *** [hw/arm/nseries.o] Error 1
>    CC      hw/arm/omap_sx1.o
> hw/arm/omap_sx1.c: In function 'sx1_init':
> hw/arm/omap_sx1.c:119:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/omap_sx1.o' failed
> make: *** [hw/arm/omap_sx1.o] Error 1
>    CC      hw/arm/palm.o
> hw/arm/palm.c: In function 'palmte_init':
> hw/arm/palm.c:202:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/palm.o' failed
> make: *** [hw/arm/palm.o] Error 1
>    CC      hw/arm/collie.o
> hw/arm/collie.c: In function 'collie_init':
> hw/arm/collie.c:32:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/collie.o' failed
> make: *** [hw/arm/collie.o] Error 1
>    CC      hw/arm/mps2.o
> hw/arm/mps2.c: In function 'mps2_common_init':
> hw/arm/mps2.c:121:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/mps2.o' failed
> make: *** [hw/arm/mps2.o] Error 1
>    CC      hw/arm/mps2-tz.o
> hw/arm/mps2-tz.c: In function 'mps2tz_common_init':
> hw/arm/mps2-tz.c:391:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/mps2-tz.o' failed
> make: *** [hw/arm/mps2-tz.o] Error 1
>    CC      hw/lm32/lm32_boards.o
> hw/lm32/lm32_boards.c: In function 'lm32_evr_init':
> hw/lm32/lm32_boards.c:89:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> hw/lm32/lm32_boards.c: In function 'lm32_uclinux_init':
> hw/lm32/lm32_boards.c:179:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/lm32/lm32_boards.o' failed
> make: *** [hw/lm32/lm32_boards.o] Error 1
>    CC      hw/lm32/milkymist.o
> hw/lm32/milkymist.c: In function 'milkymist_init':
> hw/lm32/milkymist.c:100:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
>    CC      hw/mips/mips_fulong2e.o
> hw/mips/mips_fulong2e.c: In function 'mips_fulong2e_init':
> hw/mips/mips_fulong2e.c:317:22: error: format '%ld' expects argument of 
> type 'long int', but argument 2 has type 'long long int' [-Werror=format=]
>           error_report("Invalid RAM size, should be %ld", 256 * MiB);
>                        ^
> cc1: all warnings being treated as errors
>    CC      hw/ppc/ppc405_boards.o
> hw/ppc/ppc405_boards.c: In function 'ref405ep_init':
> hw/ppc/ppc405_boards.c:165:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> hw/ppc/ppc405_boards.c: In function 'taihu_405ep_init':
> hw/ppc/ppc405_boards.c:435:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/ppc/ppc405_boards.o' failed
> make: *** [hw/ppc/ppc405_boards.o] Error 1
>    CC      hw/ppc/ppc4xx_devs.o
> hw/ppc/ppc4xx_devs.c: In function 'ppc4xx_sdram_adjust':
> hw/ppc/ppc4xx_devs.c:704:39: error: format '%lli' expects argument of 
> type 'long long int', but argument 3 has type 'ram_addr_t {aka const 
> unsigned int}' [-Werror=format=]
>               char *t = g_strdup_printf("%s%" PRIi64 "%s", s, 
> sdram_bank_sizes[i],
>                                         ^
> hw/ppc/ppc4xx_devs.c:709:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, unable to fit all RAM into RAM 
> banks"
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/ppc/ppc4xx_devs.o' failed
> make: *** [hw/ppc/ppc4xx_devs.o] Error 1
>    CC      hw/ppc/e500.o
> hw/ppc/e500.c: In function 'ppce500_init':
> hw/ppc/e500.c:909:22: error: format '%ld' expects argument of type 'long 
> int', but argument 2 has type 'long long int' [-Werror=format=]
>           error_report("RAM size must be multiple of %ld", RAM_SIZES_ALIGN);
>                        ^
> cc1: all warnings being treated as errors
> 


Re: [PATCH 00/86] refactor main RAM allocation to use hostmem backend
Posted by Igor Mammedov 4 years, 4 months ago
On Tue, 31 Dec 2019 16:58:10 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> Hi Igor,
> 
> On 12/31/19 2:02 PM, Igor Mammedov wrote:
> > Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory)
> > and consolidates it around hostmem backend. It allows to
> >   * resolve conflicts between global -mem-prealloc and hostmem's "policy" option
> >     fixing premature allocation before binding policy is applied
> >   * simplify complicated memory allocation routines which had to deal with 2 ways
> >     to allocate RAM.
> >   * it allows to reuse hostmem backends of a choice for main RAM without adding
> >     extra CLI options to duplicate hostmem features.
> >     Recent case was -mem-shared, to enable vhost-user on targets that don't
> >     support hostmem backends [1] (ex: s390)
> >   * move RAM allocation from individual boards into generic machine code and
> >     provide them with prepared MemoryRegion.
> >   * clean up deprecated NUMA features which were tied to the old API (see patches)
> >      - "numa: remove deprecated -mem-path fallback to anonymous RAM"
> >      - "numa: remove deprecated implicit RAM distribution between nodes"
> >      - "forbid '-numa node,mem' for 5.0 and newer machine types"
> > 
> > Conversion introduces a new machine.ram-memdev property and wrapper code that
> > aliases global -mem-path and -mem-alloc into automatically created hostmem
> > backend properties (provided ram-memdev was not set explicitly by user).
> > And then follows bulk of trivial patches that incrementally convert individual
> > boards to using machine.ram-memdev provided MemoryRegion.
> > 
> > Board conversion typically involves:
> >   * providing MachineClass::default_ram_size and MachineClass::default_ram_id
> >     so generic code could create default backend if user didn't explicitly provide
> >     ram-memdev or -m options
> >   * dropping memory_region_allocate_system_memory() call
> >   * using covinience MachineState::ram MemoryRegion, which points to MemoryRegion
> >     allocated by ram-memdev
> > On top of that for some boards:
> >   * added missing ram_size checks (typically it were boards with fixed ram size)
> >   * ram_size fixups were replaced by checks and hard errors, forcing user to
> >     provide correct "-m" values instead of ignoring it and continuing running.
> >     
> > After all boards are converted the old API is removed and memory allocation
> > routines are cleaned up.  
> 
> I'm replying to the cover because multiple patches are concerned.
> 
> Compiling arm/lm32/mips64el/ppc on 32-bit host I get:
what host/gcc version are you building on,
my fedora 30-32bit setup I did reproduce only a couple of errors.

> 
>    CC      hw/arm/digic_boards.o
> hw/arm/digic_boards.c: In function 'digic4_board_init':
> hw/arm/digic_boards.c:57:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/digic_boards.o' failed
> make: *** [hw/arm/digic_boards.o] Error 1
>    CC      hw/arm/musicpal.o
> hw/arm/musicpal.c: In function 'musicpal_init':
> hw/arm/musicpal.c:1598:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/musicpal.o' failed
> make: *** [hw/arm/musicpal.o] Error 1
>    CC      hw/arm/nseries.o
> hw/arm/nseries.c: In function 'n8x0_init':
> hw/arm/nseries.c:1316:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/nseries.o' failed
> make: *** [hw/arm/nseries.o] Error 1
>    CC      hw/arm/omap_sx1.o
> hw/arm/omap_sx1.c: In function 'sx1_init':
> hw/arm/omap_sx1.c:119:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/omap_sx1.o' failed
> make: *** [hw/arm/omap_sx1.o] Error 1
>    CC      hw/arm/palm.o
> hw/arm/palm.c: In function 'palmte_init':
> hw/arm/palm.c:202:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/palm.o' failed
> make: *** [hw/arm/palm.o] Error 1
>    CC      hw/arm/collie.o
> hw/arm/collie.c: In function 'collie_init':
> hw/arm/collie.c:32:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/collie.o' failed
> make: *** [hw/arm/collie.o] Error 1
>    CC      hw/arm/mps2.o
> hw/arm/mps2.c: In function 'mps2_common_init':
> hw/arm/mps2.c:121:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/mps2.o' failed
> make: *** [hw/arm/mps2.o] Error 1
>    CC      hw/arm/mps2-tz.o
> hw/arm/mps2-tz.c: In function 'mps2tz_common_init':
> hw/arm/mps2-tz.c:391:22: error: format '%lli' expects argument of type 
> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}' 
> [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/arm/mps2-tz.o' failed
> make: *** [hw/arm/mps2-tz.o] Error 1
>    CC      hw/lm32/lm32_boards.o
> hw/lm32/lm32_boards.c: In function 'lm32_evr_init':
> hw/lm32/lm32_boards.c:89:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> hw/lm32/lm32_boards.c: In function 'lm32_uclinux_init':
> hw/lm32/lm32_boards.c:179:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/lm32/lm32_boards.o' failed
> make: *** [hw/lm32/lm32_boards.o] Error 1
>    CC      hw/lm32/milkymist.o
> hw/lm32/milkymist.c: In function 'milkymist_init':
> hw/lm32/milkymist.c:100:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
>    CC      hw/mips/mips_fulong2e.o
> hw/mips/mips_fulong2e.c: In function 'mips_fulong2e_init':
> hw/mips/mips_fulong2e.c:317:22: error: format '%ld' expects argument of 
> type 'long int', but argument 2 has type 'long long int' [-Werror=format=]
>           error_report("Invalid RAM size, should be %ld", 256 * MiB);
>                        ^
> cc1: all warnings being treated as errors
>    CC      hw/ppc/ppc405_boards.o
> hw/ppc/ppc405_boards.c: In function 'ref405ep_init':
> hw/ppc/ppc405_boards.c:165:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> hw/ppc/ppc405_boards.c: In function 'taihu_405ep_init':
> hw/ppc/ppc405_boards.c:435:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/ppc/ppc405_boards.o' failed
> make: *** [hw/ppc/ppc405_boards.o] Error 1
>    CC      hw/ppc/ppc4xx_devs.o
> hw/ppc/ppc4xx_devs.c: In function 'ppc4xx_sdram_adjust':
> hw/ppc/ppc4xx_devs.c:704:39: error: format '%lli' expects argument of 
> type 'long long int', but argument 3 has type 'ram_addr_t {aka const 
> unsigned int}' [-Werror=format=]
>               char *t = g_strdup_printf("%s%" PRIi64 "%s", s, 
> sdram_bank_sizes[i],
>                                         ^
> hw/ppc/ppc4xx_devs.c:709:22: error: format '%lli' expects argument of 
> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned 
> int}' [-Werror=format=]
>           error_report("Invalid RAM size, unable to fit all RAM into RAM 
> banks"
>                        ^
> cc1: all warnings being treated as errors
> rules.mak:69: recipe for target 'hw/ppc/ppc4xx_devs.o' failed
> make: *** [hw/ppc/ppc4xx_devs.o] Error 1
>    CC      hw/ppc/e500.o
> hw/ppc/e500.c: In function 'ppce500_init':
> hw/ppc/e500.c:909:22: error: format '%ld' expects argument of type 'long 
> int', but argument 2 has type 'long long int' [-Werror=format=]
>           error_report("RAM size must be multiple of %ld", RAM_SIZES_ALIGN);
>                        ^
> cc1: all warnings being treated as errors
> 
> 


Re: [PATCH 00/86] refactor main RAM allocation to use hostmem backend
Posted by Philippe Mathieu-Daudé 4 years, 4 months ago
On 1/3/20 2:06 PM, Igor Mammedov wrote:
> On Tue, 31 Dec 2019 16:58:10 +0100
> Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
> 
>> Hi Igor,
>>
>> On 12/31/19 2:02 PM, Igor Mammedov wrote:
>>> Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory)
>>> and consolidates it around hostmem backend. It allows to
>>>    * resolve conflicts between global -mem-prealloc and hostmem's "policy" option
>>>      fixing premature allocation before binding policy is applied
>>>    * simplify complicated memory allocation routines which had to deal with 2 ways
>>>      to allocate RAM.
>>>    * it allows to reuse hostmem backends of a choice for main RAM without adding
>>>      extra CLI options to duplicate hostmem features.
>>>      Recent case was -mem-shared, to enable vhost-user on targets that don't
>>>      support hostmem backends [1] (ex: s390)
>>>    * move RAM allocation from individual boards into generic machine code and
>>>      provide them with prepared MemoryRegion.
>>>    * clean up deprecated NUMA features which were tied to the old API (see patches)
>>>       - "numa: remove deprecated -mem-path fallback to anonymous RAM"
>>>       - "numa: remove deprecated implicit RAM distribution between nodes"
>>>       - "forbid '-numa node,mem' for 5.0 and newer machine types"
>>>
>>> Conversion introduces a new machine.ram-memdev property and wrapper code that
>>> aliases global -mem-path and -mem-alloc into automatically created hostmem
>>> backend properties (provided ram-memdev was not set explicitly by user).
>>> And then follows bulk of trivial patches that incrementally convert individual
>>> boards to using machine.ram-memdev provided MemoryRegion.
>>>
>>> Board conversion typically involves:
>>>    * providing MachineClass::default_ram_size and MachineClass::default_ram_id
>>>      so generic code could create default backend if user didn't explicitly provide
>>>      ram-memdev or -m options
>>>    * dropping memory_region_allocate_system_memory() call
>>>    * using covinience MachineState::ram MemoryRegion, which points to MemoryRegion
>>>      allocated by ram-memdev
>>> On top of that for some boards:
>>>    * added missing ram_size checks (typically it were boards with fixed ram size)
>>>    * ram_size fixups were replaced by checks and hard errors, forcing user to
>>>      provide correct "-m" values instead of ignoring it and continuing running.
>>>      
>>> After all boards are converted the old API is removed and memory allocation
>>> routines are cleaned up.
>>
>> I'm replying to the cover because multiple patches are concerned.
>>
>> Compiling arm/lm32/mips64el/ppc on 32-bit host I get:
> what host/gcc version are you building on,
> my fedora 30-32bit setup I did reproduce only a couple of errors.

I'm using the qemu:debian-win32-cross docker image from 
tests/docker/dockerfiles/debian-win32-cross.docker:

$ i686-w64-mingw32.shared-gcc --version
i686-w64-mingw32.shared-gcc (GCC) 5.5.0

You can build the image running:

$ make docker-image-debian-win32-cross

>>
>>     CC      hw/arm/digic_boards.o
>> hw/arm/digic_boards.c: In function 'digic4_board_init':
>> hw/arm/digic_boards.c:57:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/digic_boards.o' failed
>> make: *** [hw/arm/digic_boards.o] Error 1
>>     CC      hw/arm/musicpal.o
>> hw/arm/musicpal.c: In function 'musicpal_init':
>> hw/arm/musicpal.c:1598:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/musicpal.o' failed
>> make: *** [hw/arm/musicpal.o] Error 1
>>     CC      hw/arm/nseries.o
>> hw/arm/nseries.c: In function 'n8x0_init':
>> hw/arm/nseries.c:1316:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/nseries.o' failed
>> make: *** [hw/arm/nseries.o] Error 1
>>     CC      hw/arm/omap_sx1.o
>> hw/arm/omap_sx1.c: In function 'sx1_init':
>> hw/arm/omap_sx1.c:119:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/omap_sx1.o' failed
>> make: *** [hw/arm/omap_sx1.o] Error 1
>>     CC      hw/arm/palm.o
>> hw/arm/palm.c: In function 'palmte_init':
>> hw/arm/palm.c:202:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/palm.o' failed
>> make: *** [hw/arm/palm.o] Error 1
>>     CC      hw/arm/collie.o
>> hw/arm/collie.c: In function 'collie_init':
>> hw/arm/collie.c:32:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/collie.o' failed
>> make: *** [hw/arm/collie.o] Error 1
>>     CC      hw/arm/mps2.o
>> hw/arm/mps2.c: In function 'mps2_common_init':
>> hw/arm/mps2.c:121:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/mps2.o' failed
>> make: *** [hw/arm/mps2.o] Error 1
>>     CC      hw/arm/mps2-tz.o
>> hw/arm/mps2-tz.c: In function 'mps2tz_common_init':
>> hw/arm/mps2-tz.c:391:22: error: format '%lli' expects argument of type
>> 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned int}'
>> [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/arm/mps2-tz.o' failed
>> make: *** [hw/arm/mps2-tz.o] Error 1
>>     CC      hw/lm32/lm32_boards.o
>> hw/lm32/lm32_boards.c: In function 'lm32_evr_init':
>> hw/lm32/lm32_boards.c:89:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> hw/lm32/lm32_boards.c: In function 'lm32_uclinux_init':
>> hw/lm32/lm32_boards.c:179:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/lm32/lm32_boards.o' failed
>> make: *** [hw/lm32/lm32_boards.o] Error 1
>>     CC      hw/lm32/milkymist.o
>> hw/lm32/milkymist.c: In function 'milkymist_init':
>> hw/lm32/milkymist.c:100:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>>     CC      hw/mips/mips_fulong2e.o
>> hw/mips/mips_fulong2e.c: In function 'mips_fulong2e_init':
>> hw/mips/mips_fulong2e.c:317:22: error: format '%ld' expects argument of
>> type 'long int', but argument 2 has type 'long long int' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %ld", 256 * MiB);
>>                         ^
>> cc1: all warnings being treated as errors
>>     CC      hw/ppc/ppc405_boards.o
>> hw/ppc/ppc405_boards.c: In function 'ref405ep_init':
>> hw/ppc/ppc405_boards.c:165:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> hw/ppc/ppc405_boards.c: In function 'taihu_405ep_init':
>> hw/ppc/ppc405_boards.c:435:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, should be %" PRIi64 " Bytes",
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/ppc/ppc405_boards.o' failed
>> make: *** [hw/ppc/ppc405_boards.o] Error 1
>>     CC      hw/ppc/ppc4xx_devs.o
>> hw/ppc/ppc4xx_devs.c: In function 'ppc4xx_sdram_adjust':
>> hw/ppc/ppc4xx_devs.c:704:39: error: format '%lli' expects argument of
>> type 'long long int', but argument 3 has type 'ram_addr_t {aka const
>> unsigned int}' [-Werror=format=]
>>                char *t = g_strdup_printf("%s%" PRIi64 "%s", s,
>> sdram_bank_sizes[i],
>>                                          ^
>> hw/ppc/ppc4xx_devs.c:709:22: error: format '%lli' expects argument of
>> type 'long long int', but argument 2 has type 'ram_addr_t {aka unsigned
>> int}' [-Werror=format=]
>>            error_report("Invalid RAM size, unable to fit all RAM into RAM
>> banks"
>>                         ^
>> cc1: all warnings being treated as errors
>> rules.mak:69: recipe for target 'hw/ppc/ppc4xx_devs.o' failed
>> make: *** [hw/ppc/ppc4xx_devs.o] Error 1
>>     CC      hw/ppc/e500.o
>> hw/ppc/e500.c: In function 'ppce500_init':
>> hw/ppc/e500.c:909:22: error: format '%ld' expects argument of type 'long
>> int', but argument 2 has type 'long long int' [-Werror=format=]
>>            error_report("RAM size must be multiple of %ld", RAM_SIZES_ALIGN);
>>                         ^
>> cc1: all warnings being treated as errors
>>
>>
>