Re: [PATCH 2/2] x86/idle: use dynamic halt poll

From: Paolo Bonzini
Date: Thu Jun 22 2017 - 07:52:17 EST

On 22/06/2017 13:22, root wrote:
> ==============================================================
> +poll_grow: (X86 only)
> +
> +This parameter is multiplied in the grow_poll_ns() to increase the poll time.
> +By default, the values is 2.
> +
> +==============================================================
> +poll_shrink: (X86 only)
> +
> +This parameter is divided in the shrink_poll_ns() to reduce the poll time.
> +By default, the values is 2.

Even before starting the debate on whether this is a good idea or a bad
idea, KVM reduces the polling value to the minimum (10 us) by default
when polling fails. Also, it shouldn't be bound to
CONFIG_HYPERVISOR_GUEST, since there's nothing specific to virtual
machines here.

Regarding the good/bad idea part, KVM's polling is made much more
acceptable by single_task_running(). At least you need to integrate it
with paravirtualization. If the VM is scheduled out, you shrink the
polling period. There is already vcpu_is_preempted for this, it is used
by mutexes.