All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhang, Yang Z" <yang.z.zhang@intel.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"gleb@redhat.com" <gleb@redhat.com>,
	"Shan, Haitao" <haitao.shan@intel.com>,
	"Zhang, Xiantao" <xiantao.zhang@intel.com>,
	"Nakajima, Jun" <jun.nakajima@intel.com>,
	"Anvin, H Peter" <h.peter.anvin@intel.com>
Subject: RE: [PATCH 2/2] x86, apicv: Add Posted Interrupt supporting
Date: Wed, 23 Jan 2013 05:09:32 +0000	[thread overview]
Message-ID: <A9667DDFB95DB7438FA9D7D576C3D87E314715@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20130122225922.GA19011@amt.cnet>

Marcelo Tosatti wrote on 2013-01-23:
> On Thu, Dec 13, 2012 at 03:29:40PM +0800, Yang Zhang wrote:
>> From: Yang Zhang <yang.z.zhang@Intel.com>
>> 
>> Posted Interrupt allows APIC interrupts to inject into guest directly
>> without any vmexit.
>> 
>> - When delivering a interrupt to guest, if target vcpu is running,
>>   update Posted-interrupt requests bitmap and send a notification event
>>   to the vcpu. Then the vcpu will handle this interrupt automatically,
>>   without any software involvemnt.
>> - If target vcpu is not running or there already a notification event
>>   pending in the vcpu, do nothing. The interrupt will be handled by
>>   next vm entry.
>> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
>> ---
> 
> <snip>
> 
>> +static void pi_handler(void)
>> +{
>> +	;
>> +}
>> +
>> +static int vmx_has_posted_interrupt(struct kvm_vcpu *vcpu)
>> +{
>> +	return irqchip_in_kernel(vcpu->kvm) && enable_apicv_pi;
>> +}
>> +
>> +static int vmx_send_nv(struct kvm_vcpu *vcpu,
>> +		int vector)
>> +{
>> +	struct vcpu_vmx *vmx = to_vmx(vcpu);
>> +
>> +	pi_set_pir(vector, vmx->pi);
> 
> Section 29.6 "Posted interrupt processing":
> 
> "No other agent can read or write a PIR bit (or groups of bits) between
> the time it is read (to determine what to OR into VIRR) and when it is
> cleared".
This means hardware can ensure the read and clear operation is atomic, for example, use locked cmpxchg.

>> +	if (!pi_test_and_set_on(vmx->pi) && (vcpu->mode == IN_GUEST_MODE)) {
>> +		apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), POSTED_INTR_VECTOR);
>> +		return 1; +	} +	return 0;
> 
> What is the purpose of outstanding-notification bit? At first, its use as a
> "lock" for PIR posted-interrupt bits is limited because its cleared
> on step 3. before PIR is cleared. If it were cleared after step 5. then
> software could
> 
> 	if (!pi_test_and_set_on(vmx->pi)) { 		pi_set_pir(vector, vmx->pi);
> 		apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), POSTED_INTR_VECTOR); 	}
> 
> Does this mean software has to read PIR _and_ outstanding notification
> bit to know when its possible to set bits in PIR + send IPI?
There is no limitation for software to set bits in PIR. Software can set PIR unconditionally with locked operation.
Software must to read ON bit to check whether the IPI is needed. If ON bit is set, this means an notification event already sent but not acked by target cpu and no need to resend it again.

> 
> Or is it really cleared after step 5?
No, it is in step 3.


Best regards,
Yang


  reply	other threads:[~2013-01-23  5:09 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-13  7:29 [PATCH 0/2] KVM: Add posted interrupt supporting Yang Zhang
2012-12-13  7:29 ` [PATCH 1/2] x86: Enable ack interrupt on vmexit Yang Zhang
2012-12-13  7:51   ` Gleb Natapov
2012-12-13  7:54     ` Zhang, Yang Z
2012-12-13  7:58       ` Gleb Natapov
2012-12-13  8:03         ` Zhang, Yang Z
2012-12-13  8:05           ` Gleb Natapov
2012-12-13  8:19             ` Zhang, Yang Z
2012-12-13  8:22               ` Gleb Natapov
2012-12-13  8:23                 ` Zhang, Yang Z
2012-12-16 13:26                 ` Zhang, Yang Z
2012-12-18  9:11                   ` Gleb Natapov
2012-12-13  7:29 ` [PATCH 2/2] x86, apicv: Add Posted Interrupt supporting Yang Zhang
2013-01-22 22:59   ` Marcelo Tosatti
2013-01-23  5:09     ` Zhang, Yang Z [this message]
2013-01-24 23:43   ` Marcelo Tosatti
2013-01-25  0:40     ` Zhang, Yang Z
2013-01-30 23:03       ` Marcelo Tosatti
2013-01-30 23:57         ` Marcelo Tosatti
2013-01-31  7:35         ` Gleb Natapov
2013-01-31  9:43         ` Gleb Natapov
2013-01-31 13:32           ` Marcelo Tosatti
2013-01-31 13:38             ` Gleb Natapov
2013-01-31 13:44               ` Marcelo Tosatti
2013-01-31 13:55                 ` Gleb Natapov
2013-02-04  0:57                   ` Marcelo Tosatti
2013-02-04  9:10                     ` Zhang, Yang Z
2013-02-04  9:55                     ` Gleb Natapov
2013-02-04 14:43                       ` Marcelo Tosatti
2013-02-04 17:13                         ` Gleb Natapov
2013-02-04 19:59                           ` Marcelo Tosatti
2013-02-04 20:47                             ` Marcelo Tosatti
2013-02-05  5:57                               ` Zhang, Yang Z
2013-02-05  8:00                                 ` Gleb Natapov
2013-02-05 10:35                                   ` Zhang, Yang Z
2013-02-05 10:54                                     ` Gleb Natapov
2013-02-05 10:58                                       ` Zhang, Yang Z
2013-02-05 11:16                                         ` Gleb Natapov
2013-02-05 13:26                                           ` Zhang, Yang Z
2013-02-05 13:29                                             ` Gleb Natapov
2013-02-05 13:40                                               ` Zhang, Yang Z
2013-02-05 13:43                                                 ` Gleb Natapov
2013-02-07  1:23                                                 ` Marcelo Tosatti
2013-02-05  7:32                               ` Gleb Natapov
2013-02-06 22:49                                 ` Marcelo Tosatti
2013-02-07  0:24                                   ` Marcelo Tosatti
2013-02-07 13:52                                     ` Gleb Natapov
2013-02-08  2:07                                       ` Marcelo Tosatti
2013-02-08 12:18                                         ` Gleb Natapov
2013-02-07 14:01                                   ` Gleb Natapov
2013-02-07 21:49                                     ` Marcelo Tosatti
2013-02-08 12:28                                       ` Gleb Natapov
2013-02-08 13:46                                         ` Marcelo Tosatti
2013-01-31  9:37   ` Gleb Natapov
2013-02-04  9:11     ` 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=A9667DDFB95DB7438FA9D7D576C3D87E314715@SHSMSX101.ccr.corp.intel.com \
    --to=yang.z.zhang@intel.com \
    --cc=gleb@redhat.com \
    --cc=h.peter.anvin@intel.com \
    --cc=haitao.shan@intel.com \
    --cc=jun.nakajima@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=xiantao.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.