From: "Jan Beulich" Subject: Re: [PATCHv1 4/6] evtchn: use a per-event channel lock for sending events Date: Wed, 10 Jun 2015 09:59:01 +0100 Message-ID: <557818750200007800082EBA@mail.emea.novell.com> References: <1433861999-15771-1-git-send-email-david.vrabel@citrix.com> <1433861999-15771-5-git-send-email-david.vrabel@citrix.com> <5577036C.5050006@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z2bqk-0003Gr-Ai for xen-devel@lists.xenproject.org; Wed, 10 Jun 2015 08:59:06 +0000 In-Reply-To: <5577036C.5050006@citrix.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: Andrew Cooper , David Vrabel Cc: xen-devel@lists.xenproject.org, Keir Fraser , Ian Campbell , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 09.06.15 at 17:17, wrote: > On 09/06/15 15:59, David Vrabel wrote: >> @@ -243,6 +248,30 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) >> } >> >> >> +static void double_evtchn_lock(struct domain *ld, struct evtchn *lchn, >> + struct domain *rd, struct evtchn *rchn) >> +{ >> + if ( ld < rd || (ld == rd && lchn->port < rchn->port) ) > > ld < rd is undefined behaviour as they are not part of the same > singly-allocated object. It would be better to choose order based on > domid, and looks like the grant code suffers the same issue. I'm not concerned of undefined behavior here at all (nor in gnttab code): struct domain * are all page aligned, and hence can be viewed as elements of a page sized array spanning the entire Xen heap. What I'd recommend is also making the channel comparison use the pointers instead of the port numbers. Which then likely could result in comparing only these two pointers. Or if not, I'd really like to at least see the struct domain pointers here to get const qualified. Jan