From: Wei Liu Subject: Re: [PATCH v2 4/5] tools: code refactoring for MBM Date: Wed, 7 Jan 2015 12:15:21 +0000 Message-ID: <20150107121521.GL28680@zion.uk.xensource.com> References: <1420629125-17725-1-git-send-email-chao.p.peng@linux.intel.com> <1420629125-17725-5-git-send-email-chao.p.peng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1420629125-17725-5-git-send-email-chao.p.peng@linux.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: Chao Peng Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, JBeulich@suse.com, wei.liu2@citrix.com List-Id: xen-devel@lists.xenproject.org On Wed, Jan 07, 2015 at 07:12:04PM +0800, Chao Peng wrote: [...] > -int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, > - uint32_t domid, > - uint32_t socketid, > - uint32_t *l3_cache_occupancy) > +static int libxl__psr_cmt_get_l3_monitoring_data(libxl__gc *gc, > + uint32_t domid, > + xc_psr_cmt_type type, > + uint32_t socketid, > + uint64_t *data) > { > - GC_INIT(ctx); > - > unsigned int rmid; > - uint32_t upscaling_factor; > - uint64_t monitor_data; > int cpu, rc; > - xc_psr_cmt_type type; > > - rc = xc_psr_cmt_get_domain_rmid(ctx->xch, domid, &rmid); > + rc = xc_psr_cmt_get_domain_rmid(CTX->xch, domid, &rmid); > if (rc < 0 || rmid == 0) { > LOGE(ERROR, "fail to get the domain rmid, " > "or domain is not attached with platform QoS monitoring service"); > - rc = ERROR_FAIL; > - goto out; > + return ERROR_FAIL; Please retain the "goto out" idiom if possible. > } > > cpu = libxl__pick_socket_cpu(gc, socketid); > if (cpu < 0) { > LOGE(ERROR, "failed to get socket cpu"); > - rc = ERROR_FAIL; > - goto out; > + return ERROR_FAIL; > } > > - type = XC_PSR_CMT_L3_OCCUPANCY; > - rc = xc_psr_cmt_get_data(ctx->xch, rmid, cpu, type, &monitor_data); > + rc = xc_psr_cmt_get_data(CTX->xch, rmid, cpu, type, data); > if (rc < 0) { > LOGE(ERROR, "failed to get monitoring data"); > - rc = ERROR_FAIL; > - goto out; > + return ERROR_FAIL; > } > > + return rc; > +} > + > +int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, > + uint32_t domid, > + uint32_t socketid, > + uint32_t *l3_cache_occupancy) > +{ > + GC_INIT(ctx); > + uint64_t data; > + uint32_t upscaling_factor; > + int rc; > + > + rc= libxl__psr_cmt_get_l3_monitoring_data(gc, domid, "rc =" Wei.