qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping t


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC PATCH v4 13/23] cpus: only take BQL for sleeping threads
Date: Fri, 19 Jan 2018 09:59:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 19/01/2018 09:44, Pavel Dovgalyuk wrote:
>      while (all_cpu_threads_idle()) {
> +        qemu_mutex_lock_iothread();
>          stop_tcg_kick_timer();
>          qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
> +        qemu_mutex_unlock_iothread();
>      }

cpu_has_work cannot be called outside BQL yet.  You first need to access
cpu->interrupt_request with atomics.

In general, testing the condition outside the mutex is a very dangerous
pattern (and I'm usually the one who enjoys dangerous patterns).

But also, taking a slightly wider look:

>  static void qemu_tcg_rr_wait_io_event(CPUState *cpu)
>  {
>      while (all_cpu_threads_idle()) {
> +        qemu_mutex_lock_iothread();
>          stop_tcg_kick_timer();
>          qemu_cond_wait(cpu->halt_cond, &qemu_global_mutex);
> +        qemu_mutex_unlock_iothread();
>      }
>  
>      start_tcg_kick_timer();
>  
>      qemu_wait_io_event_common(cpu);
> -
> -    qemu_mutex_unlock_iothread();
>  }
>  

You are adding a qemu_mutex_lock_iothread to a function that wasn't
there before.  Either it was broken before, or it is now.

Paolo



reply via email to

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