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)
Thu, Apr 11, 1:46 PM
Unknown Object (File)
Tue, Apr 2, 6:36 AM
Unknown Object (File)
Fri, Mar 29, 6:26 AM
Unknown Object (File)
Mar 11 2024, 1:23 AM
Unknown Object (File)
Jan 29 2024, 10:29 PM
Unknown Object (File)
Jan 29 2024, 10:22 PM
Unknown Object (File)
Jan 29 2024, 10:15 PM
Unknown Object (File)
Jan 20 2024, 3:44 AM

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.