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



On 19/05/2016 15:27, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
> 
> If an emulated lapic timer will fire soon(in the scope of 10us the
> base of dynamic halt-polling, lower-end of message passing workload
> latency TCP_RR's poll time < 10us) we can treat it as a short halt,
> and poll to wait it fire, the fire callback apic_timer_fn() will set
> KVM_REQ_PENDING_TIMER, and this flag will be check during busy poll.
> This can avoid context switch overhead and the latency which we wake
> up vCPU.

Would this work too and be simpler?

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4fd482fb9260..8d42f5304d94 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1964,16 +1964,12 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
 
 	old = val = vcpu->halt_poll_ns;
 	grow = READ_ONCE(halt_poll_ns_grow);
-	/* 10us base */
-	if (val == 0 && grow)
-		val = 10000;
-	else
-		val *= grow;
+	val *= grow;
 
 	if (val > halt_poll_ns)
 		val = halt_poll_ns;
 
-	vcpu->halt_poll_ns = val;
+	vcpu->halt_poll_ns = max(10000u, val);
 	trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
 }
 
@@ -1988,7 +1984,7 @@ static void shrink_halt_poll_ns(struct kvm_vcpu *vcpu)
 	else
 		val /= shrink;
 
-	vcpu->halt_poll_ns = val;
+	vcpu->halt_poll_ns = max(10000u, val);
 	trace_kvm_halt_poll_ns_shrink(vcpu->vcpu_id, val, old);
 }
 

(Plus moving 10000 into a module parameter?)  Can you measure higher CPU
utilization than with your patch?  David, what do you think?

Thanks,

Paolo

  parent reply	other threads:[~2016-05-19 13:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19 13:27 Wanpeng Li
2016-05-19 13:46 ` Christian Borntraeger
2016-05-19 13:57 ` Paolo Bonzini [this message]
2016-05-19 14:52   ` Christian Borntraeger
2016-05-19 14:56     ` Paolo Bonzini
2016-05-19 15:03       ` Christian Borntraeger
2016-05-19 15:06         ` Paolo Bonzini
2016-05-19 15:42           ` Christian Borntraeger
2016-05-24  2:48   ` Wanpeng Li
2016-05-19 18:01 ` David Matlack
2016-05-19 18:36   ` David Matlack
2016-05-20  2:04     ` Yang Zhang
2016-05-20  5:53       ` Wanpeng Li
2016-05-20 18:37       ` David Matlack
2016-05-23  1:26         ` Yang Zhang
2016-05-23 18:04           ` David Matlack
2016-05-24  1:13             ` Yang Zhang
2016-05-24  1:16               ` David Matlack
2016-05-24  2:55                 ` Yang Zhang

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=19abf5c8-7016-45af-f0e6-3bdd161ffb38@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=dmatlack@google.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®