On 31/10/2017 12:26, Pavel Dovgalyuk wrote:
> +    /* We need to drop the replay_lock so any vCPU threads woken up
> +     * can finish their replay tasks
> +     */
> +    if (replay_mode != REPLAY_MODE_NONE) {
> +        g_assert(replay_mutex_locked());
> +        qemu_mutex_unlock_iothread();
> +        replay_mutex_unlock();
> +        qemu_mutex_lock_iothread();
> +    }

The assert+unlock+lock here is unnecessary; just do

    if (replay_mode != REPLAY_MODE_NONE) {
        replay_mutex_unlock();
    }

which according to a previous suggestion can become just

    replay_mutex_unlock();

>      while (!all_vcpus_paused()) {
>          qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex);
>          CPU_FOREACH(cpu) {
>              qemu_cpu_kick(cpu);
>          }
>      }
> +
> +    if (replay_mode != REPLAY_MODE_NONE) {
> +        qemu_mutex_unlock_iothread();
> +        replay_mutex_lock();
> +        qemu_mutex_lock_iothread();
> +    }

Likewise, this is not a fast path so:

       qemu_mutex_unlock_iothread();
       if (replay_mode != REPLAY_MODE_NONE) {
           replay_mutex_lock();
       }
       qemu_mutex_lock_iothread();

or, applying the same previous suggestion,

       /* Unlock iothread to preserve lock hierarchy.  */
       qemu_mutex_unlock_iothread();
       replay_mutex_lock();
       qemu_mutex_lock_iothread();

Paolo

Reply via email to