All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Eugene Huang <eugeneh@nvidia.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: Timer delays in VM
Date: Mon, 28 Feb 2022 11:02:24 +0000	[thread overview]
Message-ID: <CAFEAcA9+cof3gHwTEht4j813hoTsSdstHd568BZEd5fm8n+n2w@mail.gmail.com> (raw)
In-Reply-To: <BYAPR12MB3192248D73D9C8AF64076A62D9019@BYAPR12MB3192.namprd12.prod.outlook.com>

.

On Mon, 28 Feb 2022 at 07:04, Eugene Huang <eugeneh@nvidia.com> wrote:
> I am running qemu on an arm64 CentOS host. Inside a ubuntu VM, a 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:

For questions that are really about KVM and not QEMU, you'll probably
find more experts on kvmarm@lists.cs.columbia.edu. My non-expert
look at this series of events:

> kvm_exit
> kvm_wfx_arm64

The guest kernel has nothing to do, so it idles,
waiting for the next interrupt.

> kvm_get_timer_map
> sched_switch
> kvm_timer_save_state

So the host schedules something else instead of this vCPU
(I think).

> kvm_timer_update_irq
> vgic_update_irq_pending

At some later date, the timer IRQ fires...

> kvm_timer_restore_state
> kvm_vcpu_wakeup
> kvm_arm_setup_debug
> kvm_arm_set_dreg32
> kvm_entry

...so we reschedule the vCPU and re-enter the guest.

I don't know why the timer might have significant delays,
but of course if your host system is very heavily loaded we
might not get round to rescheduling the vCPU for a bit.

thanks
-- PMM


  reply	other threads:[~2022-02-28 11:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28  6:22 Timer delays in VM Eugene Huang
2022-02-28 11:02 ` Peter Maydell [this message]
2022-02-28 18:02 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
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=CAFEAcA9+cof3gHwTEht4j813hoTsSdstHd568BZEd5fm8n+n2w@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=eugeneh@nvidia.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.