[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 04/47] util/oslib-win32: Use _aligned_malloc for qemu_try_mema
From: |
Volker Rümelin |
Subject: |
Re: [PULL 04/47] util/oslib-win32: Use _aligned_malloc for qemu_try_memalign |
Date: |
Mon, 11 Jan 2021 00:18:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
> We do not need or want to be allocating page sized quanta.
>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Reviewed-by: Stefan Weil <sw@weilnetz.de>
> Message-Id: <20201018164836.1149452-1-richard.henderson@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> util/oslib-win32.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index 01787df74c..8adc651259 100644
> --- a/util/oslib-win32.c
> +++ b/util/oslib-win32.c
> @@ -39,6 +39,7 @@
> #include "trace.h"
> #include "qemu/sockets.h"
> #include "qemu/cutils.h"
> +#include <malloc.h>
>
> /* this must come after including "trace.h" */
> #include <shlobj.h>
> @@ -56,10 +57,8 @@ void *qemu_try_memalign(size_t alignment, size_t size)
> {
> void *ptr;
>
> - if (!size) {
> - abort();
> - }
> - ptr = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
> + g_assert(size != 0);
> + ptr = _aligned_malloc(alignment, size);
Hi Richard,
this doesn't work really well. The _aligned_malloc parameters are swapped. ptr
= _aligned_malloc(size, alignment) is correct.
With best regards,
Volker
> trace_qemu_memalign(alignment, size, ptr);
> return ptr;
> }
> @@ -93,9 +92,7 @@ void *qemu_anon_ram_alloc(size_t size, uint64_t *align,
> bool shared)
> void qemu_vfree(void *ptr)
> {
> trace_qemu_vfree(ptr);
> - if (ptr) {
> - VirtualFree(ptr, 0, MEM_RELEASE);
> - }
> + _aligned_free(ptr);
> }
>
> void qemu_anon_ram_free(void *ptr, size_t size)
- [PULL 00/47] tcg patch queue, Richard Henderson, 2021/01/07
- [PULL 01/47] linux-user: Conditionalize TUNSETVNETLE, Richard Henderson, 2021/01/07
- [PULL 02/47] tcg/i386: Adjust TCG_TARGET_HAS_MEMORY_BSWAP, Richard Henderson, 2021/01/07
- [PULL 03/47] tcg: Introduce INDEX_op_qemu_st8_i32, Richard Henderson, 2021/01/07
- [PULL 04/47] util/oslib-win32: Use _aligned_malloc for qemu_try_memalign, Richard Henderson, 2021/01/07
- Re: [PULL 04/47] util/oslib-win32: Use _aligned_malloc for qemu_try_memalign,
Volker Rümelin <=
- [PULL 05/47] util/oslib: Assert qemu_try_memalign() alignment is a power of 2, Richard Henderson, 2021/01/07
- [PULL 06/47] tcg: Do not flush icache for interpreter, Richard Henderson, 2021/01/07
- [PULL 07/47] util: Enhance flush_icache_range with separate data pointer, Richard Henderson, 2021/01/07
- [PULL 08/47] util: Specialize flush_idcache_range for aarch64, Richard Henderson, 2021/01/07
- [PULL 09/47] tcg: Move tcg prologue pointer out of TCGContext, Richard Henderson, 2021/01/07
- [PULL 10/47] tcg: Move tcg epilogue pointer out of TCGContext, Richard Henderson, 2021/01/07
- [PULL 12/47] tcg: Introduce tcg_splitwx_to_{rx,rw}, Richard Henderson, 2021/01/07
- [PULL 14/47] tcg: Adjust tcg_out_call for const, Richard Henderson, 2021/01/07
- [PULL 13/47] tcg: Adjust TCGLabel for const, Richard Henderson, 2021/01/07