[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 08/12] cpus: always call seqlock_write in cpu
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v2 08/12] cpus: always call seqlock_write in cpu_update_icount |
Date: |
Tue, 11 Sep 2018 14:55:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 11/09/2018 14:53, Richard Henderson wrote:
>>
>> -#ifndef CONFIG_ATOMIC64
>> seqlock_write_lock(&timers_state.vm_clock_seqlock,
>> &timers_state.vm_clock_lock);
>> -#endif
>> atomic_set__nocheck(&timers_state.qemu_icount,
>> timers_state.qemu_icount + executed);
>> -#ifndef CONFIG_ATOMIC64
>> seqlock_write_unlock(&timers_state.vm_clock_seqlock,
>> &timers_state.vm_clock_lock);
>> -#endif
> I don't understand this. Surely you either want atomic64_set,
> or an actual atomic64_add, but no extra lock when CONFIG_ATOMIC64.
Even though writes of qemu_icount can safely race with reads in
qemu_icount_raw, qemu_icount is also read by icount_adjust, which runs
in the I/O thread. Therefore, writes do need protection of the
vm_clock_lock; for simplicity Emilio's patch protects it with both
seqlock+spinlock, which we already do for hosts that lack 64-bit atomics.
The bug actually predated the introduction of vm_clock_lock;
cpu_update_icount would have needed the BQL before the spinlock was
introduced.
The above could have been a commit message, by the way. :)
Paolo
- Re: [Qemu-devel] [PATCH v2 02/12] util: add atomic64, (continued)
- [Qemu-devel] [PATCH v2 06/12] atomic: fix comment s/x64_64/x86_64/, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 05/12] test-rcu-list: access n_reclaims and n_nodes_removed with atomic64, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 07/12] cpus: initialize timers_state.vm_clock_lock, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 04/12] qsp: use atomic64 accessors, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 03/12] tests: add atomic64-bench, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 08/12] cpus: always call seqlock_write in cpu_update_icount, Emilio G. Cota, 2018/09/10
- Re: [Qemu-devel] [PATCH v2 00/12] i386 + x86_64 mttcg, Paolo Bonzini, 2018/09/11