NetBSD Problem Report #57300
From www@netbsd.org Sun Mar 26 10:17:32 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_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 039F81A9239
for <gnats-bugs@gnats.NetBSD.org>; Sun, 26 Mar 2023 10:17:32 +0000 (UTC)
Message-Id: <20230326101731.1517A1A923C@mollari.NetBSD.org>
Date: Sun, 26 Mar 2023 10:17:31 +0000 (UTC)
From: nan@chinadtrace.org
Reply-To: nan@chinadtrace.org
To: gnats-bugs@NetBSD.org
Subject: Time system is not accurate on NetBSD VM
X-Send-Pr-Version: www-1.0
>Number: 57300
>Category: misc
>Synopsis: Time system is not accurate on NetBSD VM
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: misc-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Mar 26 10:20:00 +0000 2023
>Last-Modified: Mon Mar 27 10:45:01 +0000 2023
>Originator: Nan Xiao
>Release: 9.3
>Organization:
>Environment:
NetBSD localhost 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug 4 15:30:37 UTC 2022 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
Hi NetBSD community,
My NetBSD is a VirtualBox virtual machine, and host machine is macOS Ventura 13.2.1. I find the date command doesn't display time correctly, and it is very advanced than actual time.
E.g.:
-bash-5.1$ date; sleep 10; date
Sun Mar 26 18:59:44 +08 2023
Sun Mar 26 19:00:13 +08 2023
Actually the time just passes 10 seconds, but date command shows it has passes nearly half a minute. Not sure whether this could be accounted as NetBSD bug, or VirtualBox bug, thanks!
Best Regards
Nan Xiao
>How-To-Repeat:
>Fix:
>Audit-Trail:
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: misc/57300: Time system is not accurate on NetBSD VM
Date: Sun, 26 Mar 2023 10:44:17 -0000 (UTC)
nan@chinadtrace.org writes:
>-bash-5.1$ date; sleep 10; date
>Sun Mar 26 18:59:44 +08 2023
>Sun Mar 26 19:00:13 +08 2023
>Actually the time just passes 10 seconds, but date command shows it has passes nearly half a minute. Not sure whether this could be accounted as NetBSD bug, or VirtualBox bug, thanks!
"sleep 10" waits 1000 clock interrupts. If that lasts 10 seconds, the
emulation of clock interrupts is correct. The exact delay can vary
with host speed and load.
"date" looks at the current timecounter. If that advances 30 seconds
in 10 seconds, the emulation of the timecounter is bad. Fortunately we
have multiple, e.g.:
# sysctl kern.timecounter
kern.timecounter.choice = TSC(q=3000, f=3292677360 Hz) clockinterrupt(q=0, f=100 Hz) ichlpcib0(q=1000, f=3579545 Hz) hpet0(q=2000, f=14318180 Hz) ACPI-Fast(q=1000, f=3579545 Hz) lapic(q=-100, f=99859155 Hz) i8254(q=100, f=1193182 Hz) dummy(q=-1000000, f=1000000 Hz)
kern.timecounter.hardware = TSC
kern.timecounter.timestepwarnings = 0
By setting kern.timecounter.hardware to one of the choices you may get
a timecounter that works better.
While the choice "clockinterrupt" avoids discrepancies between "sleep"
and "date", the result might not be accurate. For many cases a different
choice (if there is any) is better.
From: Nan Xiao <nan@chinadtrace.org>
To: gnats-bugs@netbsd.org, misc-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: misc/57300: Time system is not accurate on NetBSD VM
Date: Mon, 27 Mar 2023 17:28:03 +0800
Hi Michael,
Thanks very much for your reply! "clockinterrupt" seems working for my
VM environment.
On 2023/3/26 6:50 PM, Michael van Elst wrote:
> The following reply was made to PR misc/57300; it has been noted by GNATS.
>
> From: mlelstv@serpens.de (Michael van Elst)
> To: gnats-bugs@netbsd.org
> Cc:
> Subject: Re: misc/57300: Time system is not accurate on NetBSD VM
> Date: Sun, 26 Mar 2023 10:44:17 -0000 (UTC)
>
> nan@chinadtrace.org writes:
>
> >-bash-5.1$ date; sleep 10; date
> >Sun Mar 26 18:59:44 +08 2023
> >Sun Mar 26 19:00:13 +08 2023
>
> >Actually the time just passes 10 seconds, but date command shows it has passes nearly half a minute. Not sure whether this could be accounted as NetBSD bug, or VirtualBox bug, thanks!
>
>
> "sleep 10" waits 1000 clock interrupts. If that lasts 10 seconds, the
> emulation of clock interrupts is correct. The exact delay can vary
> with host speed and load.
>
> "date" looks at the current timecounter. If that advances 30 seconds
> in 10 seconds, the emulation of the timecounter is bad. Fortunately we
> have multiple, e.g.:
>
> # sysctl kern.timecounter
> kern.timecounter.choice = TSC(q=3000, f=3292677360 Hz) clockinterrupt(q=0, f=100 Hz) ichlpcib0(q=1000, f=3579545 Hz) hpet0(q=2000, f=14318180 Hz) ACPI-Fast(q=1000, f=3579545 Hz) lapic(q=-100, f=99859155 Hz) i8254(q=100, f=1193182 Hz) dummy(q=-1000000, f=1000000 Hz)
> kern.timecounter.hardware = TSC
> kern.timecounter.timestepwarnings = 0
>
> By setting kern.timecounter.hardware to one of the choices you may get
> a timecounter that works better.
>
> While the choice "clockinterrupt" avoids discrepancies between "sleep"
> and "date", the result might not be accurate. For many cases a different
> choice (if there is any) is better.
>
>
--
Best Regards
Nan Xiao(肖楠)
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.