NetBSD Problem Report #53648

From nia@netbsd.org  Wed Oct  3 17:51:03 2018
Return-Path: <nia@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 6874F7A180
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  3 Oct 2018 17:51:03 +0000 (UTC)
Message-Id: <20181003175103.281F184D8B@mail.netbsd.org>
Date: Wed,  3 Oct 2018 17:51:03 +0000 (UTC)
From: nia@netbsd.org
Reply-To: nia@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: Serious clock drift when running inside KVM
X-Send-Pr-Version: 3.95

>Number:         53648
>Category:       port-amd64
>Synopsis:       Serious clock drift when running inside KVM
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 03 17:55:01 +0000 2018
>Last-Modified:  Mon Feb 25 18:50:31 +0000 2019
>Originator:     nia
>Release:        NetBSD 8.99.25
>Organization:
>Environment:
System: NetBSD 8.99.25 (GENERIC) #0: Sat Sep 22 05:24:22 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

With ntpd running:

$ ntpdate -q 0.netbsd.pool.ntp.org
server 193.150.34.2, stratum 2, offset 891.005872, delay 0.03432
server 178.79.152.182, stratum 2, offset 891.000869, delay 0.03198
server 80.87.128.17, stratum 3, offset 891.001166, delay 0.03790
server 194.80.204.184, stratum 1, offset 891.001526, delay 0.04477
 3 Oct 15:11:20 ntpdate[18592]: step time server 194.80.204.184 offset 891.001526 sec

This seems to happen with any timecounter source. Currently, I've got it
set to ACPI-Safe, as advised in this thread:

https://mail-index.netbsd.org/netbsd-users/2018/03/04/msg020504.html

$ sysctl kern.timecounter.
kern.timecounter.choice = TSC(q=-100, f=2394744680 Hz) clockinterrupt(q=0, f=100 Hz) piixpm0(q=1000, f=3579545 Hz) hpet0(q=2000, f=100000000 Hz) ACPI-Safe(q=900, f=3579545 Hz) lapic(q=-100, f=1001659389 Hz) i8254(q=100, f=1193182 Hz) dummy(q=-1000000, f=1000000 Hz)
kern.timecounter.hardware = ACPI-Safe
kern.timecounter.timestepwarnings = 0

The default was hpet0, which clearly didn't work. Lots of
"WARNING: negative runtime; monotonic clock has gone backwards".

Similar issue: https://gnats.netbsd.org/45626 - I don't have noatime on
/var, only log.

>How-To-Repeat:
Set up a Vultr VM. Install NetBSD-current. Use an encrypted /home and start NTP on boot.

Wait for clock drift after a day or so.
>Fix:
Reboot.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-amd64-maintainer->maya
Responsible-Changed-By: maya@NetBSD.org
Responsible-Changed-When: Fri, 05 Oct 2018 21:37:37 +0000
Responsible-Changed-Why:
Take. I'm going to try to write a kvm-clock driver, which is what linux has for this problem.


From: maya@netbsd.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-amd64/53648 (Serious clock drift when running inside KVM)
Date: Sat, 6 Oct 2018 05:12:12 +0000

 This is the same as the xen clock (called 'pvclock').

Responsible-Changed-From-To: maya->port-amd64-maintainer
Responsible-Changed-By: maya@NetBSD.org
Responsible-Changed-When: Mon, 25 Feb 2019 18:50:31 +0000
Responsible-Changed-Why:


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.