All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Janosch Frank <frankja@linux.vnet.ibm.com>
Cc: KVM <kvm@vger.kernel.org>, "Cornelia Huck" <cohuck@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH v2 2/2] KVM: s390: provide kvm_arch_no_poll function
Date: Tue, 16 Apr 2019 20:02:39 +0200	[thread overview]
Message-ID: <60692984-7a70-8b10-d51a-28fd019d3a88@de.ibm.com> (raw)
In-Reply-To: <20190416180158.112309-3-borntraeger@de.ibm.com>

FWiw, this patch need 5.1-rc3 or later.

On 16.04.19 20:01, Christian Borntraeger 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 configured value.
> 
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  arch/s390/include/asm/kvm_host.h |  1 +
>  arch/s390/kvm/Kconfig            |  1 +
>  arch/s390/kvm/kvm-s390.c         | 17 +++++++++++++++++
>  3 files changed, 19 insertions(+)
> 
> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
> index e70f6ce14267..dbe254847e0d 100644
> --- a/arch/s390/include/asm/kvm_host.h
> +++ b/arch/s390/include/asm/kvm_host.h
> @@ -313,6 +313,7 @@ struct kvm_vcpu_stat {
>  	u64 halt_successful_poll;
>  	u64 halt_attempted_poll;
>  	u64 halt_poll_invalid;
> +	u64 halt_no_poll_steal;
>  	u64 halt_wakeup;
>  	u64 instruction_lctl;
>  	u64 instruction_lctlg;
> 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---
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index d7423fdf5f68..8d0e2416f905 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -75,6 +75,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = {
>  	{ "halt_successful_poll", VCPU_STAT(halt_successful_poll) },
>  	{ "halt_attempted_poll", VCPU_STAT(halt_attempted_poll) },
>  	{ "halt_poll_invalid", VCPU_STAT(halt_poll_invalid) },
> +	{ "halt_no_poll_steal", VCPU_STAT(halt_no_poll_steal) },
>  	{ "halt_wakeup", VCPU_STAT(halt_wakeup) },
>  	{ "instruction_lctlg", VCPU_STAT(instruction_lctlg) },
>  	{ "instruction_lctl", VCPU_STAT(instruction_lctl) },
> @@ -182,6 +183,11 @@ static int hpage;
>  module_param(hpage, int, 0444);
>  MODULE_PARM_DESC(hpage, "1m huge page backing support");
>  
> +/* maximum percentage of steal time for polling */
> +static u8 halt_poll_max_steal = 10;
> +module_param(halt_poll_max_steal, byte, 0644);
> +MODULE_PARM_DESC(hpage, "Maximum percentage of steal time to allow pollinh");
> +
>  /*
>   * For now we handle at most 16 double words as this is what the s390 base
>   * kernel handles and stores in the prefix page. If we ever need to go beyond
> @@ -3150,6 +3156,17 @@ static void kvm_gmap_notifier(struct gmap *gmap, unsigned long start,
>  	}
>  }
>  
> +bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
> +{
> +	/* do not poll with more than halt_poll_max_steal percent of steal time */
> +	if (S390_lowcore.avg_steal_timer * 100 / (TICK_USEC << 12) >=
> +	    halt_poll_max_steal) {
> +		vcpu->stat.halt_no_poll_steal++;
> +		return true;
> +	}
> +	return false;
> +}
> +
>  int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
>  {
>  	/* kvm common code refers to this, but never calls it */
> 


  reply	other threads:[~2019-04-16 18:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 18:01 [PATCH v2 0/2] disabling halt polling for nested virtualization Christian Borntraeger
2019-04-16 18:01 ` [PATCH v2 1/2] KVM: polling: add architecture backend to disable polling Christian Borntraeger
2019-04-18 14:44   ` Cornelia Huck
2019-04-16 18:01 ` [PATCH v2 2/2] KVM: s390: provide kvm_arch_no_poll function Christian Borntraeger
2019-04-16 18:02   ` Christian Borntraeger [this message]
2019-04-18 14:46   ` Cornelia Huck
2019-04-17 13:20 ` [PATCH v2 0/2] disabling halt polling for nested virtualization Paolo Bonzini
2019-04-17 13:23   ` Christian Borntraeger
2019-04-17 13:43     ` Paolo Bonzini
2019-04-26  7:09 ` Christian Borntraeger

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=60692984-7a70-8b10-d51a-28fd019d3a88@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.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.