From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [v3 08/15] Suppress posting interrupts when 'SN' is set Date: Fri, 10 Jul 2015 14:20:29 +0100 Message-ID: <559FE2BD020000780008F874@mail.emea.novell.com> References: <1435123109-10481-1-git-send-email-feng.wu@intel.com> <1435123109-10481-9-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1435123109-10481-9-git-send-email-feng.wu@intel.com> 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@intel.com, keir@xen.org, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, xen-devel@lists.xen.org, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org >>> On 24.06.15 at 07:18, wrote: > @@ -1698,13 +1700,35 @@ static void vmx_deliver_posted_intr(struct vcpu *v, u8 vector) > */ > pi_set_on(&v->arch.hvm_vmx.pi_desc); > } > - else if ( !pi_test_and_set_on(&v->arch.hvm_vmx.pi_desc) ) > + else > { > + prev.control = 0; > + > + do { > + old.control = v->arch.hvm_vmx.pi_desc.control & > + ~(1 << POSTED_INTR_ON | 1 << POSTED_INTR_SN); > + new.control = v->arch.hvm_vmx.pi_desc.control | > + 1 << POSTED_INTR_ON; > + > + /* > + * Currently, we don't support urgent interrupt, all > + * interrupts are recognized as non-urgent interrupt, > + * so we cannot send posted-interrupt when 'SN' is set. > + * Besides that, if 'ON' is already set, we cannot set > + * posted-interrupts as well. > + */ > + if ( prev.sn || prev.on ) > + { > + vcpu_kick(v); > + return; > + } > + > + prev.control = cmpxchg(&v->arch.hvm_vmx.pi_desc.control, > + old.control, new.control); > + } while ( prev.control != old.control ); This pretty clearly demonstrates that mixing bitfields and non-bitfield mask operations makes code hard to read: How is one supposed to see at the first glance that e.g. prev.on and old.control & (1 << POSTED_INTR_ON) are the same thing? Jan