public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: kvm@vger.kernel.org, gleb@redhat.com, xiantao.zhang@intel.com,
	mingo@kernel.org, hpa@linux.intel.com
Subject: Re: [PATCH v5 4/5] KVM: VMX: Add the algorithm of deliver posted interrupt
Date: Fri, 8 Mar 2013 17:21:09 -0300	[thread overview]
Message-ID: <20130308202109.GA11546@amt.cnet> (raw)
In-Reply-To: <1362705801-4467-5-git-send-email-yang.z.zhang@intel.com>

On Fri, Mar 08, 2013 at 09:23:20AM +0800, Yang Zhang wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
> 
> 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@Intel.com>

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

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


  reply	other threads:[~2013-03-08 20:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08  1:23 [PATCH v5 0/5] KVM: VMX: Add Posted Interrupt supporting Yang Zhang
2013-03-08  1:23 ` [PATCH v5 1/5] KVM: VMX: Enable acknowledge interupt on vmexit Yang Zhang
2013-03-08  1:23 ` [PATCH v5 2/5] KVM: VMX: Register a new IPI for posted interrupt Yang Zhang
2013-03-08 13:26   ` Ingo Molnar
2013-03-08 13:47     ` Gleb Natapov
2013-03-08 14:05       ` Ingo Molnar
2013-03-08 14:07         ` Zhang, Yang Z
2013-03-08 14:21         ` Gleb Natapov
2013-03-08 15:40           ` Ingo Molnar
2013-03-15  2:41             ` Zhang, Yang Z
2013-03-08  1:23 ` [PATCH v5 3/5] KVM: VMX: Check the posted interrupt capability Yang Zhang
2013-03-08  1:23 ` [PATCH v5 4/5] KVM: VMX: Add the algorithm of deliver posted interrupt Yang Zhang
2013-03-08 20:21   ` Marcelo Tosatti [this message]
2013-03-09  1:19     ` Zhang, Yang Z
2013-03-08  1:23 ` [PATCH v5 5/5] KVM : VMX: Use posted interrupt to deliver virtual interrupt Yang Zhang
2013-03-08 20:23   ` Marcelo Tosatti
2013-03-09  1:19     ` Zhang, Yang Z
2013-03-11 13:04   ` Gleb Natapov
2013-03-11 13:38     ` Zhang, Yang Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130308202109.GA11546@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=gleb@redhat.com \
    --cc=hpa@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=xiantao.zhang@intel.com \
    --cc=yang.z.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox