From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xw70X-0005w9-5Z for qemu-devel@nongnu.org; Wed, 03 Dec 2014 05:18:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xw70O-0000sY-5I for qemu-devel@nongnu.org; Wed, 03 Dec 2014 05:18:05 -0500 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:44357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xw70N-0000sP-UT for qemu-devel@nongnu.org; Wed, 03 Dec 2014 05:17:56 -0500 Received: by mail-wg0-f53.google.com with SMTP id l18so19105117wgh.26 for ; Wed, 03 Dec 2014 02:17:55 -0800 (PST) Sender: Paolo Bonzini Message-ID: <547EE34D.4000500@redhat.com> Date: Wed, 03 Dec 2014 11:17:49 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <20141126103841.7772.11864.stgit@PASHA-ISP> <20141126103925.7772.13043.stgit@PASHA-ISP> In-Reply-To: <20141126103925.7772.13043.stgit@PASHA-ISP> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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: Pavel Dovgalyuk , 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 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)? 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 This makes it clear that cpu_get_instructions_counter should raise questions to a reviewer. Paolo