Hi, I re-open this issue because, configuring tsc clock in a
debian guest, I still see time not working properly.

I'm installed the debian VM on a different hardware.

In dmesg of OpenBSD guest I see:

# dmesg | grep -i clock
cpu0: apic clock running at 1000MHz
pvclock0 at pvbus0

# dmesg | grep -i time
acpitimer0 at acpi0: 3579545 Hz, 24 bits


On the debian host I see:
# dmesg | grep -i clock
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-6.1.0-25-amd64
root=UUID=6bc49085-38f1-42ca-b35c-a1380d901771 ro gfxpayload=text
console=ttyS0,115200n8 quiet clocksource=tsc tsc=reliable
[    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles:
0xffffffff, max_idle_ns: 7645519600211568 ns
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-6.1.0-25-amd64
root=UUID=6bc49085-38f1-42ca-b35c-a1380d901771 ro gfxpayload=text
console=ttyS0,115200n8 quiet clocksource=tsc tsc=reliable
[    0.000001] clocksource: tsc-early: mask: 0xffffffffffffffff max_cycles:
0xa8712ffee66, max_idle_ns: 440795817477 ns
[    0.004002] clocksource: jiffies: mask: 0xffffffff max_cycles:
0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.008002] PTP clock support registered
[    0.012087] clocksource: Switched to clocksource tsc-early
[    0.448433] rtc_cmos rtc_cmos: setting system clock to
2024-10-02T10:09:31 UTC (1727863771)
[    0.453391] sched_clock: Marking stable (465310107,
-11997886)->(453268078, 44143)
[    0.473602] clk: Disabling unused clocks
[    1.047190] clocksource: tsc: mask: 0xffffffffffffffff max_cycles:
0xa8712ffee66, max_idle_ns: 440795817477 ns
[    1.047194] clocksource: Switched to clocksource tsc

# dmesg | grep -i time
[    0.000002] Calibrating delay loop (skipped), value calculated using
timer frequency.. 23371.32 BogoMIPS (lpj=46742656)
[    0.051444] workingset: timestamp_bits=36 max_order=16 bucket_order=0
[    0.791451] systemd-journald[186]: Received client request to flush
runtime journal.


Il giorno sab 21 ott 2023 alle ore 17:46 Luca Di Gregorio <[email protected]>
ha scritto:

> On debian guest:
> # cat /sys/devices/system/clocksource/clocksource0/current_clocksource
> refined-jiffies
> # cat /sys/devices/system/clocksource/clocksource0/available_clocksource
> refined-jiffies jiffies
>
> In */etc/default/grub *I appended clocksource=tsc tsc=reliable in the
> variable GRUB_CMDLINE_LINUX_DEFAULT
> Before:
>    GRUB_CMDLINE_LINUX_DEFAULT="quiet"
> After:
>    GRUB_CMDLINE_LINUX_DEFAULT="quiet clocksource=tsc tsc=reliable"
>
> Update GRUB:
> #sudo update-grub
>
> After rebooting:
> # cat /sys/devices/system/clocksource/clocksource0/current_clocksource
> tsc
> # cat /sys/devices/system/clocksource/clocksource0/available_clocksource
> tsc
>
> Now sleep on guest debian works as expected.
>
> Thanks a lot!!!
>
>
>
> Il giorno sab 21 ott 2023 alle ore 16:54 Brian Conway <
> [email protected]> ha scritto:
>
>> On Sat, Oct 21, 2023, at 2:36 AM, Luca Di Gregorio wrote:
>> > Host:
>> > # uname -a
>> > OpenBSD xxx.my.domain 7.4 GENERIC.MP#1397 amd64
>> > # dmesg | egrep '(VMX/EPT|SVM/RVI)'
>> > vmm0 at mainbus0: VMX/EPT
>> > # vmctl show
>> >    ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER    STATE NAME
>> >     2 17798     1    1.0G    519M   ttyp4         root  running debian
>> >     1 89226     1    1.0G   1006M   ttyp2         root  running obsd
>> >
>> > Guest debian:
>> > root@debian:~# lsb_release -a
>> > No LSB modules are available.
>> > Distributor ID: Debian
>> > Description:    Debian GNU/Linux 12 (bookworm)
>> > Release:        12
>> > Codename:       bookworm
>> >
>> > I see a strange behavior on the guest debian.
>> > With a simple 'sleep 2', I see that the sleep time is much more than 2
>> secs.
>> > Can be observed with:
>> > root@debian:~# while [ 1 ]; do sleep 2; date; done
>> >
>> > On obsd guest, that is OpenBSD 7.4, sleep works as expected.
>> >
>> > Is this a bug of vmd?
>>
>> Clock sources can be an issue across host-VM combinations. I'd check what
>> yours look like in the Linux VM:
>>
>> `cat /sys/devices/system/clocksource/clocksource0/available_clocksource`
>>
>> `cat /sys/devices/system/clocksource/clocksource0/current_clocksource`
>>
>> If that is the cause, there are a few ways to skin that cat. The approach
>> that has worked well for me, and doesn't require installing any additional
>> software on the guest side, is to append the following to the kernel boot
>> parameters for the Linux VM:
>>
>> clocksource=tsc tsc=reliable
>>
>> In Alpine this is done with /etc/update-extlinux.conf and
>> `update-extlinux`. I don't remember the details of Debian and its GRUB
>> configuration, but I recall it being fairly straightforward.
>>
>> Brian Conway
>> RCE Software, LLC
>>
>>

Reply via email to