From: "Jan Beulich" Subject: Re: [RFC v2 13/15] Update Posted-Interrupts Descriptor during vCPU scheduling Date: Wed, 17 Jun 2015 08:56:16 +0100 Message-ID: <558144400200007800085DC6@mail.emea.novell.com> References: <1431076038-7497-1-git-send-email-feng.wu@intel.com> <1431076038-7497-14-git-send-email-feng.wu@intel.com> <5577F8CD0200007800082E0E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Feng Wu Cc: Kevin Tian , "keir@xen.org" , "george.dunlap@eu.citrix.com" , "andrew.cooper3@citrix.com" , "xen-devel@lists.xen.org" , Yang Z Zhang List-Id: xen-devel@lists.xenproject.org >>> On 17.06.15 at 08:54, wrote: >> From: Jan Beulich [mailto:JBeulich@suse.com] >> Sent: Wednesday, June 10, 2015 2:44 PM >> >>> On 08.05.15 at 11:07, wrote: >> > + switch ( v->runstate.state ) >> > + { >> > + case RUNSTATE_runnable: >> > + case RUNSTATE_offline: >> > + /* >> > + * We don't need to send notification event to a non-running >> > + * vcpu, the interrupt information will be delivered to it before >> > + * VM-ENTRY when the vcpu is scheduled to run next time. >> > + */ >> > + pi_desc->sn = 1; >> > + >> > + /* >> > + * If the state is transferred from RUNSTATE_blocked, >> > + * we should set 'NV' feild back to posted_intr_vector, >> > + * so the Posted-Interrupts can be delivered to the vCPU >> > + * by VT-d HW after it is scheduled to run. >> > + */ >> > + if ( old_state == RUNSTATE_blocked ) >> > + { >> > + do >> > + { >> > + old.control = new.control = pi_desc->control; >> > + new.nv = posted_intr_vector; >> > + } >> > + while ( cmpxchg(&pi_desc->control, old.control, new.control) >> > + != old.control ); >> >> So why is it okay to do the SN update non-atomically when the >> vector update is done atomically? >> >> Also the curly braces do _not_ go on separate lines for do/while >> constructs. >> >> And then do you really need to atomically update the whole 64 bits >> here, rather than just the nv field? By not making it a bit field >> you could perhaps just write_atomic() it? >> > > Thinking more about this, maybe write_atomic() is not good for this, we need > use > the LOCK prefix when updating the posted-interrupt descriptor. The LOCK prefix can't be applied to simple loads and stores; they're implicitly atomic. Also - please remember to trim your replies. Jan