From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754996AbcESOwN (ORCPT ); Thu, 19 May 2016 10:52:13 -0400 Received: from e06smtp07.uk.ibm.com ([195.75.94.103]:34484 "EHLO e06smtp07.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754297AbcESOwL (ORCPT ); Thu, 19 May 2016 10:52:11 -0400 X-IBM-Helo: d06dlp02.portsmouth.uk.ibm.com X-IBM-MailFrom: borntraeger@de.ibm.com X-IBM-RcptTo: kvm@vger.kernel.org;linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] KVM: halt-polling: poll if emulated lapic timer will fire soon To: Paolo Bonzini , Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <1463664426-2991-1-git-send-email-wanpeng.li@hotmail.com> <19abf5c8-7016-45af-f0e6-3bdd161ffb38@redhat.com> Cc: Wanpeng Li , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , David Matlack From: Christian Borntraeger Message-ID: <573DD312.4060001@de.ibm.com> Date: Thu, 19 May 2016 16:52:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <19abf5c8-7016-45af-f0e6-3bdd161ffb38@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16051914-0029-0000-0000-00001EC833BD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/19/2016 03:57 PM, Paolo Bonzini wrote: > > > On 19/05/2016 15:27, Wanpeng Li wrote: >> From: Wanpeng Li >> >> 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? Hmm, your patch does only fiddle with the grow/shrink logic (which might be a good idea independently of this change), but the original patch actually takes into account that we have a guaranteed maximum time by a wakeup timer - IOW we know exactly what the maximum poll time is. > > 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); That would prevent halt_poll_ns from going 0, no? > 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 >