[PATCH v2 0/9] Cleanup of qemu_oom_check() and qemu_memalign()

Peter Maydell posted 9 patches 2 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220304112126.2261039-1-peter.maydell@linaro.org
Test checkpatch failed
Maintainers: Stefan Hajnoczi <stefanha@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, John Snow <jsnow@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, Fam Zheng <fam@euphon.net>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, "Denis V. Lunev" <den@openvz.org>, Alberto Garcia <berto@igalia.com>, Stefan Weil <sw@weilnetz.de>, Jeff Cody <codyprime@gmail.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, "Cédric Le Goater" <clg@kaod.org>, Daniel Henrique Barboza <danielhb413@gmail.com>, David Gibson <david@gibson.dropbear.id.au>, Greg Kurz <groug@kaod.org>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Gerd Hoffmann <kraxel@redhat.com>, Eric Blake <eblake@redhat.com>, Jason Wang <jasowang@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <r.bolshakov@yadro.com>, Marcelo Tosatti <mtosatti@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
meson.build                    |  7 ++-
include/qemu-common.h          |  2 -
include/qemu/memalign.h        | 61 ++++++++++++++++++++++
include/qemu/osdep.h           | 18 -------
block/blkverify.c              |  1 +
block/block-copy.c             |  1 +
block/commit.c                 |  1 +
block/crypto.c                 |  1 +
block/dmg.c                    |  1 +
block/export/fuse.c            |  1 +
block/file-posix.c             |  1 +
block/io.c                     |  1 +
block/mirror.c                 |  1 +
block/nvme.c                   |  1 +
block/parallels-ext.c          |  1 +
block/parallels.c              |  1 +
block/qcow.c                   |  1 +
block/qcow2-cache.c            |  1 +
block/qcow2-cluster.c          |  1 +
block/qcow2-refcount.c         |  1 +
block/qcow2-snapshot.c         |  1 +
block/qcow2.c                  |  1 +
block/qed-l2-cache.c           |  1 +
block/qed-table.c              |  1 +
block/qed.c                    |  1 +
block/quorum.c                 |  1 +
block/raw-format.c             |  1 +
block/vdi.c                    |  1 +
block/vhdx-log.c               |  1 +
block/vhdx.c                   |  1 +
block/vmdk.c                   |  1 +
block/vpc.c                    |  1 +
block/win32-aio.c              |  1 +
hw/block/dataplane/xen-block.c |  1 +
hw/block/fdc.c                 |  1 +
hw/ide/core.c                  |  1 +
hw/ppc/spapr.c                 |  1 +
hw/ppc/spapr_softmmu.c         |  1 +
hw/scsi/scsi-disk.c            |  1 +
hw/tpm/tpm_ppi.c               |  2 +-
hw/usb/redirect.c              | 17 +++++--
nbd/server.c                   |  1 +
net/l2tpv3.c                   |  2 +-
plugins/loader.c               |  1 +
qemu-img.c                     |  1 +
qemu-io-cmds.c                 |  1 +
qom/object.c                   |  1 +
softmmu/physmem.c              |  1 +
target/i386/hvf/hvf.c          |  1 +
target/i386/kvm/kvm.c          |  1 +
tcg/region.c                   |  1 +
tests/bench/atomic_add-bench.c |  1 +
tests/bench/qht-bench.c        |  1 +
util/atomic64.c                |  1 +
util/memalign.c                | 92 ++++++++++++++++++++++++++++++++++
util/oslib-posix.c             | 46 -----------------
util/oslib-win32.c             | 35 -------------
util/qht.c                     |  1 +
util/meson.build               |  1 +
59 files changed, 224 insertions(+), 107 deletions(-)
create mode 100644 include/qemu/memalign.h
create mode 100644 util/memalign.c
[PATCH v2 0/9] Cleanup of qemu_oom_check() and qemu_memalign()
Posted by Peter Maydell 2 years, 1 month ago
This series does some cleanup of the qemu_oom_check() and
qemu_memalign() functions; I started looking at the first of these and
found myself wanting to tidy some stuff relating to the second in the
process. The TLDR is that this series removes qemu_oom_check() (which
was mostly being misused), unifies the POSIX and Win32 versions of
qemu_memalign() and qemu_try_memalign(), and moves the prototypes out
of osdep.h.

