All of lore.kernel.org
 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: Sean Christopherson <sean.j.christopherson@intel.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>
Subject: Re: [PATCH v2 5/9] KVM: LAPIC: Narrow down the kick target vCPU
Date: Sat, 12 Sep 2020 08:46:15 +0200	[thread overview]
Message-ID: <9281f28a-e2bd-a79c-fc94-4999f4c6307a@redhat.com> (raw)
In-Reply-To: <1599731444-3525-6-git-send-email-wanpengli@tencent.com>

On 10/09/20 11:50, Wanpeng Li wrote:
> From: Wanpeng Li <wanpengli@tencent.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, this kick is expensive
> since memory barrier, rcu, preemption disable/enable operations. We don't
> need this kick when injecting already-expired timer, we also should 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.
> 
> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
>  arch/x86/kvm/lapic.c | 4 +++-
>  arch/x86/kvm/x86.c   | 6 ------
>  arch/x86/kvm/x86.h   | 1 -
>  3 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index e446bdf..3b32d3b 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1642,7 +1642,9 @@ 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_make_request(KVM_REQ_PENDING_TIMER, vcpu);
> +	if (from_timer_fn)
> +		kvm_vcpu_kick(vcpu);
>  }

This only matters for !APICv, but it's nice anyway.

Paolo

>  static void start_sw_tscdeadline(struct kvm_lapic *apic)
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d39d6cf..dcf4494 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1774,12 +1774,6 @@ static s64 get_kvmclock_base_ns(void)
>  }
>  #endif
>  
> -void kvm_set_pending_timer(struct kvm_vcpu *vcpu)
> -{
> -	kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
> -	kvm_vcpu_kick(vcpu);
> -}
> -
>  static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
>  {
>  	int version;
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index 995ab69..ea20b8b 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -246,7 +246,6 @@ static inline bool kvm_vcpu_latch_init(struct kvm_vcpu *vcpu)
>  	return is_smm(vcpu) || kvm_x86_ops.apic_init_signal_blocked(vcpu);
>  }
>  
> -void kvm_set_pending_timer(struct kvm_vcpu *vcpu);
>  void kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip);
>  
>  void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr);
> 


  reply	other threads:[~2020-09-12  6:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10  9:50 [PATCH v2 0/9] KVM: collect sporadic patches Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 1/9] KVM: LAPIC: Return 0 when getting the tscdeadline timer if the lapic is hw disabled Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 2/9] KVM: LAPIC: Guarantee the timer is in tsc-deadline mode when setting Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 3/9] KVM: LAPIC: Fix updating DFR missing apic map recalculation Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 4/9] KVM: VMX: Don't freeze guest when event delivery causes an APIC-access exit Wanpeng Li
2020-09-29 21:42   ` Jim Mattson
2020-09-10  9:50 ` [PATCH v2 5/9] KVM: LAPIC: Narrow down the kick target vCPU Wanpeng Li
2020-09-12  6:46   ` Paolo Bonzini [this message]
2020-09-10  9:50 ` [PATCH v2 6/9] KVM: LAPIC: Reduce world switch latency caused by timer_advance_ns Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 7/9] KVM: SVM: Get rid of handle_fastpath_set_msr_irqoff() Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 8/9] KVM: SVM: Move svm_complete_interrupts() into svm_vcpu_run() Wanpeng Li
2020-09-10  9:50 ` [PATCH v2 9/9] KVM: SVM: Reenable handle_fastpath_set_msr_irqoff() after complete_interrupts() Wanpeng Li
2020-09-12  6:47 ` [PATCH v2 0/9] KVM: collect sporadic patches Paolo Bonzini

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=9281f28a-e2bd-a79c-fc94-4999f4c6307a@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.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.