Re: clock stability, TSC, and QEMU
Ottavio Caruso <[email protected]> Sun, 9 May 2021 08:48:00 +0100
| Newsgroups | gmane.os.netbsd.ports.x86-64 |
|---|---|
| Message-ID | <[email protected]> |
On 09/05/2021 07:23, nia wrote: > hello, > > when running NetBSD as a QEMU guest, there seem to be problems > with clock stability. Interesting. I don't have this problem with NetBSD guest but I had a similar one with an OpenBSD guest (see below). This is my command line (host is Debian Buster): qemu-system-x86_64 \ -drive if=virtio,file=/home/oc/VM/img/netbsd.image,index=0,media=disk \ -drive if=virtio,file=/home/oc/VM/img/netbsd.image.old,index=1,media=disk \ -M q35,accel=kvm -m 250M -cpu host -smp $(nproc) \ -nic user,hostfwd=tcp:127.0.0.1:5555-:22,model=virtio-net-pci,ipv6=off \ -daemonize -display none -vga none \ -serial mon:telnet:127.0.0.1:6665,server,nowait \ -pidfile /home/oc/VM/pid/netbsd-pid -nodefaults > > i remember having this problem when using a commercial KVM-based VM > host. erlang is very sensitive to monotonic clock drift, and > will abort if it detects it. my application would infrequently > abort regardless of kern.timecounter.hardware (although ACPI-Safe > annecdotally made it less worse) due to the monotonic clock > stepping backwards. > > when running NetBSD as a QEMU guest with NVMM, the following > message is printed to dmesg on boot: > > autoconfiguration ERROR: 9225914709 cycle TSC drift observed > > (kern.timecounter.hardware defaults to hpet) $ dmesg|grep drift $ grep drift /var/log/messages $ sysctl kern.timecounter.hardware kern.timecounter.hardware = hpet0 > > QEMU has a -rtc setting, but I'm unsure of best option > to pick for NetBSD: > > -rtc [base=utc|localtime|<datetime>][,clock=host|rt|vm][,driftfix=none|slew] > set the RTC base and clock, enable drift fix for clock ticks (x86 only) > > additionally, on my laptop running -curent, I get spammed > with warnings about TSC drift when waking from suspend: > http://gnats.netbsd.org/55694 > It is defaulting to using TSC as a timecounter - > I wonder if NetBSD should be relying on TSC less. > I had a problem with an OpenBSD guest, where the clock would go mental after a prolonged period of inactivity and would trigger ddb(4) kernel panic. I was suggested to add "-kvmclock-stable-bit" to -"-cpu", so my OpenBSD boot is: qemu-system-x86_64 \ -drive if=virtio,file=/home/oc/VM/img/openbsd.image,index=0,media=disk \ -drive if=virtio,file=/home/oc/VM/img/openbsd.image.old,index=1,media=disk \ -M q35,accel=kvm -m 250M -cpu host,-kvmclock-stable-bit -smp $(nproc) \ -nic user,hostfwd=tcp:127.0.0.1:5556-:22,model=virtio-net-pci \ -daemonize -display none -vga none \ -serial mon:telnet:127.0.0.1:6666,server,nowait \ -pidfile /home/oc/VM/pid/openbsd-pid -nodefaults telnet 127.0.0.1 6666 I don't know how all this fits with NVMM, though. -- Ottavio Caruso