Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KVM: KVM_GET_TSC_KHZ fails #1276

Open
shrik3 opened this issue May 22, 2024 · 2 comments
Open

KVM: KVM_GET_TSC_KHZ fails #1276

shrik3 opened this issue May 22, 2024 · 2 comments
Assignees

Comments

@shrik3
Copy link
Collaborator

shrik3 commented May 22, 2024

I don't know if it's only me but strace on quark (x86) repeatedly shows:

[pid 490389] ioctl(19, KVM_GET_TSC_KHZ, 0) = 2591999
[pid 490389] read(12, 0x7752b2fe71c8, 8) = -1 EAGAIN (Resource temporarily unavailable)

the vcpu constantly polls KVM_GET_TSC_KHZ, which always fails.

4.56 KVM_GET_TSC_KHZ
Capability: KVM_CAP_GET_TSC_KHZ
Architectures: x86
Type: vcpu ioctl
Parameters: none
Returns: virtual tsc-khz on success, negative value on error
Returns the tsc frequency of the guest. The unit of the return value is
KHz. If the host has unstable tsc this ioctl returns -EIO instead as an
error.

Perhaps we turn off this kvm capability, if we don't use it.

@shrik3
Copy link
Collaborator Author

shrik3 commented May 22, 2024

image

@QuarkContainer QuarkContainer self-assigned this May 23, 2024
@shrik3
Copy link
Collaborator Author

shrik3 commented May 23, 2024

CC. @QuarkContainer

The time stamp counter in newer processors may support an enhancement, referred to as invariant TSC. Processor’s support for invariant TSC is indicated by CPUID.80000007H:EDX[8]. The invariant TSC will run at a constant rate in all ACPI P-, C-. and T-states. This is the architectural behavior moving forward. On processors with invariant TSC support, the OS may use the TSC for wall clock timer services (instead of ACPI or HPET timers). TSC reads are much more efficient and do not incur the overhead associated with a ring transition or access to a platform resource.

In newer (x86) processors the TSC increments at a constant rate, in which case perhaps there is not need to calibrate the system clock per CPU frequency if using the rdtsc instruction.

reference: Intel SDM section 17.17.1 Invariant TSC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants