Re: [patch 2/5] KVM: reintroduce guest mode bit and unify remote request code

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

 



On 08/27/2009 04:20 AM, Marcelo Tosatti wrote:

+}
+
+void kvm_vcpu_ipi(struct kvm_vcpu *vcpu)
+{
+	int me;
+	int cpu = vcpu->cpu;

  	me = get_cpu();
-	if (cpu != me&&  (unsigned)cpu<  nr_cpu_ids&&  cpu_online(cpu))
-		if (!test_and_set_bit(KVM_REQ_KICK,&vcpu->requests))
-			smp_send_reschedule(cpu);
+	if (cpu != me&&  (unsigned)cpu<  nr_cpu_ids&&  cpu_online(cpu)) {
+		if (test_bit(KVM_VCPU_GUEST_MODE,&vcpu->vcpu_state)) {
+			if (!test_and_set_bit(KVM_VCPU_KICKED,
+					&vcpu->vcpu_state))
+				smp_send_reschedule(cpu);
+		}
+	}
  	put_cpu();
  }

@@ -168,6 +176,30 @@ static bool make_all_cpus_request(struct
  	return called;
  }

+static int kvm_req_wait(void *unused)
+{
+	cpu_relax();
+	return 0;
+}
+
+static void kvm_vcpu_request(struct kvm_vcpu *vcpu, unsigned int req)
+{
+	set_bit(req,&vcpu->requests);
+	barrier();
+	kvm_vcpu_ipi(vcpu);
+	wait_on_bit(&vcpu->vcpu_state, KVM_VCPU_GUEST_MODE, kvm_req_wait,
+		    TASK_UNINTERRUPTIBLE);
+}
+
+static void kvm_vcpus_request(struct kvm *kvm, unsigned int req)
+{
+	int i;
+	struct kvm_vcpu *vcpu;
+
+	kvm_for_each_vcpu(i, vcpu, kvm)
+		kvm_vcpu_request(vcpu, req);
+}

Gleb notes there are two problems here: instead of using a multicast IPI, you're sending multiple unicast IPIs. Second, you're serializing the waiting. It would be better to batch-send the IPIs, then batch-wait for results.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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