OSDN Git Service

cpus: protect TimerState writes with a spinlock
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 14 Aug 2018 07:57:16 +0000 (09:57 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 23 Aug 2018 16:46:25 +0000 (18:46 +0200)
commit94377115b2458506579907f3ebf1ffbfea12b216
tree401e56cc1152cca4c83e59cc8d70855285f68011
parent988fcafc730242711ba92f9e62557e37f2b22cc0
cpus: protect TimerState writes with a spinlock

In the next patch, we will need to write cpu_ticks_offset from any
thread, even outside the BQL.  Currently, it is protected by the BQL
just because cpu_enable_ticks and cpu_disable_ticks happen to hold it,
but the critical sections are well delimited and it's easy to remove
the BQL dependency.

Add a spinlock that matches vm_clock_seqlock, and hold it when writing
to the TimerState.  This also lets us fix cpu_update_icount when 64-bit
atomics are not available.

Fields of TiemrState are reordered to avoid padding.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cpus.c