All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: kvm@vger.kernel.org
Cc: Jenifer Abrams <jhopper@redhat.com>,
	atheurer@redhat.com, jmario@redhat.com,
	Paolo Bonzini <pbonzini@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Maxim Levitsky <mlevitsk@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: What does KVM_HINTS_REALTIME do?
Date: Tue, 3 Aug 2021 15:11:04 +0100	[thread overview]
Message-ID: <YQlOeGxhor3wJM6i@stefanha-x1.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 1866 bytes --]

Hi,
I was just in a discussion where we realized KVM_HINTS_REALTIME is a
little underdocumented. Here is attempt to address that. Please correct
me if there are inaccuracies or reply if you have additional questions:

KVM_HINTS_REALTIME (aka QEMU kvm-hint-dedicated) is defined as follows
in Documentation/virt/kvm/cpuid.rst:

  guest checks this feature bit to determine that vCPUs are never
  preempted for an unlimited time allowing optimizations

Users or management tools set this flag themselves (it is not set
automatically). This raises the question of what effects this flag has
and when it should be set.

When should I set KVM_HINTS_REALTIME?
-------------------------------------
When vCPUs are pinned to dedicated pCPUs. Even better if the isolcpus=
kernel parameter is used on the host so there are no disturbances.

Is the flag guest-wide or per-vCPU?
-----------------------------------
This flag is guest-wide so all vCPUs should be dedicated, not just some
of them.

Which Linux guest features are affected?
----------------------------------------
PV spinlocks, PV TLB flush, and PV sched yield are disabled by
KVM_HINTS_REALTIME. This is because no other vCPUs or host tasks will be
running on the pCPUs, so there is no benefit in involving the host.

The cpuidle-haltpoll driver is enabled by KVM_HINTS_REALTIME. This
driver performs busy waiting inside the guest before halting the CPU in
order to avoid the vCPU's wakeup latency. This driver also has a boolean
"force" module parameter if you wish to enable it without setting
KVM_HINTS_REALTIME.

When KVM_HINTS_REALTIME is set, the KVM_CAP_X86_DISABLE_EXITS capability
can also be used to disable MWAIT/HLT/PAUSE/CSTATE exits. This improves
the latency of these operations. The user or management tools need to
disable these exits themselves, e.g. with QEMU's -overcommit cpu-pm=on.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2021-08-03 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 14:11 Stefan Hajnoczi [this message]
2021-08-03 16:47 ` What does KVM_HINTS_REALTIME do? Marcelo Tosatti
2021-08-04  0:38 ` Wanpeng Li
2021-08-04  9:01 ` Pankaj Gupta
2021-08-04  9:06   ` Pankaj Gupta
2021-08-04  9:54     ` Paolo Bonzini
2021-08-04 10:23       ` Pankaj Gupta

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=YQlOeGxhor3wJM6i@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=atheurer@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jhopper@redhat.com \
    --cc=jmario@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=wanpengli@tencent.com \
    /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.