All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Wanpeng Li <kernellwp@gmail.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Wanpeng Li" <wanpeng.li@hotmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"David Matlack" <dmatlack@google.com>
Subject: Re: [PATCH] KVM: halt-polling: poll if emulated lapic timer will fire soon
Date: Thu, 19 May 2016 13:23:57 +0200	[thread overview]
Message-ID: <573DA24D.3080507@de.ibm.com> (raw)
In-Reply-To: <1463649990-5889-1-git-send-email-wanpeng.li@hotmail.com>

On 05/19/2016 11:26 AM, Wanpeng Li wrote:

I think in general a good idea to poll if a timer will expire soon.

Some patch comments:

Same for all non-x86 archs:
> +static inline unsigned int kvm_arch_timer_remaining(struct kvm_vcpu *vcpu) {}

A function returning int, without a return statement? 
That gives at least a compiler warning.

> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -78,6 +78,9 @@ module_param(halt_poll_ns_grow, uint, S_IRUGO | S_IWUSR);
>  static unsigned int halt_poll_ns_shrink;
>  module_param(halt_poll_ns_shrink, uint, S_IRUGO | S_IWUSR);
> 
> +/* lower-end of message passing workload latency TCP_RR's poll time < 10us */
> +static unsigned int halt_poll_ns_base = 10000;
> +
>  /*
>   * Ordering of locks:
>   *
> @@ -1966,7 +1969,7 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
>  	grow = READ_ONCE(halt_poll_ns_grow);
>  	/* 10us base */
>  	if (val == 0 && grow)
> -		val = 10000;
> +		val = halt_poll_ns_base;
>  	else
>  		val *= grow;
> 
> @@ -2015,11 +2018,15 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
>  	DECLARE_SWAITQUEUE(wait);
>  	bool waited = false;
>  	u64 block_ns;
> +	unsigned int delta, remaining;
> 
> +	remaining = kvm_arch_timer_remaining(vcpu);

and now it causes undefined behaviour, no?


>  	start = cur = ktime_get();
> -	if (vcpu->halt_poll_ns) {
> -		ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
> +	if (vcpu->halt_poll_ns || (remaining < halt_poll_ns_base)) {
> +		ktime_t stop;
> 
> +		delta = vcpu->halt_poll_ns ? vcpu->halt_poll_ns : remaining;
> +		stop = ktime_add_ns(ktime_get(), delta);
>  		++vcpu->stat.halt_attempted_poll;
>  		do {
>  			/*
> 

So you avoid to shrink/grow for these cases? Probably makes sense

  reply	other threads:[~2016-05-19 11:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19  9:26 [PATCH] KVM: halt-polling: poll if emulated lapic timer will fire soon Wanpeng Li
2016-05-19 11:23 ` Christian Borntraeger [this message]
2016-05-19 11:35   ` Wanpeng Li
2016-05-19 11:42     ` Christian Borntraeger
2016-05-19 11:48       ` Wanpeng Li
2016-05-19 11:56         ` Christian Borntraeger
2016-05-19 12:00           ` Wanpeng Li

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=573DA24D.3080507@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=dmatlack@google.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=wanpeng.li@hotmail.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.