From: "Jan Beulich" Subject: Re: [PATCH v11 5/9] x86: dynamically attach/detach QoS monitoring service for a guest Date: Fri, 20 Jun 2014 16:08:12 +0100 Message-ID: <53A46A7C020000780001C0F7@mail.emea.novell.com> References: <19c30e909b84cdd1a8f49b1707b1810190af0a83.1403248469.git.dongxiao.xu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <19c30e909b84cdd1a8f49b1707b1810190af0a83.1403248469.git.dongxiao.xu@intel.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: Dongxiao Xu Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 20.06.14 at 16:31, wrote: > +int pqos_monitor_alloc_rmid(struct domain *d) > +{ > + int rc = 0; > + unsigned int rmid; > + > + ASSERT(pqos_monitor_enabled()); > + > + spin_lock(&pqosm->pqosm_lock); > + > + if ( d->arch.pqos_rmid > 0 ) > + { > + rc = -EEXIST; > + goto out; > + } Does this check really need to be inside the locked region? You're already protected against races by the domctl lock. > +void pqos_monitor_free_rmid(struct domain *d) > +{ > + unsigned int rmid; > + > + spin_lock(&pqosm->pqosm_lock); > + rmid = d->arch.pqos_rmid; > + /* We do not free system reserved "RMID=0" */ > + if ( rmid == 0 ) > + goto out; Similarly here. Jan