Page MenuHomeFreeBSD

paravirt: Add KVM clock timecounter support
AbandonedPublic

Authored by jhb on Jul 17 2018, 7:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 22, 7:45 PM
Unknown Object (File)
Sat, Dec 21, 4:11 PM
Unknown Object (File)
Sat, Dec 14, 3:20 PM
Unknown Object (File)
Fri, Dec 13, 7:46 PM
Unknown Object (File)
Thu, Dec 12, 9:06 AM
Unknown Object (File)
Sun, Dec 8, 1:42 PM
Unknown Object (File)
Wed, Nov 27, 10:30 AM
Unknown Object (File)
Nov 26 2024, 1:45 PM

Details

Reviewers
mmacy
stevek
Summary

This allows a KVM guest to get an accurate cycle counter without having to do a VM exit, which happens when either HPET or ACPI is used.

KVMCLOCK quality is set to 2000 to ensure it is preferred, when it is available. Otherwise, if it was set to 1000, both TSC and KVMCLOCK could be detected and TSC will most likely get selected over KVMCLOCK, based on probe order.

KVM clock also supports getting the wall clock time but that is not implemented yet.

This change is dependent on D16305 being committed first.

Test Plan

Booted on qemu/KVM setup running Junos with these changes.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 20300
Build 19760: arc lint + arc unit

Event Timeline

sys/x86/x86/kvm_clock.c
65

I don't think we need to do this right now, but we may later want to use this in probe_tsc_freq(), similar to what's done for VMware.

Removed kvm_clock_tsc_freq, per comments, as it is currently not needed.

any update on this?

i have manually patched my FreeBSD 11.2 environment with this patch and the corresponding D16305 patch and the clock on my virtual FreeBSD guests seems to be more correct now.
although i have to mention that i see messages like this from time to time:

Feb 15 11:47:47 kern kernel: calcru: runtime went backwards from 2567676 usec to 2513475 usec for pid 1 (init)
Feb 15 11:47:47 kern kernel: calcru: runtime went backwards from 1658497 usec to 1623487 usec for pid 0 (kernel)

it is a bit unclear to me yet if one is still supposed to use ntp client when using KVMCLOCK or not?

any update on this?

I have some folks in work scheduled to do some stress testing with the patch, but it has not occurred yet.

I don't know yet if anyone else has tested it.

i have manually patched my FreeBSD 11.2 environment with this patch and the corresponding D16305 patch and the clock on my virtual FreeBSD guests seems to be more correct now.
although i have to mention that i see messages like this from time to time:

Feb 15 11:47:47 kern kernel: calcru: runtime went backwards from 2567676 usec to 2513475 usec for pid 1 (init)
Feb 15 11:47:47 kern kernel: calcru: runtime went backwards from 1658497 usec to 1623487 usec for pid 0 (kernel)

Interesting.

it is a bit unclear to me yet if one is still supposed to use ntp client when using KVMCLOCK or not?

I think one is not supposed to be, since the host clock should be the source of truth when using KVMCLOCK. Bryan might have some input on this, since the driver implementation is originally his.

jhb abandoned this revision.
jhb edited reviewers, added: stevek; removed: jhb.

Superseded by D29531 and D29733.