> From: Paolo Bonzini [mailto:paolo.bonz...@gmail.com] On Behalf Of Paolo > Bonzini > On 26/11/2014 11:39, Pavel Dovgalyuk wrote: > > +int64_t cpu_get_instructions_counter(void) > > +{ > > + /* This function calls are synchnonized to timer changes, > > + calling cpu_get_instructions_counter_locked without lock is safe */ > > + int64_t icount = timers_state.qemu_icount; > > + CPUState *cpu = current_cpu; > > + > > + if (cpu) { > > + icount -= (cpu->icount_decr.u16.low + cpu->icount_extra); > > + } > > + return icount; > > Why do you need to do this if !cpu_can_do_io(cpu)?
We save number of executed instruction when saving interrupt or exception event. It leads to the call of cpu_get_instructions_counter() from cpu_exec function (through several replay functions). It is correct (because no block is executing at that moment) but is different to prior usage of icount requests. > Perhaps a better name for the functions is > > - cpu_get_instructions_counter_locked -> cpu_get_icount_raw > > - cpu_get_instructions_counter -> cpu_get_icount_raw_nocheck Ok, I'll rename these functions. Pavel Dovgalyuk