From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAcFG-0007aL-JD for qemu-devel@nongnu.org; Fri, 25 Jul 2014 05:57:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAcFB-0002LV-3u for qemu-devel@nongnu.org; Fri, 25 Jul 2014 05:56:58 -0400 Received: from zimbra3.corp.accelance.fr ([2001:4080:204::2:8]:38458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAcFA-0002LL-PJ for qemu-devel@nongnu.org; Fri, 25 Jul 2014 05:56:53 -0400 From: Sebastian Tanase Date: Fri, 25 Jul 2014 11:56:27 +0200 Message-Id: <1406282193-9664-1-git-send-email-sebastian.tanase@openwide.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH V5 0/6] icount: Implement delay algorithm between guest and host clocks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, Sebastian Tanase , jeremy.rosen@openwide.fr, alex@alex.org.uk, wenchaoqemu@gmail.com, quintela@redhat.com, mst@redhat.com, stefanha@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, michael@walle.cc, camille.begue@openwide.fr, aliguori@amazon.com, crobinso@redhat.com, pbonzini@redhat.com, pierre.lemagourou@openwide.fr, afaerber@suse.de, rth@twiddle.net The icount option already implemented in QEMU allows the guest to run at = a theoretical frequency of 1/(2^N) GHz (N is the icount parameter). The goal of this pa= tch is to have a real guest frequency close to the one imposed by using the icount option. The main idea behind the algorithm is that we compare the virtual monoton= ic clock and the host monotonic clock. For big icounts (on our test machine, an i5 CPU @ 3= .10GHz, icounts starting at 6) the guest clock will be ahead of the host clock. In this c= ase, we try to sleep QEMU for the difference between the 2 clocks. Therefore, the guest = would have executed for a period almost equally to the one imposed by icount. We sho= uld point out that the algorithm works only for those icounts that allow the guest cloc= k to be in front of the host clock. The first patch adds support for QemuOpts for the 'icount' parameter. It = also adds a suboption called 'shift' that will hold the value for 'icount'. Therefore= we now have -icount shift=3DN|auto or -icount N|auto. The second patch adds the 'align' suboption for icount. The third patch exports 'icount_time_shift' so that it can be used in pla= ces other than cpus.c; we need it in cpu-exec.c for calculating for how long we want QEM= U to sleep. The forth patch implements the algorithm used for calculating the delay w= e want to sleep. It uses the number of instructions executed by the virtual cpu and also t= he icount_time_shift. The fifth patch prints to the console whenever the guest clock runs behin= d the host clock. The fastest printing speed is every 2 seconds, and we only print i= f the align option is enabled. We also have a limit to 100 printed messages. The sixth patch adds information about the difference between the host an= d guest clocks (taking into account the offset) in the 'info jit' command. We also print= the maximum delay and advance of the guest clock compared to the host clock. v4 -> v5 * Use existing offset value (timers_state.cpu_clock_offset) for computati= on -> patch 4 * Use cpu_get_clock and cpu_get_icount for showing drift information -> p= atch 6 Important note: This patch series relies on the bug fix discussed here http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg03208.html Sebastian Tanase (6): icount: Add QemuOpts for icount icount: Add align option to icount icount: Make icount_time_shift available everywhere cpu_exec: Add sleeping algorithm cpu_exec: Print to console if the guest is late monitor: Add drift info to 'info jit' cpu-exec.c | 127 ++++++++++++++++++++++++++++++++++++++++++++= ++++++ cpus.c | 59 +++++++++++++++++++++-- include/qemu-common.h | 9 +++- include/qemu/timer.h | 1 + monitor.c | 1 + qemu-options.hx | 17 +++++-- qtest.c | 13 +++++- vl.c | 39 +++++++++++++--- 8 files changed, 248 insertions(+), 18 deletions(-) --=20 2.0.0.rc2