2022-04-22 20:19:58

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: [PATCH V2 0/2] KVM: SVM: Optimize AVIC incomplete IPI #vmexit handling

This series introduce a fast-path when handling AVIC incomplete IPI #vmexit
for AVIC, and introduce a new tracepoint for the slow-path processing.

Regards,
Suravee

Change from v1: (https://lore.kernel.org/lkml/[email protected]/T/)
* Rebased on top of Linux 5.18-rc3
* Patch 1/2:
- Update commit shortlog to be more meaningful
- Refactor to remove x2AVIC related logic for now, which will be included
in the x2AVIC patch series.

Suravee Suthikulpanit (2):
KVM: SVM: Use target APIC ID to complete AVIC IRQs when possible
KVM: SVM: Introduce trace point for the slow-path of
avic_kic_target_vcpus

arch/x86/kvm/svm/avic.c | 74 ++++++++++++++++++++++++++++++++++++++---
arch/x86/kvm/trace.h | 20 +++++++++++
arch/x86/kvm/x86.c | 1 +
3 files changed, 91 insertions(+), 4 deletions(-)

--
2.25.1


2022-04-22 21:24:49

by Suthikulpanit, Suravee

[permalink] [raw]
Subject: [PATCH 2/2] KVM: SVM: Introduce trace point for the slow-path of avic_kic_target_vcpus

This can help identify potential performance issues when handles
AVIC incomplete IPI due vCPU not running.

Reviewed-by: Maxim Levitsky <[email protected]>
Signed-off-by: Suravee Suthikulpanit <[email protected]>
---
arch/x86/kvm/svm/avic.c | 2 ++
arch/x86/kvm/trace.h | 20 ++++++++++++++++++++
arch/x86/kvm/x86.c | 1 +
3 files changed, 23 insertions(+)

diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
index c8b8a0cb02b0..c5b38b160180 100644
--- a/arch/x86/kvm/svm/avic.c
+++ b/arch/x86/kvm/svm/avic.c
@@ -355,6 +355,8 @@ static void avic_kick_target_vcpus(struct kvm *kvm, struct kvm_lapic *source,
if (!avic_kick_target_vcpus_fast(kvm, source, icrl, icrh, index))
return;

+ trace_kvm_avic_kick_vcpu_slowpath(icrh, icrl, index);
+
/*
* Wake any target vCPUs that are blocking, i.e. waiting for a wake
* event. There's no need to signal doorbells, as hardware has handled
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index e3a24b8f04be..de4762517569 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -1459,6 +1459,26 @@ TRACE_EVENT(kvm_avic_ga_log,
__entry->vmid, __entry->vcpuid)
);

+TRACE_EVENT(kvm_avic_kick_vcpu_slowpath,
+ TP_PROTO(u32 icrh, u32 icrl, u32 index),
+ TP_ARGS(icrh, icrl, index),
+
+ TP_STRUCT__entry(
+ __field(u32, icrh)
+ __field(u32, icrl)
+ __field(u32, index)
+ ),
+
+ TP_fast_assign(
+ __entry->icrh = icrh;
+ __entry->icrl = icrl;
+ __entry->index = index;
+ ),
+
+ TP_printk("icrh:icrl=%#08x:%08x, index=%u",
+ __entry->icrh, __entry->icrl, __entry->index)
+);
+
TRACE_EVENT(kvm_hv_timer_state,
TP_PROTO(unsigned int vcpu_id, unsigned int hv_timer_in_use),
TP_ARGS(vcpu_id, hv_timer_in_use),
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 547ba00ef64f..d90e4020e9b9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -12980,6 +12980,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_pi_irte_update);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_unaccelerated_access);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_incomplete_ipi);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_ga_log);
+EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_avic_kick_vcpu_slowpath);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_apicv_accept_irq);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_enter);
EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_vmgexit_exit);
--
2.25.1

2022-04-22 21:48:54

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH V2 0/2] KVM: SVM: Optimize AVIC incomplete IPI #vmexit handling

On 4/20/22 17:49, Suravee Suthikulpanit wrote:
> This series introduce a fast-path when handling AVIC incomplete IPI #vmexit
> for AVIC, and introduce a new tracepoint for the slow-path processing.
>
> Regards,
> Suravee
>
> Change from v1: (https://lore.kernel.org/lkml/[email protected]/T/)
> * Rebased on top of Linux 5.18-rc3
> * Patch 1/2:
> - Update commit shortlog to be more meaningful
> - Refactor to remove x2AVIC related logic for now, which will be included
> in the x2AVIC patch series.
>
> Suravee Suthikulpanit (2):
> KVM: SVM: Use target APIC ID to complete AVIC IRQs when possible
> KVM: SVM: Introduce trace point for the slow-path of
> avic_kic_target_vcpus
>
> arch/x86/kvm/svm/avic.c | 74 ++++++++++++++++++++++++++++++++++++++---
> arch/x86/kvm/trace.h | 20 +++++++++++
> arch/x86/kvm/x86.c | 1 +
> 3 files changed, 91 insertions(+), 4 deletions(-)
>

Queued, thanks.

Paolo