From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: Re: [PATCHv1 3/6] evtchn: simplify port_is_valid() Date: Tue, 9 Jun 2015 16:16:52 +0100 Message-ID: <55770364.6090604@citrix.com> References: <1433861999-15771-1-git-send-email-david.vrabel@citrix.com> <1433861999-15771-4-git-send-email-david.vrabel@citrix.com> <55770186.4070603@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z2LJ8-0000Hy-Ol for xen-devel@lists.xenproject.org; Tue, 09 Jun 2015 15:19:18 +0000 In-Reply-To: <55770186.4070603@citrix.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: Andrew Cooper , David Vrabel , xen-devel@lists.xenproject.org Cc: Keir Fraser , Tim Deegan , Ian Campbell , Jan Beulich List-Id: xen-devel@lists.xenproject.org On 09/06/15 16:08, Andrew Cooper wrote: > On 09/06/15 15:59, David Vrabel wrote: >> By keeping a count of the number of currently valid event channels, >> port_is_valid() can be simplified. >> >> d->valid_evtchns can also be tested without holding d->event_lock which >> will be useful later on. [...] >> --- a/xen/include/xen/sched.h >> +++ b/xen/include/xen/sched.h >> @@ -336,8 +336,9 @@ struct domain >> /* Event channel information. */ >> struct evtchn *evtchn; /* first bucket only */ >> struct evtchn **evtchn_group[NR_EVTCHN_GROUPS]; /* all other buckets */ >> - unsigned int max_evtchns; >> - unsigned int max_evtchn_port; >> + unsigned int max_evtchns; /* number supported by ABI */ >> + unsigned int max_evtchn_port; /* max permitted port number */ >> + atomic_t valid_evtchns; /* number of allocated event channels */ > > atomic_t contains a signed integer. You probably want a BUILD_BUG_ON() > if any ABI maximum value exceeds INT_MAX. Probably better to use unsigned int and read_atomic(). All the updates to valid_evtchns are done while holding d->event_lock. David ps. please trim replies.