Changes v1->v2:
 * Replacement patch 4, which takes the approach discussed in
   comments on v1 of making all our implementations handle
   size == 0 by doing a size 1 allocation
 * two #include lines accidentally added in patch 7 are
   moved to patch 6 where they belong (fixes compile failure
   during bisect)

Patch 4 is the only one needing review.

(When I came to make this change I decided that there was
just a bit more involved than I was happy making in passing
while assembling a pull request.)

thanks
-- PMM


Peter Maydell (9):
  hw/usb/redirect.c: Stop using qemu_oom_check()
  util: Make qemu_oom_check() a static function
  util: Unify implementations of qemu_memalign()
  util: Return valid allocation for qemu_try_memalign() with zero size
  meson.build: Don't misdetect posix_memalign() on Windows
  util: Share qemu_try_memalign() implementation between POSIX and
    Windows
  util: Use meson checks for valloc() and memalign() presence
  util: Put qemu_vfree() in memalign.c
  osdep: Move memalign-related functions to their own header

 meson.build                    |  7 ++-
 include/qemu-common.h          |  2 -
 include/qemu/memalign.h        | 61 ++++++++++++++++++++++
 include/qemu/osdep.h           | 18 -------
 block/blkverify.c              |  1 +
 block/block-copy.c             |  1 +
 block/commit.c                 |  1 +
 block/crypto.c                 |  1 +
 block/dmg.c                    |  1 +
 block/export/fuse.c            |  1 +
 block/file-posix.c             |  1 +
 block/io.c                     |  1 +
 block/mirror.c                 |  1 +
 block/nvme.c                   |  1 +
 block/parallels-ext.c          |  1 +
 block/parallels.c              |  1 +
 block/qcow.c                   |  1 +
 block/qcow2-cache.c            |  1 +
 block/qcow2-cluster.c          |  1 +
 block/qcow2-refcount.c         |  1 +
 block/qcow2-snapshot.c         |  1 +
 block/qcow2.c                  |  1 +
 block/qed-l2-cache.c           |  1 +
 block/qed-table.c              |  1 +
 block/qed.c                    |  1 +
 block/quorum.c                 |  1 +
 block/raw-format.c             |  1 +
 block/vdi.c                    |  1 +
 block/vhdx-log.c               |  1 +
 block/vhdx.c                   |  1 +
 block/vmdk.c                   |  1 +
 block/vpc.c                    |  1 +
 block/win32-aio.c              |  1 +
 hw/block/dataplane/xen-block.c |  1 +
 hw/block/fdc.c                 |  1 +
 hw/ide/core.c                  |  1 +
 hw/ppc/spapr.c                 |  1 +
 hw/ppc/spapr_softmmu.c         |  1 +
 hw/scsi/scsi-disk.c            |  1 +
 hw/tpm/tpm_ppi.c               |  2 +-
 hw/usb/redirect.c              | 17 +++++--
 nbd/server.c                   |  1 +
 net/l2tpv3.c                   |  2 +-
 plugins/loader.c               |  1 +
 qemu-img.c                     |  1 +
 qemu-io-cmds.c                 |  1 +
 qom/object.c                   |  1 +
 softmmu/physmem.c              |  1 +
 target/i386/hvf/hvf.c          |  1 +
 target/i386/kvm/kvm.c          |  1 +
 tcg/region.c                   |  1 +
 tests/bench/atomic_add-bench.c |  1 +
 tests/bench/qht-bench.c        |  1 +
 util/atomic64.c                |  1 +
 util/memalign.c                | 92 ++++++++++++++++++++++++++++++++++
 util/oslib-posix.c             | 46 -----------------
 util/oslib-win32.c             | 35 -------------
 util/qht.c                     |  1 +
 util/meson.build               |  1 +
 59 files changed, 224 insertions(+), 107 deletions(-)
 create mode 100644 include/qemu/memalign.h
 create mode 100644 util/memalign.c

-- 
2.25.1