Re: [patch 4/4] KVM: VMX: update vcpu posted-interrupt descriptor when assigning device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24/05/21 19:53, Marcelo Tosatti wrote:
On Mon, May 24, 2021 at 05:55:18PM +0200, Paolo Bonzini wrote:
On 10/05/21 19:26, Marcelo Tosatti wrote:
+void vmx_pi_start_assignment(struct kvm *kvm)
+{
+	struct kvm_vcpu *vcpu;
+	int i;
+
+	if (!irq_remapping_cap(IRQ_POSTING_CAP))
+		return;
+
+	/*
+	 * Wakeup will cause the vCPU to bail out of kvm_vcpu_block() and
+	 * go back through vcpu_block().
+	 */
+	kvm_for_each_vcpu(i, vcpu, kvm) {
+		if (!kvm_vcpu_apicv_active(vcpu))
+			continue;
+
+		kvm_vcpu_wake_up(vcpu);

Would you still need the check_block callback, if you also added a
kvm_make_request(KVM_REQ_EVENT)?

In fact, since this is entirely not a hot path, can you just do
kvm_make_all_cpus_request(kvm, KVM_REQ_EVENT) instead of this loop?

Thanks,

Paolo

Hi Paolo,

Don't think so:

static int kvm_vcpu_check_block(struct kvm_vcpu *vcpu)
{
         int ret = -EINTR;
         int idx = srcu_read_lock(&vcpu->kvm->srcu);

         if (kvm_arch_vcpu_runnable(vcpu)) {
                 kvm_make_request(KVM_REQ_UNHALT, vcpu);  <---- don't want KVM_REQ_UNHALT

UNHALT is incorrect indeed, but requests don't have to unhalt the vCPU.

This case is somewhat similar to signal_pending(), where the next KVM_RUN ioctl resumes the halt. It's also similar to KVM_REQ_PENDING_TIMER. So you can:

- rename KVM_REQ_PENDING_TIMER to KVM_REQ_UNBLOCK except in arch/powerpc, where instead you add KVM_REQ_PENDING_TIMER to arch/powerpc/include/asm/kvm_host.h

- here, you add

	if (kvm_check_request(KVM_REQ_UNBLOCK, vcpu))
		goto out;

- then vmx_pi_start_assignment only needs to

	if (!irq_remapping_cap(IRQ_POSTING_CAP))
		return;
	kvm_make_all_cpus_request(kvm, KVM_REQ_UNBLOCK);

kvm_arch_vcpu_runnable() would still return false, so the mp_state would not change.

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux