From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v13 05/10] x86: dynamically attach/detach QoS monitoring service for a guest Date: Mon, 4 Aug 2014 10:38:09 +0100 Message-ID: <53DF5481.3010207@citrix.com> References: <1407118626-76843-1-git-send-email-dongxiao.xu@intel.com> <1407118626-76843-6-git-send-email-dongxiao.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1407118626-76843-6-git-send-email-dongxiao.xu@intel.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: Dongxiao Xu , xen-devel@lists.xen.org Cc: keir@xen.org, Ian.Campbell@citrix.com, George.Dunlap@eu.citrix.com, stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com, JBeulich@suse.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On 04/08/14 03:17, Dongxiao Xu wrote: > +/* Called with domain lock held, no pqos specific lock needed */ > +int pqos_monitor_alloc_rmid(struct domain *d) > +{ > + unsigned int rmid; > + > + ASSERT(pqos_monitor_enabled()); > + > + if ( d->arch.pqos_rmid > 0 ) > + return -EEXIST; > + > + for ( rmid = pqosm->rmid_min; rmid <= pqosm->rmid_max; rmid++ ) > + { > + if ( pqosm->rmid_to_dom[rmid] != DOMID_INVALID) > + continue; > + > + pqosm->rmid_to_dom[rmid] = d->domain_id; > + break; > + } > + > + /* No RMID available, assign RMID=0 by default */ > + if ( rmid > pqosm->rmid_max ) > + { > + d->arch.pqos_rmid = 0; > + return -EUSERS; > + } > + else > + pqosm->rmid_inuse++; This rmid_inuse needs some concurrency protection; the domain lock is not suitable. Probably best to make it an atomic_t and use atomic_inc/dec() ~Andrew