qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH 17/26] replay: push replay_mutex_lock up the


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC PATCH 17/26] replay: push replay_mutex_lock up the call tree
Date: Thu, 2 Nov 2017 13:00:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

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

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