RE: [PATCH v5 4/5] KVM: VMX: Add the algorithm of deliver posted interrupt

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

 



Marcelo Tosatti wrote on 2013-03-09:
> On Fri, Mar 08, 2013 at 09:23:20AM +0800, Yang Zhang wrote:
>> From: Yang Zhang <yang.z.zhang@xxxxxxxxx>
>> 
>> Only deliver the posted interrupt when target vcpu is running
>> and there is no previous interrupt pending in pir.
>> 
>> Signed-off-by: Yang Zhang <yang.z.zhang@xxxxxxxxx>
>> 
>> +static bool vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu, int vector)
>> +{
>> +	struct vcpu_vmx *vmx = to_vmx(vcpu);
>> +
>> +	if (!vmx_vm_has_apicv(vcpu->kvm))
>> +		return false;
>> +
>> +	if (pi_test_and_set_pir(vector, &vmx->pi_desc))
>> +		return true;
>> +
>> +	kvm_make_request(KVM_REQ_EVENT, vcpu);
>> +	if ((vcpu->mode == IN_GUEST_MODE)) {
>> +		if (!pi_test_and_set_on(&vmx->pi_desc))
>> +			apic->send_IPI_mask(get_cpu_mask(vcpu->cpu),
>> +					POSTED_INTR_VECTOR);
>> +	} else
>> +		kvm_vcpu_kick(vcpu);
>> +
>> +	return true;
>> +}
> 
> Meaning of return value is unclear.
Yes, maybe the function name is confused. how about call it hwapic_deliver_interrupt()?

Or, rollback to the old way:
if(vm_has_apicv)
	deliver_posted_interrupt()
else
	test_and_set_virr(). 

>> +
>> +static bool vmx_sync_pir_to_irr(struct kvm_vcpu *vcpu, bool sync)
>> +{
>> +	struct vcpu_vmx *vmx = to_vmx(vcpu);
>> +
>> +	if (!vmx_vm_has_apicv(vcpu->kvm))
>> +		return false;
>> +
>> +	if (bitmap_empty((unsigned long *)vmx->pi_desc.pir, 256))
>> +		return false;
>> +
>> +	if (sync)
>> +		kvm_apic_update_irr(vcpu, vmx->pi_desc.pir);
>> +	return true;
>> +}
> 
> Please split in two kvm_x86_ops functions: one to query whether PIR is empty
> the other
> to perform the sync.
> 
> Perhaps "->hwapic_has_interrupt" is a good name.
Sure.

Best regards,
Yang

--
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