qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH V2 0/5] icount: Implement delay algorithm between guest and host clocks
@ 2014-06-13  9:40 Sebastian Tanase
  2014-06-13  9:40 ` [Qemu-devel] [RFC PATCH V2 1/5] icount: Add 'align' and 'icount' options Sebastian Tanase
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Sebastian Tanase @ 2014-06-13  9:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, Sebastian Tanase, jeremy.rosen, alex,
	wenchaoqemu, quintela, mjt, mst, stefanha, armbru, lcapitulino,
	michael, camille.begue, aliguori, crobinso, pbonzini,
	pierre.lemagourou, afaerber, rth

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 patch 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 monotonic 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 case, 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 should point out
that the algorithm works only for those icounts that allow the guest clock to be in front
of the host clock.

The first patch adds the 'align' parameter for icount and changes the icount option from
'-icount [N|auto]' to '-icount [icount=][N|auto][,align=on|off]'.

The second patch exports 'icount_time_shift' so that it can be used in places other than
cpus.c; we need it in cpu-exec.c for calculating for how long we want QEMU to sleep.

The third patch implements the algorithm used for calculating the delay we want to sleep.
It uses the number of instructions executed by the virtual cpu and also the icount_time_shift.
All the parts in cpu-exec.c are only compiled for soft-mmu architectures otherwise the code
will not compile for all architectures (linux-user and soft-mmu).

The forth patch updates the algorithm to take into account an initial offset between clocks.
The offset can be 0 (for example on ARM) or another value (typically it is almost equal
to the realtime clock) on other architectures (for example on x86).

The fifth and final patch prints to the console whenever the guest clock runs behind the host
clock. The fastest printing speed is every 2 seconds, and we only print if the align option
is enabled.

v1 -> v2

* Signal errors in configure_icount() as suggested by Paolo Bonzini (patch 1).
* Update qtest.c to take into account the new configure_icount() (patch 1).
* Surround delay code in cpu-exec.c with !defined(CONFIG_USER_ONLY) (patch 3).
* Clean up delay code in cpu-exec.c as suggested by Paolo Bonzini
  and Juan Quintela (patch 3).
* Take into account initial offset between real and virtual clocks (patch 4).

Sebastian Tanase (5):
  icount: Add 'align' and 'icount' options
  icount: Make icount_time_shift available everywhere
  cpu_exec: Add sleeping algorithm
  icount_warp: Take into account initial offset between clocks
  cpu_exec: Print to console if the guest is late

 cpu-exec.c                | 108 +++++++++++++++++++++++++++++++++++++++++++++-
 cpus.c                    |  38 ++++++++++++++--
 include/qapi/qmp/qerror.h |   9 ++++
 include/qemu-common.h     |   6 ++-
 qemu-options.hx           |  19 ++++++--
 qtest.c                   |  19 +++++++-
 vl.c                      |  43 +++++++++++++++---
 7 files changed, 225 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-06-13 12:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-13  9:40 [Qemu-devel] [RFC PATCH V2 0/5] icount: Implement delay algorithm between guest and host clocks Sebastian Tanase
2014-06-13  9:40 ` [Qemu-devel] [RFC PATCH V2 1/5] icount: Add 'align' and 'icount' options Sebastian Tanase
2014-06-13 10:17   ` Paolo Bonzini
2014-06-13  9:40 ` [Qemu-devel] [RFC PATCH V2 2/5] icount: Make icount_time_shift available everywhere Sebastian Tanase
2014-06-13  9:40 ` [Qemu-devel] [RFC PATCH V2 3/5] cpu_exec: Add sleeping algorithm Sebastian Tanase
2014-06-13 10:27   ` Paolo Bonzini
2014-06-13  9:40 ` [Qemu-devel] [RFC PATCH V2 4/5] icount_warp: Take into account initial offset between clocks Sebastian Tanase
2014-06-13 10:28   ` Paolo Bonzini
2014-06-13  9:40 ` [Qemu-devel] [RFC PATCH V2 5/5] cpu_exec: Print to console if the guest is late Sebastian Tanase
2014-06-13 10:29   ` Paolo Bonzini
2014-06-13 12:00     ` Sebastian Tanase
2014-06-13 12:03       ` Paolo Bonzini
2014-06-13 10:32 ` [Qemu-devel] [RFC PATCH V2 0/5] icount: Implement delay algorithm between guest and host clocks Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).