Re: Timer delays in VM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[Please don't send HTML email and stick to plain text]

On 2022-02-28 18:02, Eugene Huang wrote:
Hi,

I am running qemu on an arm64 CentOS host. Inside a ubuntu VM, a

I assume that by this you mean QEMU as the VMM for a KVM guest, right?

process runs a timer created using timer_t:

ev.sigev_notify_function = m_callback;

…

timer_create(CLOCK_MONOTONIC, &ev, &m_timer_t);

This timer sometimes has significant delays. For example, the 50 ms
timer can have a callback delay of 100ms.

I did a host kernel trace and see a lot of WFx kvm_exits, and  the
following events between kvm_exit and kvm_entry:

kvm_exit

kvm_wfx_arm64

kvm_get_timer_map

sched_switch

kvm_timer_save_state

kvm_timer_update_irq

vgic_update_irq_pending

kvm_timer_restore_state

kvm_vcpu_wakeup

kvm_arm_setup_debug

kvm_arm_set_dreg32

kvm_entry

All of this is perfectly normal (guest hits WFI from its idle
loop, no interrupt is pending, trap to EL2, schedule out,
schedule back in, reenter the guest).


I have the following questions:

 	* Why there are a lot WFx exits? Is the timer dependent on it?

That's most probably because your vcpu goes idle and execute WFI to
Wait For an Interrupt. As no interrupt is pending, the vcpu exits
so that the host can do something useful until it gets an interrupt
that is targeted at the vcpu. On an idle VM, this probably happens
100s of times a second.

	* Does this timer rely on kvm timer irq injection?

Yes. A timer interrupt is always injected in SW. But the timer
interrupt can either come from the HW timer itself (the VM
was running while the timer expired), or from a SW timer that
KVM as setup if the guest was blocked on WFI.

	* What can be any possible causes for the timer delay? Are there some
locking mechanisms which can cause the delay?

This completely depend on how loaded your host is, the respective
priorities of the various processes, and a million of other things.
This is no different from the same userspace running on the host.
It also depends on the *guest* kernel, by the way.

There are of course locks all over the place, but that's the very
nature of the beast.

	* What parameters can tune this timer?

None. You may want to check whether the delay is observed when the
VM has hit WFI or not.

You also don't mention what host kernel version you are running.
In general, please try and reproduce the issue using the latest
kernel version (5.16 at the moment). Please also indicate what
HW you are using.

Thanks,

        M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm




[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux