On 2019 Nov 17 (Sun) at 17:14:22 -0800 (-0800), Mike Larkin wrote: :On Sat, Nov 16, 2019 at 11:20:48PM -0800, Pratik Vyas wrote: :> * George Koehler <[email protected]> [2019-11-16 18:59:08 -0500]: :> :> > I adapted some code from OpenBSD pvclock(4) into a Linux :> > kernel module, and used it to fix the clock in a Void Linux virtual :> > guest (which had been using the broken i8254 pit). In the Linux :> > module, I set "shift = 12", ignoring the shift = -20 from vmm(4). :> > This seems to fix the tsc-to-nanosecond conversion, so the Void guest :> > is now my only virtual machine with a precise clock. :> > :> :> :> Hi George, :> :> I concur with your math and indeed the diff below fixes it for me. :> :> ok? :> :> -- :> Pratik :> :> Index: sys/arch/amd64/amd64/vmm.c :> =================================================================== :> RCS file: /cvs/src/sys/arch/amd64/amd64/vmm.c,v :> retrieving revision 1.254 :> diff -u -p -a -u -r1.254 vmm.c :> --- sys/arch/amd64/amd64/vmm.c 22 Sep 2019 08:47:54 -0000 1.254 :> +++ sys/arch/amd64/amd64/vmm.c 17 Nov 2019 07:11:04 -0000 :> @@ -6906,7 +6906,7 @@ vmm_update_pvclock(struct vcpu *vcpu) :> nanotime(&tv); :> pvclock_ti->ti_system_time = :> tv.tv_sec * 1000000000L + tv.tv_nsec; :> - pvclock_ti->ti_tsc_shift = -20; :> + pvclock_ti->ti_tsc_shift = 12; :> pvclock_ti->ti_tsc_to_system_mul = :> vcpu->vc_pvclock_system_tsc_mul; :> pvclock_ti->ti_flags = PVCLOCK_FLAG_TSC_STABLE; :> : :Reads ok to me.. :
this seems to fix the "sleep 1" problem for me on two machines, one intel cpu and one amd cpu. OK -- When you're not looking at it, this fortune is written in FORTRAN.
