From patchwork Fri Mar 4 11:21:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 548107 Delivered-To: patch@linaro.org Received: by 2002:ac0:f585:0:0:0:0:0 with SMTP id s5csp1253imq; Fri, 4 Mar 2022 03:28:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2oZK2JJXojARXBMoy9PrU4qCH5NwhKx9QJtZPKi8tFzYq4WoGoESodzv1vNXOYN3qbWJ2 X-Received: by 2002:a81:7886:0:b0:2dc:5d84:622b with SMTP id t128-20020a817886000000b002dc5d84622bmr2273388ywc.40.1646393292589; Fri, 04 Mar 2022 03:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646393292; cv=none; d=google.com; s=arc-20160816; b=LRXZUxyf4gVqXayAfFQ94Yxcu8lgLpsMNi7YmSf2vpwEACTjrAbzemkXppWctvAUy4 VaBTxZGNoM+wZMkEykC332X8cohihO8/U9ZvOfN8sl6FLavyJNipEArlhPYSGHKXbGvO 6rU4SfiiMRsubNjRNVH3Ni7b+mqMzLr5tNYVlLQO8mDE07JuwZC8tAv5j3Z0LazOTDpQ y0bvsh1VOFvLR6mtEsNbBPnpJb8KWAIytws3lgfemRLC/MjrBIgsJE+zpTO6H2UzrJiU NBPXRJE4TWzJ28toAZINYtsYl4KGoQiI15wdoFOfq5FZFVyYAR2m2B8FWBMQ+PSwh9TI Kcmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=cYwUVlrJmDcCkID1J7elovzHQrM1WzQMevVmjItgLkU=; b=XbjuTLAK1wmVPk+dsqr6onNOM9aY8IXvwei4llKBcY3uKdRA5TdugbIiSySxw9h+7N NVfmEprljOlEYTafo20obVUR2Y+w4+8OtPm3HWNQSOZNLmXmc6FvdZskvKGsL9I8CXku B4nfMiTV5CHe48v7QqaEqP8WQYr4ynH0lgjoqBtJgwt9nNgkBLucceXUR3gXK22geMfB 8LyeosVH4bkaQB33ublXiM/hxsnj714vyBjt52Nqyj1NLePlY39wr4jmBVV2pg+erGKR E54Mv4YFyGy+oUQeXPpuq4xPNJTd0uWCmggKLV0MCe8UjdfU2SrSz6aX4GOfbRqlsmEp e6hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="E0/lETEw"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w8-20020a81d108000000b002d035ccf9c0si3719619ywi.100.2022.03.04.03.28.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Mar 2022 03:28:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="E0/lETEw"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:35296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ66W-0001Em-25 for patch@linaro.org; Fri, 04 Mar 2022 06:28:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ606-0002VY-IN for qemu-devel@nongnu.org; Fri, 04 Mar 2022 06:21:34 -0500 Received: from [2a00:1450:4864:20::32c] (port=55870 helo=mail-wm1-x32c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nQ603-0004dp-Gf for qemu-devel@nongnu.org; Fri, 04 Mar 2022 06:21:34 -0500 Received: by mail-wm1-x32c.google.com with SMTP id i66so4801346wma.5 for ; Fri, 04 Mar 2022 03:21:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cYwUVlrJmDcCkID1J7elovzHQrM1WzQMevVmjItgLkU=; b=E0/lETEwDng8oU/bIrggCzAjDNa+5WY+MmzDgCZhqZMfhMwN9IVj1T3d4O8/qhwj1C ozZHwKLnUMyGC1XkGSCioE8EilCBLVzbobv0Jxqt0yvz4LR6rhjq9jcZ/v/i3PKSb70t P5o53BoKp+YxXBE6CfiYFFjDJJdsbsW4Ll3J77kHO1uabfkVpztG4hx5g58+I/bAaehU nsNDaxDDNBUd3O5HGMYkVfaDclFR5BplhX+k8MdmFt/r4rBnPb8KOhjbplpS54SyugJq FdPQeVzBKy5VYZWM12pIQdWSoJEUu8Yz3hykLggN94g43feAbTLoWy05LFea0bfQ0FG/ qAcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cYwUVlrJmDcCkID1J7elovzHQrM1WzQMevVmjItgLkU=; b=MTASEQSBn4c7dm2CbOAEhXMoTBGSsThkE3ZVvKkVHRd6OWXHVuuaZBNjAP85+sLXzz II9PMfd2YDWB94Rx9lXjhRjvX4jKM43KHtHW7WTR6mxJFDvogcK85spNwFSyW5S2OL1S Usf2HQLvtpa2VqHdp4VbodwVH9WzPfZooNvhxXJZcE5jyHvdwQVBZPlh7MHPBYzycRKL co1+4siNVOHdjcdTrlYm8hMIA3QzfM9iFsLf/GYaCrxRBQe5YArqBReFkH7wXwG9lyOP +4iyL8F7Vs6WfDFr+jHglcPAdwxKarGYbe6rtqoDkIQyuQNqzSzwRSrZp0db/QuVM8IT dURg== X-Gm-Message-State: AOAM530eQG9qu+WgZHw5ARIj9tMVWUvJRaApxUgS0/cyThOrom7OaqK6 GAgBC0c+NKgDE40S3jleMW4jI4QQ0qTeXg== X-Received: by 2002:a05:600c:a06:b0:37b:fdd8:4f8 with SMTP id z6-20020a05600c0a0600b0037bfdd804f8mr7403607wmp.41.1646392889204; Fri, 04 Mar 2022 03:21:29 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id u14-20020adfed4e000000b001e3323611e5sm4148651wro.26.2022.03.04.03.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 03:21:28 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 0/9] Cleanup of qemu_oom_check() and qemu_memalign() Date: Fri, 4 Mar 2022 11:21:17 +0000 Message-Id: <20220304112126.2261039-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Richard Henderson , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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