From: "Jan Beulich" Subject: Re: [PATCH v12 5/9] x86: dynamically attach/detach QoS monitoring service for a guest Date: Fri, 04 Jul 2014 13:06:12 +0100 Message-ID: <53B6B4D40200007800020B56@mail.emea.novell.com> References: <76a4654789627dcc38af0cad728da78d6e1facbe.1404462280.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: <76a4654789627dcc38af0cad728da78d6e1facbe.1404462280.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 04.07.14 at 10:34, wrote: > + case XEN_DOMCTL_pqos_monitor_op: > + if ( !pqos_monitor_enabled() ) > + { > + ret = -ENODEV; > + break; > + } > + > + switch ( domctl->u.pqos_monitor_op.cmd ) > + { > + case XEN_DOMCTL_PQOS_MONITOR_OP_ATTACH: > + ret = pqos_monitor_alloc_rmid(d); > + break; Wouldn't it make sense to return the allocated rmid from this operation? > +int pqos_monitor_alloc_rmid(struct domain *d) > +{ > + int rc = 0; > + unsigned int rmid; > + > + ASSERT(pqos_monitor_enabled()); > + > + if ( d->arch.pqos_rmid > 0 ) > + { > + rc = -EEXIST; > + return rc; "return -EEXIST" please (unless you're being paid my number of lines of code). > + } > + > + 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 ) > + { > + rmid = 0; > + rc = -EUSERS; > + } > + else > + pqosm->rmid_inuse++; > + > + d->arch.pqos_rmid = rmid; > + > + return rc; > +} > + > +void pqos_monitor_free_rmid(struct domain *d) > +{ > + unsigned int rmid; > + > + rmid = d->arch.pqos_rmid; > + /* We do not free system reserved "RMID=0" */ > + if ( rmid == 0 ) > + return; > + > + pqosm->rmid_to_dom[rmid] = DOMID_INVALID; > + d->arch.pqos_rmid = 0; > + pqosm->rmid_inuse--; > +} This pair of functions should get a brief comment added explaining why explicit locking here isn't needed. > --- a/xen/include/asm-x86/pqos.h > +++ b/xen/include/asm-x86/pqos.h > @@ -16,6 +16,7 @@ > #ifndef __ASM_PQOS_H__ > #define __ASM_PQOS_H__ > > +#include You'd get away with just xen/types.h here if you forward declared struct domain below. Jan