All of lore.kernel.org
 help / color / mirror / Atom feed
* What does KVM_HINTS_REALTIME do?
@ 2021-08-03 14:11 Stefan Hajnoczi
  2021-08-03 16:47 ` Marcelo Tosatti
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2021-08-03 14:11 UTC (permalink / raw)
  To: kvm
  Cc: Jenifer Abrams, atheurer, jmario, Paolo Bonzini,
	Michael S. Tsirkin, Wanpeng Li, Eduardo Habkost, Maxim Levitsky,
	Marcelo Tosatti

[-- 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 --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: What does KVM_HINTS_REALTIME do?
  2021-08-03 14:11 What does KVM_HINTS_REALTIME do? Stefan Hajnoczi
@ 2021-08-03 16:47 ` Marcelo Tosatti
  2021-08-04  0:38 ` Wanpeng Li
  2021-08-04  9:01 ` Pankaj Gupta
  2 siblings, 0 replies; 7+ messages in thread
From: Marcelo Tosatti @ 2021-08-03 16:47 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: kvm, Jenifer Abrams, atheurer, jmario, Paolo Bonzini,
	Michael S. Tsirkin, Wanpeng Li, Eduardo Habkost, Maxim Levitsky

On Tue, Aug 03, 2021 at 03:11:04PM +0100, Stefan Hajnoczi wrote:
> 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

Looks good.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: What does KVM_HINTS_REALTIME do?
  2021-08-03 14:11 What does KVM_HINTS_REALTIME do? Stefan Hajnoczi
  2021-08-03 16:47 ` Marcelo Tosatti
@ 2021-08-04  0:38 ` Wanpeng Li
  2021-08-04  9:01 ` Pankaj Gupta
  2 siblings, 0 replies; 7+ messages in thread
From: Wanpeng Li @ 2021-08-04  0:38 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: kvm, Jenifer Abrams, atheurer, jmario, Paolo Bonzini,
	Michael S. Tsirkin, Wanpeng Li, Eduardo Habkost, Maxim Levitsky,
	Marcelo Tosatti

On Tue, 3 Aug 2021 at 22:14, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> 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.

Looks good to me, too. :)

    Wanpeng

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: What does KVM_HINTS_REALTIME do?
  2021-08-03 14:11 What does KVM_HINTS_REALTIME do? Stefan Hajnoczi
  2021-08-03 16:47 ` Marcelo Tosatti
  2021-08-04  0:38 ` Wanpeng Li
@ 2021-08-04  9:01 ` Pankaj Gupta
  2021-08-04  9:06   ` Pankaj Gupta
  2 siblings, 1 reply; 7+ messages in thread
From: Pankaj Gupta @ 2021-08-04  9:01 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: kvm, Jenifer Abrams, atheurer, jmario, Paolo Bonzini,
	Michael S. Tsirkin, Wanpeng Li, Eduardo Habkost, Maxim Levitsky,
	Marcelo Tosatti

> 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 (akaalso  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.

Do we need to mention "halt_poll_ns" at host side also will also be disabled?

>
> 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.

This looks good. Thank you.

Thanks,
Pankaj

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: What does KVM_HINTS_REALTIME do?
  2021-08-04  9:01 ` Pankaj Gupta
@ 2021-08-04  9:06   ` Pankaj Gupta
  2021-08-04  9:54     ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: Pankaj Gupta @ 2021-08-04  9:06 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: kvm, Jenifer Abrams, atheurer, jmario, Paolo Bonzini,
	Michael S. Tsirkin, Wanpeng Li, Eduardo Habkost, Maxim Levitsky,
	Marcelo Tosatti

> > 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 (akaalso  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.
>
> Do we need to mention "halt_poll_ns" at host side also will also be disabled?
with KVM_FEATURE_POLL_CONTROL

Sorry, pressed enter quickly in previous email.
>
> >
> > 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.
>
> This looks good. Thank you.
>
> Thanks,
> Pankaj

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: What does KVM_HINTS_REALTIME do?
  2021-08-04  9:06   ` Pankaj Gupta
@ 2021-08-04  9:54     ` Paolo Bonzini
  2021-08-04 10:23       ` Pankaj Gupta
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2021-08-04  9:54 UTC (permalink / raw)
  To: Pankaj Gupta, Stefan Hajnoczi
  Cc: kvm, Jenifer Abrams, atheurer, jmario, Michael S. Tsirkin,
	Wanpeng Li, Eduardo Habkost, Maxim Levitsky, Marcelo Tosatti

On 04/08/21 11:06, Pankaj Gupta wrote:
>> Do we need to mention "halt_poll_ns" at host side also will also be disabled?
> with KVM_FEATURE_POLL_CONTROL
> 
> Sorry, pressed enter quickly in previous email.

That is done by the cpuidle-haltpoll driver, not just by the presence of 
the feature.

Paolo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: What does KVM_HINTS_REALTIME do?
  2021-08-04  9:54     ` Paolo Bonzini
@ 2021-08-04 10:23       ` Pankaj Gupta
  0 siblings, 0 replies; 7+ messages in thread
From: Pankaj Gupta @ 2021-08-04 10:23 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Stefan Hajnoczi, kvm, Jenifer Abrams, atheurer, jmario,
	Michael S. Tsirkin, Wanpeng Li, Eduardo Habkost, Maxim Levitsky,
	Marcelo Tosatti

> >> Do we need to mention "halt_poll_ns" at host side also will also be disabled?
> > with KVM_FEATURE_POLL_CONTROL
> >
> > Sorry, pressed enter quickly in previous email.
>
> That is done by the cpuidle-haltpoll driver, not just by the presence of
> the feature.

Okay.

Thanks,
Pankaj

>
> Paolo
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-04 10:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 14:11 What does KVM_HINTS_REALTIME do? Stefan Hajnoczi
2021-08-03 16:47 ` 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

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.