From owner-freebsd-current@freebsd.org Wed Jun 27 17:10:55 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0ECE102DD17 for ; Wed, 27 Jun 2018 17:10:54 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8EEF7882F1; Wed, 27 Jun 2018 17:10:54 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from freefall.freebsd.org (static-71-168-218-4.cmdnnj.fios.verizon.net [71.168.218.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jkim/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 5AF341EF2E; Wed, 27 Jun 2018 17:10:54 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Subject: Re: TSC calibration in virtual machines To: Ryan Stone , Alan Somers Cc: Andriy Gapon , FreeBSD Current References: <8ac353c5-d188-f432-aab1-86f4ca5fd295@FreeBSD.org> <4d7957f6-9497-19ff-4dbb-436bb6b05a56@FreeBSD.org> From: Jung-uk Kim Openpgp: preference=signencrypt Autocrypt: addr=jkim@FreeBSD.org; prefer-encrypt=mutual; keydata= xsBNBFJBztUBCAChqNyGqmFuNo0U7MBzsD+q/G6Cv0l7LGVrOAsgh34M8wIWhD+tztDWMVfn AhxNDd0ceCj2bYOe67sTQxAScEcbt2FfvPOLp9MEXb9qohZj172Gwkk7dnhOhZZKhVGVZKM4 NcsuBDUzgf4f3Vdzj4wg6WlqplnTZo8lPE4hZWvZHoFIyunPTJWenybeV1xnxK7JkUdSvQR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ncvq14fEOxCNq1Rf4Q 9P+tOFa8GZfKDGB2BFGIrW7uT5mlmKdK1vO6ZIA930y5kUsnCmBUEBJkE2ciSQk01aB/1o62 Q3Gk/F6BwtNY9OXiqF7AcAo+K/BMIaqb26QKeh+IIgK1NN9dQiq3ByTbl4zpGZa6MmsnnRTu mzGKt2nkz7vBzH6+hZp1OzGZikgjjhYWVFoJo1dvf/rv4obs0ZJEqFPQs/1Qa1dbkKBv6odB XJpPH0ssOluTY24d1XxTiKTwmWvHeQkOKRAIfD7VTtF4TesoZYkf7hsh3e3VwXhptSLFnEOi WwYofg== Message-ID: <5a63153e-4001-e4f4-ea64-9692568c934e@FreeBSD.org> Date: Wed, 27 Jun 2018 13:10:49 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ViomFQoC01Vis9GyYUNfpUlzeJx5460mE" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jun 2018 17:10:55 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ViomFQoC01Vis9GyYUNfpUlzeJx5460mE Content-Type: multipart/mixed; boundary="PFVwc0NxXOerKKgOwN8RWYpGWyIHkuqWf"; protected-headers="v1" From: Jung-uk Kim To: Ryan Stone , Alan Somers Cc: Andriy Gapon , FreeBSD Current Message-ID: <5a63153e-4001-e4f4-ea64-9692568c934e@FreeBSD.org> Subject: Re: TSC calibration in virtual machines References: <8ac353c5-d188-f432-aab1-86f4ca5fd295@FreeBSD.org> <4d7957f6-9497-19ff-4dbb-436bb6b05a56@FreeBSD.org> In-Reply-To: --PFVwc0NxXOerKKgOwN8RWYpGWyIHkuqWf Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 06/27/2018 13:01, Ryan Stone wrote: > I would guess that the calibration can fail because when running under > the hypervisor, the FreeBSD guest code can be descheduled at the wrong > time. As I recall, the current algorithm looks like: >=20 > 1. Sample rdtsc > 2. Use a fixed-frequency timer to busy-wait for exactly 1 second > 3. Sample rdtsc again > 4. tsc_freq =3D sample2 - sample1; >=20 > If we are descheduled between 2 and 3, the time we spend off-cpu will > not be accounted for at step 4. On bare-metal this is not possible as > neither the scheduler nor interrupts are not running yet. >=20 > Although, come to think of it, I seem to recall something about SMI > interrupts mucking this up long in the past, for exactly the same > reason. I think it was legacy USB device emulation for certain Intel chipset-based motherboards. Jung-uk Kim --PFVwc0NxXOerKKgOwN8RWYpGWyIHkuqWf-- --ViomFQoC01Vis9GyYUNfpUlzeJx5460mE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEl1bqgKaRyqfWXu/CfJ+WJvzb8UYFAlszxRkACgkQfJ+WJvzb 8UZB7gf/Q1735anz4BXShSAwnHoSY/P/40ts9m1G+I53QyjSoiunWJpPo6Rnb35v z1ePaSwSy9ecuVIqyxwJxHNxE5Y9VSWzqmD5v+g5cbF0sLKSylEObOz/sbQyftpi 297VaMBHnt2P52CFI5oc7dq46uzR8Cl0jNV/m9TiUr1PeJeTAQ0g4X5RRO/pnLJT R1S6N8xEpDflPYMqt4c7ynCQY8JNmbUYscAikMaagaC+8GyhoG9DAKlfwCOr9Jxz quyHcoJ3KcevQqWUj3sE6CHrLrQMwJuOcs+/QwEXANp13f19gOwWAIpfb+43sEXC KIN0EPNd61ZeTIJXQ4U8fzDU6kZBQQ== =EAlI -----END PGP SIGNATURE----- --ViomFQoC01Vis9GyYUNfpUlzeJx5460mE--