On 05/04/2017 16:34, Alex Bennée wrote: >> On 05/04/2017 15:25, Alex Bennée wrote: >>> +{ >>> + int64_t executed = cpu_get_icount_executed(cpu); >>> + cpu->icount_budget -= executed; >>> + atomic_add(&timers_state.qemu_icount, executed); >>> +} >> Since there's only one writer, it's also okay to do >> >> atomic_set(&timers_state.qemu_icount, >> atomic_read(&timers_state.qemu_icount) + executed); >> >> (also not just faster, but also simpler to turn into TCG code if we do >> the update in gen_io_start). > > OK fair enough. Annoyingly I've just noticed this breaks for 32 bit > hosts because we might not have CONFIG_ATOMIC64. What's the best > approach? #ifdef and handwave?
For 2.9 yes... For 2.10 I'm going to add a "Stat64" type that can compute max or add of 63-bit values, and blocks on the read side if a doubleword change is in progress. Paolo