From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCHv2 3/5] evtchn: use a per-event channel lock for sending events Date: Tue, 16 Jun 2015 10:51:19 +0100 Message-ID: <55800DB70200007800085647@mail.emea.novell.com> References: <1434383299-21833-1-git-send-email-david.vrabel@citrix.com> <1434383299-21833-4-git-send-email-david.vrabel@citrix.com> <5580060502000078000855A9@mail.emea.novell.com> <557FEDB3.2090601@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 1Z4nWe-0003DX-GE for xen-devel@lists.xenproject.org; Tue, 16 Jun 2015 09:51:24 +0000 In-Reply-To: <557FEDB3.2090601@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: David Vrabel Cc: xen-devel@lists.xenproject.org, Keir Fraser , Ian Campbell , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 16.06.15 at 11:34, wrote: > On 16/06/15 10:18, Jan Beulich wrote: >>>>> On 15.06.15 at 17:48, wrote: >>> @@ -609,21 +662,18 @@ int evtchn_send(struct domain *ld, unsigned int lport) >>> struct domain *rd; >>> int rport, ret = 0; >>> >>> - spin_lock(&ld->event_lock); >>> - >>> - if ( unlikely(!port_is_valid(ld, lport)) ) >>> - { >>> - spin_unlock(&ld->event_lock); >>> + if ( unlikely(lport >= read_atomic(&ld->valid_evtchns)) ) >>> return -EINVAL; >>> - } >> >> I don't think you really want to open code part of port_is_valid() >> (and avoid other parts of it) here? Or if really so, I think a comment >> should be added to explain it. > > The ld->valid_evtchns is the only field we can safely check without > ld->event_lock. > > We do check the channel state and the code that set this state uses the > full port_is_valid() call. I'll add a comment. Hmm, port_is_valid() also checks d->max_evtchns and d->evtchn. The latter is involved in evtchn_from_port(), so I can't see how you checking the channel's state _afterwards_ can leverage that whoever set this state did a full check. Another question is whether with the ->valid_evtchns check the ->evtchn check is necessary at all anymore. (The check against ->max_evtchns isn't wrong with the lock not held, i.e. could only end up being too strict, and hence the open coding would then still be questionable.) Jan