From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Matlack Date: Tue, 28 Sep 2021 22:08:33 +0000 Subject: Re: [PATCH 12/14] KVM: Don't redo ktime_get() when calculating halt-polling stop/deadline Message-Id: List-Id: References: <20210925005528.1145584-1-seanjc@google.com> <20210925005528.1145584-13-seanjc@google.com> In-Reply-To: <20210925005528.1145584-13-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, Jing Zhang On Fri, Sep 24, 2021 at 05:55:26PM -0700, Sean Christopherson wrote: > Calculate the halt-polling "stop" time using "cur" instead of redoing > ktime_get(). In the happy case where hardware correctly predicts > do_halt_poll, "cur" is only a few cycles old. And if the branch is > mispredicted, arguably that extra latency should count toward the > halt-polling time. > > In all likelihood, the numbers involved are in the noise and either > approach is perfectly ok. > > Signed-off-by: Sean Christopherson Reviewed-by: David Matlack > --- > virt/kvm/kvm_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 2980d2b88559..80f78daa6b8d 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3267,7 +3267,7 @@ void kvm_vcpu_halt(struct kvm_vcpu *vcpu) > > start = cur = poll_end = ktime_get(); > if (do_halt_poll) { > - ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); > + ktime_t stop = ktime_add_ns(cur, vcpu->halt_poll_ns); > > do { > /* > -- > 2.33.0.685.g46640cef36-goog >