LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] KVM: LAPIC: Per vCPU control over kvm_can_post_timer_interrupt
@ 2021-11-22  1:58 Aili Yao
  2021-11-22 19:13 ` Sean Christopherson
  0 siblings, 1 reply; 9+ messages in thread
From: Aili Yao @ 2021-11-22  1:58 UTC (permalink / raw)
  To: pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, tglx,
	mingo, bp, dave.hansen
  Cc: x86, hpa, kvm, linux-kernel, yaoaili

From: Aili Yao <yaoaili@kingsoft.com>

When we isolate some pyhiscal cores, We may not use them for kvm guests,
We may use them for other purposes like DPDK, or we can make some kvm
guests isolated and some not, the global judgement pi_inject_timer is
not enough; We may make wrong decisions:

In such a scenario, the guests without isolated cores will not be
permitted to use vmx preemption timer, and tscdeadline fastpath also be
disabled, both will lead to performance penalty.

So check whether the vcpu->cpu is isolated, if not, don't post timer
interrupt.

Signed-off-by: Aili Yao <yaoaili@kingsoft.com>
---
 arch/x86/kvm/lapic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 759952dd1222..72dde5532101 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -34,6 +34,7 @@
 #include <asm/delay.h>
 #include <linux/atomic.h>
 #include <linux/jump_label.h>
+#include <linux/sched/isolation.h>
 #include "kvm_cache_regs.h"
 #include "irq.h"
 #include "ioapic.h"
@@ -113,7 +114,8 @@ static inline u32 kvm_x2apic_id(struct kvm_lapic *apic)
 
 static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu)
 {
-	return pi_inject_timer && kvm_vcpu_apicv_active(vcpu);
+	return pi_inject_timer && kvm_vcpu_apicv_active(vcpu) &&
+		!housekeeping_cpu(vcpu->cpu, HK_FLAG_TIMER);
 }
 
 bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu)
-- 
2.25.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-11-29  3:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22  1:58 [PATCH] KVM: LAPIC: Per vCPU control over kvm_can_post_timer_interrupt Aili Yao
2021-11-22 19:13 ` Sean Christopherson
2021-11-23  2:57   ` Wanpeng Li
2021-11-23  4:11     ` yaoaili [么爱利]
2021-11-23  6:24       ` Wanpeng Li
2021-11-23  7:02         ` Aili Yao
2021-11-23  7:22           ` Wanpeng Li
2021-11-23  8:18   ` Aili Yao
2021-11-29  3:28     ` Aili Yao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).