[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 16/16] cpus-common: lock-free fast path for cpu_
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 16/16] cpus-common: lock-free fast path for cpu_exec_start/end |
Date: |
Sat, 24 Sep 2016 07:52:53 -0400 (EDT) |
----- Original Message -----
> From: "Richard Henderson" <address@hidden>
> To: "Paolo Bonzini" <address@hidden>, address@hidden
> Cc: "serge fdrv" <address@hidden>, address@hidden, "alex bennee"
> <address@hidden>, "sergey fedorov"
> <address@hidden>
> Sent: Friday, September 23, 2016 8:23:46 PM
> Subject: Re: [Qemu-devel] [PATCH 16/16] cpus-common: lock-free fast path for
> cpu_exec_start/end
>
> On 09/23/2016 12:31 AM, Paolo Bonzini wrote:
> > + if (atomic_read(&other_cpu->running)) {
> ...
> > + atomic_set(&cpu->running, true);
> ...
> > + cpu->running = false;
> ...
> > + cpu->running = true;
>
> Inconsistent use of atomics. I don't see that the cpu_list_lock protects the
> last two lines in any way.
It does:
qemu_mutex_lock(&qemu_cpu_list_lock);
if (!cpu->has_waiter) {
/* Not counted in pending_cpus, let the exclusive item
* run. Since we have the lock, just set cpu->running to true
* while holding it; no need to check pending_cpus again.
*/
cpu->running = false;
exclusive_idle();
/* Now pending_cpus is zero. */
cpu->running = true;
} else {
/* Counted in pending_cpus, go ahead and release the
* waiter at cpu_exec_end.
*/
}
qemu_mutex_unlock(&qemu_cpu_list_lock);
but I can change it anyway to atomic_set.
Paolo
- [Qemu-devel] [PATCH 15/16] tcg: Make tb_flush() thread safe, (continued)
[Qemu-devel] [PATCH 14/16] cpus-common: Introduce async_safe_run_on_cpu(), Paolo Bonzini, 2016/09/23
[Qemu-devel] [PATCH 16/16] cpus-common: lock-free fast path for cpu_exec_start/end, Paolo Bonzini, 2016/09/23
[Qemu-devel] [PATCH 12/16] cpus-common: remove redundant call to exclusive_idle(), Paolo Bonzini, 2016/09/23
Re: [Qemu-devel] [PATCH v8 00/16] cpu-exec: Safe work in quiescent state, Alex Bennée, 2016/09/25