From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZAKy-0001Iy-R4 for qemu-devel@nongnu.org; Thu, 25 Feb 2016 23:49:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZAKx-0004rV-T7 for qemu-devel@nongnu.org; Thu, 25 Feb 2016 23:49:08 -0500 Date: Fri, 26 Feb 2016 15:35:14 +1100 From: David Gibson Message-ID: <20160226043514.GK20657@voom.fritz.box> References: <56A7F3B7.3080908@ilande.co.uk> <20160201005218.GY23043@voom.redhat.com> <56B13EB4.9000309@ilande.co.uk> <20160203045926.GH15080@voom.fritz.box> <56CCCEAD.70805@ilande.co.uk> <20160224004738.GC2808@voom.fritz.box> <87mvqql27q.fsf@emacs.mitica> <56CE8436.6010404@ilande.co.uk> <56CE8A7B.60700@ilande.co.uk> <56CECE5C.4070302@ilande.co.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tKtFalx5NIx0HZ72" Content-Disposition: inline In-Reply-To: <56CECE5C.4070302@ilande.co.uk> Subject: Re: [Qemu-devel] [Qemu-ppc] Migrating decrementer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark Cave-Ayland Cc: amit.shah@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, quintela@redhat.com --tKtFalx5NIx0HZ72 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 25, 2016 at 09:50:20AM +0000, Mark Cave-Ayland wrote: > On 25/02/16 05:00, Mark Cave-Ayland wrote: >=20 > > On 25/02/16 04:33, Mark Cave-Ayland wrote: > >=20 > >> cpu_start/resume(): > >> cpu->tb_env->tb_offset =3D > >> qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) * tb_env->tb_freq + > >> cpu->tb_env->tb_offset - > >> qemu_clock_get_ns(QEMU_CLOCK_HOST) > >=20 > > Actually just realised this is slightly wrong and in fact should be: > >=20 > > cpu_start/resume(): > > cpu->tb_env->tb_offset =3D > > muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), > > cpu->tb_env->tb_freq, NANOSECONDS_PER_SECOND) + > > cpu->tb_env->tb_offset - > > qemu_clock_get_ns(QEMU_CLOCK_HOST) >=20 > Sign. And let me try that again, this time after caffeine: >=20 > cpu_start/resume(): > cpu->tb_env->tb_offset =3D > muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), > cpu->tb_env->tb_freq, NANOSECONDS_PER_SECOND) + > cpu->tb_env->tb_offset - > cpu_get_host_ticks(); >=20 > This should translate to: at CPU start, calculate the difference between > the current guest virtual timebase and the host timebase, storing the > difference in cpu->tb_env->tb_offset. Ummm... I think that's right. Except that you need to make sure you calculate the tb_offset just once, and set the same value to all guest CPUs. Otherwise the guest TBs may be slightly out of sync with each other, which is bad (the host should have already ensure that all host TBs are in sync with each other). We really should make helper routines that each Power machine type can use for this. Unfortunately we can't put it directly into the common ppc cpu migration code because of the requirement to keep the TBs synced across the machine. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --tKtFalx5NIx0HZ72 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWz9YCAAoJEGw4ysog2bOSPt0P/1Ehfsf6R+fXZPlsvBmsFaUI fMb+VPbx4kwglXhIjGPJtrfozLEZ3dpQ1gb1baaVlnYGve6oxE7Z031j2jLZbLDV eSBR6VJtpHxt6K7OyAlSZwYCY5mvpc8P4kNSL3ISSjJ9VHta+ps/iHzGxWfnGEkU j+wbaT78o+68wGqP+fIvBPsV+kBdvgacChxH1ewKoDuKyLwWkNN1pGEmlrDCikom R1V8x2ODEZPRLWRDiTUBCGe38MRuIwqeZGfF+tRAUn8CkXVEG3zJ1EJC61liEED1 J4sVOh+e7pV3CluaD6wOwfuvt+T3E5ad8Vgkjqt1XrZZj65FfbFobn1AGt3iC1rz pD9sblJpbviBMlTCXnZxbSyvJf9eWjAoguWzBR/aYgT4VBzuKCioPS0s0Lf4Av/L lVvpC3TRwXMpqKqxAw0jzm2Fh4FFJXNZga3JzoDSrTLxrD2/N5VyG1XfNdFsCOUF Kifz12HSJi8OS6j4VRqE69CNwdGA1l+z/p76DZrXrwNZQof4ES4uw3FA/MGk7QHD Q7haA7jaEtd/fl48wJf1u2gbYU4/hA8FhpadGqdc0FXc2C5Z/+wz6M/KIj9Ei8Fu YAbbQHiR5aNFOoSPOwOJTSiAg+zPGQSgZyxQscYG6XOiSx64q4W6hAy8AkDKPf1W 64Tk/xq5+u9Q8mx8UEGJ =4C4/ -----END PGP SIGNATURE----- --tKtFalx5NIx0HZ72--