Re: [PATCH] KVM: x86: Use fast path for Xen timer delivery

From: David Woodhouse
Date: Wed Sep 27 2023 - 02:42:54 EST


On Fri, 2023-09-22 at 10:20 +0100, David Woodhouse wrote:
> From: David Woodhouse <dwmw@xxxxxxxxxxxx>
>
> Most of the time there's no need to kick the vCPU and deliver the timer
> event through kvm_xen_inject_timer_irqs(). Use kvm_xen_set_evtchn_fast()
> directly from the timer callback, and only fall back to the slow path
> when it's necessary to do so.
>
> This gives a significant improvement in timer latency testing (using
> nanosleep() for various periods and then measuring the actual time
> elapsed).
>
> Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>

Hm, scratch that. It brings back the race condition Paolo talks about in
https://lore.kernel.org/kvm/0709ac62f664c0f3123fcdeabed3b79038cef3b6.camel@xxxxxxxxxxxxx/T/

Well, not *quite*... there's no race with clearing timer_expires
because I forgot to clear it at all :)

I think I'll be able to fix it up with an hrtimer_cancel() in the rare
ioctl attr_get path to avoid the race.

Attachment: smime.p7s
Description: S/MIME cryptographic signature