Date: Wed, 27 Jun 2018 13:10:49 -0400 From: Jung-uk Kim <jkim@FreeBSD.org> To: Ryan Stone <rysto32@gmail.com>, Alan Somers <asomers@freebsd.org> Cc: Andriy Gapon <avg@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org> Subject: Re: TSC calibration in virtual machines Message-ID: <5a63153e-4001-e4f4-ea64-9692568c934e@FreeBSD.org> In-Reply-To: <CAFMmRNyFppU94S=QjQGZY4RJau82xtg45csELC5q5Y35R7VwUw@mail.gmail.com> References: <8ac353c5-d188-f432-aab1-86f4ca5fd295@FreeBSD.org> <4d7957f6-9497-19ff-4dbb-436bb6b05a56@FreeBSD.org> <CAOtMX2gcUybMhPdEzBWX07-oPdmJdqn%2BvW7KkNZvs2sFmcHFNw@mail.gmail.com> <CAFMmRNyFppU94S=QjQGZY4RJau82xtg45csELC5q5Y35R7VwUw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <jkim@FreeBSD.org> To: Ryan Stone <rysto32@gmail.com>, Alan Somers <asomers@freebsd.org> Cc: Andriy Gapon <avg@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org> 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> <CAOtMX2gcUybMhPdEzBWX07-oPdmJdqn+vW7KkNZvs2sFmcHFNw@mail.gmail.com> <CAFMmRNyFppU94S=QjQGZY4RJau82xtg45csELC5q5Y35R7VwUw@mail.gmail.com> In-Reply-To: <CAFMmRNyFppU94S=QjQGZY4RJau82xtg45csELC5q5Y35R7VwUw@mail.gmail.com> --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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5a63153e-4001-e4f4-ea64-9692568c934e>