[2/2] KVM: s390: provide kvm_arch_no_poll function
diff mbox series

Message ID 20190305103002.5801-3-borntraeger@de.ibm.com
State New
Headers show
Series
  • disabling halt polling for nested virtualization
Related show

Commit Message

Christian Borntraeger March 5, 2019, 10:30 a.m. UTC
We do track the current steal time of the host CPUs. Let us use
this value to disable halt polling if the steal time goes beyond
a predefined value. (12.5% for now).

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/kvm_host.h | 6 ++++++
 arch/s390/kvm/Kconfig            | 1 +
 2 files changed, 7 insertions(+)

Comments

Cornelia Huck March 5, 2019, 11:05 a.m. UTC | #1
On Tue,  5 Mar 2019 05:30:02 -0500
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> We do track the current steal time of the host CPUs. Let us use
> this value to disable halt polling if the steal time goes beyond
> a predefined value. (12.5% for now).

Might make sense to make it tweakable. On the other hand, a reasonable
value might be good enough :)

> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  arch/s390/include/asm/kvm_host.h | 6 ++++++
>  arch/s390/kvm/Kconfig            | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
> index a4962761e1dd..f699983a8d09 100644
> --- a/arch/s390/include/asm/kvm_host.h
> +++ b/arch/s390/include/asm/kvm_host.h
> @@ -884,6 +884,12 @@ struct kvm_arch_async_pf {
>  	unsigned long pfault_token;
>  };
>  
> +static inline bool kvm_arch_no_poll(void)
> +{
> +	/* do not poll with more than 12.5% steal */
> +	return S390_lowcore.avg_steal_timer > (TICK_USEC << 12) / 8;

That's an average anyway, correct?

> +}
> +
>  bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu);
>  
>  void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
> diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig
> index 767453faacfc..e987e73738b5 100644
> --- a/arch/s390/kvm/Kconfig
> +++ b/arch/s390/kvm/Kconfig
> @@ -31,6 +31,7 @@ config KVM
>  	select HAVE_KVM_IRQFD
>  	select HAVE_KVM_IRQ_ROUTING
>  	select HAVE_KVM_INVALID_WAKEUPS
> +	select HAVE_KVM_NO_POLL
>  	select SRCU
>  	select KVM_VFIO
>  	---help---
kbuild test robot March 5, 2019, 12:29 p.m. UTC | #2
Hi Christian,

I love your patch! Yet something to improve:

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on v5.0 next-20190305]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christian-Borntraeger/KVM-polling-add-architecture-backend-to-disable-polling/20190305-193431
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: s390-allyesconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=s390 

All errors (new ones prefixed by >>):

   In file included from include/linux/kvm_host.h:38,
                    from arch/s390/kernel/asm-offsets.c:11:
   arch/s390/include/asm/kvm_host.h: In function 'kvm_arch_no_poll':
>> arch/s390/include/asm/kvm_host.h:887:22: error: 'struct lowcore' has no member named 'avg_steal_timer'; did you mean 'steal_timer'?
     return S390_lowcore.avg_steal_timer > (TICK_USEC << 12) / 8;
                         ^~~~~~~~~~~~~~~
                         steal_timer
   make[2]: *** [arch/s390/kernel/asm-offsets.s] Error 1
   make[2]: Target '__build' not remade because of errors.
   make[1]: *** [prepare0] Error 2
   make[1]: Target 'prepare' not remade because of errors.
   make: *** [sub-make] Error 2

vim +887 arch/s390/include/asm/kvm_host.h

   883	
   884	static inline bool kvm_arch_no_poll(void)
   885	{
   886		/* do not poll with more than 12.5% steal */
 > 887		return S390_lowcore.avg_steal_timer > (TICK_USEC << 12) / 8;
   888	}
   889	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Patch
diff mbox series

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index a4962761e1dd..f699983a8d09 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -884,6 +884,12 @@  struct kvm_arch_async_pf {
 	unsigned long pfault_token;
 };
 
+static inline bool kvm_arch_no_poll(void)
+{
+	/* do not poll with more than 12.5% steal */
+	return S390_lowcore.avg_steal_timer > (TICK_USEC << 12) / 8;
+}
+
 bool kvm_arch_can_inject_async_page_present(struct kvm_vcpu *vcpu);
 
 void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu,
diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig
index 767453faacfc..e987e73738b5 100644
--- a/arch/s390/kvm/Kconfig
+++ b/arch/s390/kvm/Kconfig
@@ -31,6 +31,7 @@  config KVM
 	select HAVE_KVM_IRQFD
 	select HAVE_KVM_IRQ_ROUTING
 	select HAVE_KVM_INVALID_WAKEUPS
+	select HAVE_KVM_NO_POLL
 	select SRCU
 	select KVM_VFIO
 	---help---