qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/6] util/oslib-win32: Use _aligned_malloc for qemu_try_me


From: Eduardo Habkost
Subject: Re: [PATCH v2 1/6] util/oslib-win32: Use _aligned_malloc for qemu_try_memalign
Date: Thu, 17 Sep 2020 14:43:35 -0400

On Tue, Sep 15, 2020 at 05:46:33PM -0700, Richard Henderson wrote:
> We do not need or want to be allocating page sized quanta.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Would it be safe to keep patches 2-6 applied in case this one
gets dropped or reverted for any reason?

I consider patches 2-6 bug fixes (that I'd like to merge soon),
and this one as an optimization (that could be merged later).

> ---
> Cc: Stefan Weil <sw@weilnetz.de>
> ---
>  util/oslib-win32.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index c654dafd93..8d838bf342 100644
> --- a/util/oslib-win32.c
> +++ b/util/oslib-win32.c
> @@ -56,10 +56,8 @@ void *qemu_try_memalign(size_t alignment, size_t size)
>  {
>      void *ptr;
>  
> -    if (!size) {
> -        abort();
> -    }
> -    ptr = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE);
> +    assert(size != 0);
> +    ptr = _aligned_malloc(alignment, size);
>      trace_qemu_memalign(alignment, size, ptr);
>      return ptr;
>  }
> @@ -93,9 +91,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)
> -- 
> 2.25.1
> 
> 

-- 
Eduardo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]