Skip to contentSkip to conversation

KVM: x86: Take advantage of kvm_arch_dy_has_pending_interrupt()

PATCH In review [email protected] 3 participants 3 messages Apr 21, 2021 – Apr 22, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86: Take advantage of kvm_arch_dy_has_pending_interrupt()

From: Haiwei Li <[email protected]>

kvm_arch_dy_runnable checks the pending_interrupt as the code in kvm_arch_dy_has_pending_interrupt. So take advantage of it.

---
 arch/x86/kvm/x86.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
arch/x86/kvm/x86.c +9 -12
index d696a9f..08bd616 100644
@@ -11125,28 +11125,25 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
 	return kvm_vcpu_running(vcpu) || kvm_vcpu_has_events(vcpu);
 }
 
-bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu)
+bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu)
 {
-	if (READ_ONCE(vcpu->arch.pv.pv_unhalted))
-		return true;
-
-	if (kvm_test_request(KVM_REQ_NMI, vcpu) ||
-		kvm_test_request(KVM_REQ_SMI, vcpu) ||
-		 kvm_test_request(KVM_REQ_EVENT, vcpu))
-		return true;
-
 	if (vcpu->arch.apicv_active && static_call(kvm_x86_dy_apicv_has_pending_interrupt)(vcpu))
 		return true;
 
 	return false;
 }
 
-bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu)
+bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu)
 {
-	if (vcpu->arch.apicv_active && static_call(kvm_x86_dy_apicv_has_pending_interrupt)(vcpu))
+	if (READ_ONCE(vcpu->arch.pv.pv_unhalted))
 		return true;
 
-	return false;
+	if (kvm_test_request(KVM_REQ_NMI, vcpu) ||
+		kvm_test_request(KVM_REQ_SMI, vcpu) ||
+		 kvm_test_request(KVM_REQ_EVENT, vcpu))
+		return true;
+
+	return kvm_arch_dy_has_pending_interrupt(vcpu);
 }
 
 bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
Signature · 1 line
1.8.3.1
maintainer
#2 lore raw
In reply to [email protected]
Quoted 43 lines · On 21/04/21 05:25, [email protected] wrote:

From: Haiwei Li <[email protected]>

kvm_arch_dy_runnable checks the pending_interrupt as the code in kvm_arch_dy_has_pending_interrupt. So take advantage of it.

---
  arch/x86/kvm/x86.c | 21 +++++++++------------
  1 file changed, 9 insertions(+), 12 deletions(-)
arch/x86/kvm/x86.c +3 -11
index d696a9f..08bd616 100644
@@ -11125,28 +11125,25 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
  	return kvm_vcpu_running(vcpu) || kvm_vcpu_has_events(vcpu);
  }
 
-bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu)
+bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu)
  {
-	if (READ_ONCE(vcpu->arch.pv.pv_unhalted))
-		return true;
-
-	if (kvm_test_request(KVM_REQ_NMI, vcpu) ||
-		kvm_test_request(KVM_REQ_SMI, vcpu) ||
-		 kvm_test_request(KVM_REQ_EVENT, vcpu))
-		return true;
-
  	if (vcpu->arch.apicv_active && static_call(kvm_x86_dy_apicv_has_pending_interrupt)(vcpu))
  		return true;
 
  	return false;
  }
 
-bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *vcpu)
+bool kvm_arch_dy_runnable(struct kvm_vcpu *vcpu)
  {
-	if (vcpu->arch.apicv_active && static_call(kvm_x86_dy_apicv_has_pending_interrupt)(vcpu))
+	if (READ_ONCE(vcpu->arch.pv.pv_unhalted))
  		return true;
 

arch/x86/kvm/x86.c int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) · line 11149

Quoted 10 lines
arch/x86/kvm/x86.c +6 -1
-	return false;
+	if (kvm_test_request(KVM_REQ_NMI, vcpu) ||
+		kvm_test_request(KVM_REQ_SMI, vcpu) ||
+		 kvm_test_request(KVM_REQ_EVENT, vcpu))
+		return true;
+
+	return kvm_arch_dy_has_pending_interrupt(vcpu);
  }
 
  bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)

Looks good, but I'd like to take a look at the other patches for directed yield first. Thanks!

Paolo