Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Eugene Huang <eugeneh@nvidia.com>
Cc: "kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>
Subject: Re: Timer delays in VM
Date: Wed, 02 Mar 2022 07:28:56 +0000	[thread overview]
Message-ID: <87wnhc6cef.wl-maz@kernel.org> (raw)
In-Reply-To: <BYAPR12MB3192EFEBABB1B31D9751C931D9029@BYAPR12MB3192.namprd12.prod.outlook.com>

On Tue, 01 Mar 2022 19:03:33 +0000,
Eugene Huang <eugeneh@nvidia.com> wrote:
> 
> > >       * 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.
> 
> <EH> Here for arm64, EL1Virtual Timer is used. EL1 Virtual Timer is
> a HW timer, correct?  There is an armvtimer implementation in QEMU
> 6.1+. Does this armvtimer make a difference?

KVM only deals with the EL1 timers (both physical and virtual). I
guess that by 'armvtimer', you mean libvirt's front-end for the stolen
time feature to expose to the guest how wall clock and CPU time
diverge (i.e. it isn't a timer at all, but a dynamic correction for
it).

> > >       * 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.
> 
> <EH> Our guest kernel is 5.4. How is the *guest* kernel involved?
> Can you give an example? Do you have suggestions on the guest kernel
> version as well.

It is the guest kernel that programs the timer, and KVM isn't involved
at all, specially on your HW (direct access to both timers on
VHE-capable systems).

> > >       * 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.
> 
> <EH> Yes, delay is observed after vm_exit because of WFx (not sure
> WFI or WFE) but only when on a different vCPU in the same VM some
> workload is started.

Let me see if I understand what you mean:

- vcpu-0 is running your timer test, everything is fine
- vcpu-1 starts some other workload, and this affects the timer test
  on the other vcpu

Is that correct? It so, this would tend to indicate that both vcpu
share some physical resources such as a physical CPU. How do you run
your VM?

Also, please work out whether you exit because of a blocking WFI or
WFE, as they are indicative of different guest behaviour.

> Since we pin that workload to its own vCPU, in
> theory, it should not affect the timing of another vCPU.

Why not? a vcpu is just a host thread, and if they share a physical
CPU at some point, there is a knock-on effect.

> > 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.
> 
> <EH> Tried 5.15 and 5.4 kernels. Both have the issue. Do you think
> 5.16 can make a difference? The HW is an Ampere Altra system.

Unlikely. The Altra is a mostly sane system, as long as you make sure
that VMs don't migrate across sockets (at which point it becomes
laughably bad). Nothing to do with KVM though.

Are these kernels compiled from scratch? Or are they whatever the
distro ships? Same question for the guest.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  parent reply	other threads:[~2022-03-02  7:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 18:02 Timer delays in VM Eugene Huang
2022-02-28 21:02 ` Marc Zyngier
2022-03-01  9:06   ` Andrew Jones
2022-03-01 19:03   ` Eugene Huang
2022-03-02  2:27     ` Eugene Huang
2022-03-02  7:28     ` Marc Zyngier [this message]
2022-03-03  5:49       ` Eugene Huang
2022-03-03 14:42         ` Marc Zyngier
2022-03-08  7:50           ` Eugene Huang
2022-03-08  9:34             ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnhc6cef.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=eugeneh@nvidia.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox