[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH V7 02/19] cpus: add tcg_exec_flag.
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC PATCH V7 02/19] cpus: add tcg_exec_flag. |
Date: |
Tue, 11 Aug 2015 14:57:50 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 11/08/2015 13:11, Frederic Konrad wrote:
> On 11/08/2015 12:53, Paolo Bonzini wrote:
>>
>> On 10/08/2015 17:27, address@hidden wrote:
>>> @@ -583,5 +587,6 @@ int cpu_exec(CPUState *cpu)
>>> /* fail safe : never use current_cpu outside cpu_exec() */
>>> current_cpu = NULL;
>>> + tcg_cpu_allow_execution(cpu);
>> I don't think this is correct; safe_work_pending() is a much clearer
>> test. I'll revert locally to the previous version to play more with the
>> code.
>>
>> Paolo
>
> Yes definitely but we might have a race if we just use safe_work_pending().
The trick is to order the accesses correctly. For example, cpu_exec
will check tcg_exit_req, then clear exit_request, then check
queued_work_first. On the write side the order is the opposite:
queued_work_first must be written first, then exit_request, then
tcg_exit_req.
Here it is the same. safe_work_pending must be incremented first to
prevent threads from entering cpu-exec.c; for those that are already in
there you write queued_safe_work_first, then exit_request, then
tcg_exit_req. Similarly safe_work_pending must be decremented last.
Paolo
[Qemu-devel] [RFC PATCH V7 03/19] cpus: introduce async_run_safe_work_on_cpu., fred . konrad, 2015/08/10
[Qemu-devel] [RFC PATCH V7 05/19] remove unused spinlock., fred . konrad, 2015/08/10
[Qemu-devel] [RFC PATCH V7 06/19] add support for spin lock on POSIX systems exclusively, fred . konrad, 2015/08/10
[Qemu-devel] [RFC PATCH V7 04/19] replace spinlock by QemuMutex., fred . konrad, 2015/08/10
[Qemu-devel] [RFC PATCH V7 07/19] protect TBContext with tb_lock., fred . konrad, 2015/08/10