From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyG8X-00048I-VF for qemu-devel@nongnu.org; Fri, 29 May 2015 04:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyG8G-0008Vd-2i for qemu-devel@nongnu.org; Fri, 29 May 2015 04:59:29 -0400 Received: from zimbra3.corp.accelance.fr ([2001:4080:204::2:8]:52609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyG8F-0008VZ-MU for qemu-devel@nongnu.org; Fri, 29 May 2015 04:59:11 -0400 Date: Fri, 29 May 2015 10:59:07 +0200 (CEST) From: Victor Clement Message-ID: <1155201608.740003.1432889947235.JavaMail.root@openwide.fr> In-Reply-To: <5565BDF0.8050508@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] icount: implement a new icount_no_rt mode without real time cpu sleeping List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?utf-8?Q?fran=C3=A7ois?= Guerret , Paolo Bonzini , Julien Viard de Galbert ----- Mail original ----- > De: "Paolo Bonzini" > =C3=80: "Victor CLEMENT" , qemu-devel@nongnu.= org > Cc: "francois guerret" > Envoy=C3=A9: Mercredi 27 Mai 2015 14:52:00 > Objet: Re: [Qemu-devel] [PATCH 1/3] icount: implement a new icount_no_rt = mode without real time cpu sleeping >=20 >=20 >=20 > On 27/05/2015 13:52, Victor CLEMENT wrote: > > In this new icount_no_rt mode, the QEMU_VIRTUAL_CLOCK runs at the > > maximum possible speed by warping the sleep times of the virtual > > cpu to the > > soonest clock deadline. The virtual clock will be updated only > > according > > the instruction counter. > >=20 > > Signed-off-by: Victor CLEMENT > > --- > > cpus.c | 64 > > ++++++++++++++++++++++++++++++++++++++++------------------------ > > 1 file changed, 40 insertions(+), 24 deletions(-) > >=20 > > diff --git a/cpus.c b/cpus.c > > index de6469f..012d14b 100644 > > --- a/cpus.c > > +++ b/cpus.c > > @@ -105,6 +105,7 @@ static bool all_cpu_threads_idle(void) > > =20 > > /* Protected by TimersState seqlock */ > > =20 > > +static bool icount_no_rt; >=20 > It is somewhat hard to read the code due to double negations. What > about "-icount sleep=3D[yes|no]" and naming the variable > "icount_sleep"? You are right, the "nort" can be ambiguous. icount_sleep seems clear. Thanks for the suggestion. > [...] > > + if (icount_no_rt) { > > + /* > > + * We never let VCPUs sleep in async icount mode. >=20 > s/async icount/sleep=3Dno/ >=20 > ? Right ! My bad... >=20 > Otherwise the series looks good. >=20 > Paolo Ok, I sumbit the v2 with icount_sleep naming. Victor >=20 > > + * If there is a pending QEMU_CLOCK_VIRTUAL timer we > > just advance > > + * to the next QEMU_CLOCK_VIRTUAL event and notify it. > > + * It is useful when we want a deterministic execution > > time, > > + * isolated from host latencies. > > + */ > > + seqlock_write_lock(&timers_state.vm_clock_seqlock); > > + timers_state.qemu_icount_bias +=3D deadline; > > + seqlock_write_unlock(&timers_state.vm_clock_seqlock); > > + qemu_clock_notify(QEMU_CLOCK_VIRTUAL); > > + } else { > > + /* > > + * We do stop VCPUs and only advance > > QEMU_CLOCK_VIRTUAL after some > > + * "real" time, (related to the time left until the > > next event) has > > + * passed. The QEMU_CLOCK_VIRTUAL_RT clock will do > > this. > > + * This avoids that the warps are visible externally; > > for example, > > + * you will not be sending network packets > > continuously instead of > > + * every 100ms. > > + */ > > + seqlock_write_lock(&timers_state.vm_clock_seqlock); > > + if (vm_clock_warp_start =3D=3D -1 || vm_clock_warp_start > > > clock) { > > + vm_clock_warp_start =3D clock; > > + } > > + seqlock_write_unlock(&timers_state.vm_clock_seqlock); > > + timer_mod_anticipate(icount_warp_timer, clock + > > deadline); > > } > > - seqlock_write_unlock(&timers_state.vm_clock_seqlock); > > - timer_mod_anticipate(icount_warp_timer, clock + deadline); > > } else if (deadline =3D=3D 0) { > > qemu_clock_notify(QEMU_CLOCK_VIRTUAL); > > } > >=20 >=20 >