From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCHv2 3/5] evtchn: use a per-event channel lock for sending events Date: Tue, 16 Jun 2015 10:57:40 +0100 Message-ID: <557FF314.20305@citrix.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> <55800DB70200007800085647@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z4nco-0003mp-1y for xen-devel@lists.xenproject.org; Tue, 16 Jun 2015 09:57:46 +0000 In-Reply-To: <55800DB70200007800085647@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel@lists.xenproject.org, Keir Fraser , Ian Campbell , Tim Deegan List-Id: xen-devel@lists.xenproject.org On 16/06/15 10:51, Jan Beulich wrote: >>>> 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.) Ok. I'll remove the d->evtchn check from port_is_valid() and use it. David