qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] oslib-posix: initialize mutex and condition variable


From: Christian Borntraeger
Subject: Re: [PATCH] oslib-posix: initialize mutex and condition variable
Date: Tue, 10 Mar 2020 21:23:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1


On 10.03.20 18:59, Paolo Bonzini wrote:
> The mutex and condition variable were never initialized, causing
> -mem-prealloc to abort with an assertion failure.
> 
> Fixes: 037fb5eb3941c80a2b7c36a843e47207ddb004d4
> Reported-by: Christian Borntraeger <address@hidden>

You might want to replace this by 
Reported-by: Marc Hartmayer <address@hidden>

> Cc: bauerchen <address@hidden>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>  util/oslib-posix.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index 897e8f3ba6..4dd6d7d4b4 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -466,10 +466,17 @@ static inline int get_memset_num_threads(int smp_cpus)
>  static bool touch_all_pages(char *area, size_t hpagesize, size_t numpages,
>                              int smp_cpus)
>  {
> +    static gsize initialized = 0;
>      size_t numpages_per_thread, leftover;
>      char *addr = area;
>      int i = 0;
>  
> +    if (g_once_init_enter(&initialized)) {
> +        qemu_mutex_init(&page_mutex);
> +        qemu_cond_init(&page_cond);
> +        g_once_init_leave(&initialized, 1);
> +    }
> +
>      memset_thread_failed = false;
>      threads_created_flag = false;
>      memset_num_threads = get_memset_num_threads(smp_cpus);
> 




reply via email to

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