Received: from eggs.gnu.org ([2001:4830:134:3::10]:42261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwUAu-0006rS-U8 for qemu-devel@nongnu.org; Thu, 04 Dec 2014 06:02:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwUAn-0008RU-B1 for qemu-devel@nongnu.org; Thu, 04 Dec 2014 06:02:20 -0500 Received: from mail.ispras.ru ([83.149.199.45]:41191) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwUAn-0008Qp-3L for qemu-devel@nongnu.org; Thu, 04 Dec 2014 06:02:13 -0500 From: "Pavel Dovgaluk" References: <20141126103841.7772.11864.stgit@PASHA-ISP> <20141126103925.7772.13043.stgit@PASHA-ISP> <547EE34D.4000500@redhat.com> In-Reply-To: <547EE34D.4000500@redhat.com> Date: Thu, 4 Dec 2014 14:02:12 +0300 Message-ID: <000c01d00fb1$c2010860$46031920$@Dovgaluk@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-Language: ru Subject: Re: [Qemu-devel] [RFC PATCH v5 07/31] icount: implement icount requesting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Paolo Bonzini' , qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, alex.bennee@linaro.org, afaerber@suse.de, fred.konrad@greensocs.com > From: Paolo Bonzini [mailto:paolo.bonzini@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