[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 4/5] tools: code refactoring for MBM



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.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.