[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANRm+Cxf9g7gvW1N7W0conMO4z-LUVuFiZ-ui37m1dtOwzzA1Q@mail.gmail.com>
Date: Mon, 24 Aug 2020 08:19:25 +0800
From: Wanpeng Li <kernellwp@...il.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: LKML <linux-kernel@...r.kernel.org>, kvm <kvm@...r.kernel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>
Subject: Re: [PATCH] KVM: LAPIC: Don't kick vCPU which is injecting
already-expired timer
On Sat, 22 Aug 2020 at 12:01, Sean Christopherson
<sean.j.christopherson@...el.com> wrote:
>
> On Fri, Aug 21, 2020 at 05:17:34PM +0800, Wanpeng Li wrote:
> > From: Wanpeng Li <wanpengli@...cent.com>
> >
> > The kick after setting KVM_REQ_PENDING_TIMER is used to handle the timer
> > fires on a different pCPU which vCPU is running on, we don't need this
> > kick when injecting already-expired timer, this kick is expensive since
> > memory barrier, rcu, preemption disable/enable operations. This patch
> > reduces the overhead by don't kick vCPU which is injecting already-expired
> > timer.
>
> This should also call out the VMX preemption timer case, which also passes
> from_timer_fn=false but doesn't need a kick because kvm_lapic_expired_hv_timer()
> is called from the target vCPU.
>
> > Signed-off-by: Wanpeng Li <wanpengli@...cent.com>
> > ---
> > arch/x86/kvm/lapic.c | 2 +-
> > arch/x86/kvm/x86.c | 5 +++--
> > arch/x86/kvm/x86.h | 2 +-
> > 3 files changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> > index 248095a..5b5ae66 100644
> > --- a/arch/x86/kvm/lapic.c
> > +++ b/arch/x86/kvm/lapic.c
> > @@ -1642,7 +1642,7 @@ static void apic_timer_expired(struct kvm_lapic *apic, bool from_timer_fn)
> > }
> >
> > atomic_inc(&apic->lapic_timer.pending);
> > - kvm_set_pending_timer(vcpu);
> > + kvm_set_pending_timer(vcpu, from_timer_fn);
>
> My vote would be to open code kvm_set_pending_timer() here and drop the
> helper, i.e.
>
> kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
> if (from_timer_fn)
> kvm_vcpu_kick(vcpu);
>
> with that and an updated changelog:
Agreed.
>
> Reviewed-by: Sean Christopherson <sean.j.christopherson@...el.com>
Thanks.
Wanpeng
Powered by blists - more mailing lists