From owner-freebsd-virtualization@freebsd.org Sat Oct 21 22:16:08 2017 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F877E3B651 for ; Sat, 21 Oct 2017 22:16:08 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06F406D69A for ; Sat, 21 Oct 2017 22:16:07 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 695d617b-b6ad-11e7-a893-25625093991c X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 695d617b-b6ad-11e7-a893-25625093991c; Sat, 21 Oct 2017 22:15:58 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id v9LMFrKh014285; Sat, 21 Oct 2017 16:15:53 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1508624153.1383.107.camel@freebsd.org> Subject: Re: host, bhyve vm and ntpd From: Ian Lepore To: Michael Voorhis Cc: Boris Samorodov , freebsd-current@FreeBSD.org, freebsd-virtualization@FreeBSD.org Date: Sat, 21 Oct 2017 16:15:53 -0600 In-Reply-To: <23019.46875.929719.481108@atom.mcvau.net> References: <2931f1cc-6574-b58d-4b94-5f77fa5cdb85@passap.ru> <1508512327.1383.55.camel@freebsd.org> <39bf2426-2edf-d485-7c81-519e931154be@passap.ru> <1508517160.1383.63.camel@freebsd.org> <76ff7afb-3d3a-96f6-1275-89472ff5683d@passap.ru> <1508522667.1383.69.camel@freebsd.org> <30992c14-7b78-ab9f-5693-931e6ca41f1b@passap.ru> <1508523696.1383.75.camel@freebsd.org> <23019.46875.929719.481108@atom.mcvau.net> Content-Type: multipart/mixed; boundary="=-85jbhbwt4hlyeaS0wt1C" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Oct 2017 22:16:08 -0000 --=-85jbhbwt4hlyeaS0wt1C Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit On Sat, 2017-10-21 at 17:07 -0400, Michael Voorhis wrote: > Ian Lepore writes: > > > > Beyond that, I'm not sure what else to try.  It might be necessary to > > get some bhyve developers involved (I know almost nothing about it). > NTPD behaves more normally on uniprocessor VMs. > > A FreeBSD bhyve-guest running on a freebsd host will select a > different timecounter depending on whether it is a multiprocessor or a > uniprocessor.  My uniprocessor bhyve-vm selected TSC-low as the best > timecounter in a uniprocessor.  NTP functions there as expected. > > kern.timecounter.choice: TSC-low(1000) ACPI-fast(900) HPET(950) i8254(0) dummy(-1000000) > kern.timecounter.hardware: TSC-low > > The very same VM, when given two total CPUs, selected HPET (if I > recall) and the timekeeping with NTPD was unreliable, with many > step-resets to the clock. > Hmm, I just had glance at the code in sys/amd64/vmm/io/vhpet.c and it looks right.  I wonder if this is just a simple roundoff error in converting between 10.0MHz and SBT units?  If so, that could be wished away easily by using a power-of-2 frequency for the virtual HPET.  I wonder if the attached patch is all that's needed? -- Ian --=-85jbhbwt4hlyeaS0wt1C Content-Disposition: inline; filename="temp.diff" Content-Type: text/x-patch; name="temp.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit Index: sys/amd64/vmm/io/vhpet.c =================================================================== --- sys/amd64/vmm/io/vhpet.c (revision 324176) +++ sys/amd64/vmm/io/vhpet.c (working copy) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_VHPET, "vhpet", "bhyve virtual hpet"); -#define HPET_FREQ 10000000 /* 10.0 Mhz */ +#define HPET_FREQ 16777216 /* 16.7 (2^24) Mhz */ #define FS_PER_S 1000000000000000ul /* Timer N Configuration and Capabilities Register */ --=-85jbhbwt4hlyeaS0wt1C--