Re: [Xen-devel] [PATCH 3/4] tools: libxl: code preparation for MBM
On Mon, Jan 05, 2015 at 12:25:05PM +, Wei Liu wrote: On Tue, Dec 23, 2014 at 04:54:38PM +0800, Chao Peng wrote: [...] diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 3737c7e..f4534ec 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7845,12 +7845,13 @@ out: } #ifdef LIBXL_HAVE_PSR_CMT -static void psr_cmt_print_domain_cache_occupancy(libxl_dominfo *dominfo, +static void psr_cmt_print_domain_l3_info(libxl_dominfo *dominfo, +libxl_psr_cmt_type type, uint32_t nr_sockets) Indentation. { char *domain_name; uint32_t socketid; -uint32_t l3_cache_occupancy; +uint32_t data; if (!libxl_psr_cmt_domain_attached(ctx, dominfo-domid)) return; @@ -7860,15 +7861,21 @@ static void psr_cmt_print_domain_cache_occupancy(libxl_dominfo *dominfo, free(domain_name); for (socketid = 0; socketid nr_sockets; socketid++) { -if ( !libxl_psr_cmt_get_cache_occupancy(ctx, dominfo-domid, - socketid, l3_cache_occupancy) ) -printf(%13u KB, l3_cache_occupancy); +switch (type) { +case LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY: +if ( !libxl_psr_cmt_get_cache_occupancy(ctx, dominfo-domid, + socketid, data) ) +printf(%13u KB, data); +break; +default: +return; +} } printf(\n); } -static int psr_cmt_show_cache_occupancy(uint32_t domid) +static int psr_cmt_show_l3_info(libxl_psr_cmt_type type, uint32_t domid) { uint32_t i, socketid, nr_sockets, total_rmid; uint32_t l3_cache_size; @@ -7904,18 +7911,22 @@ static int psr_cmt_show_cache_occupancy(uint32_t domid) printf(%14s %d, Socket, socketid); printf(\n); -/* Total L3 cache size */ -printf(%-46s, Total L3 Cache Size); -for (socketid = 0; socketid nr_sockets; socketid++) { -rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, l3_cache_size); -if (rc 0) { -fprintf(stderr, Failed to get system l3 cache size for socket:%d\n, -socketid); -return -1; -} -printf(%13u KB, l3_cache_size); +if ( type == LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY ) { Coding style, no space after ( and before ). I missed this issue when I reviewed your previous patches. You can fix this style problem here while you're at it. Sure, I will fix them all. Thanks. Chao ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH 3/4] tools: libxl: code preparation for MBM
On Tue, Jan 06, 2015 at 05:46:12PM +0800, Chao Peng wrote: [...] Coding style, no space after ( and before ). I missed this issue when I reviewed your previous patches. You can fix this style problem here while you're at it. Sure, I will fix them all. If you plan to fix them all and there are many instances, please use preparatory patch -- don't mix them with functional changes. Wei. Thanks. Chao ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH 3/4] tools: libxl: code preparation for MBM
On Tue, Dec 23, 2014 at 04:54:38PM +0800, Chao Peng wrote: [...] diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 3737c7e..f4534ec 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7845,12 +7845,13 @@ out: } #ifdef LIBXL_HAVE_PSR_CMT -static void psr_cmt_print_domain_cache_occupancy(libxl_dominfo *dominfo, +static void psr_cmt_print_domain_l3_info(libxl_dominfo *dominfo, +libxl_psr_cmt_type type, uint32_t nr_sockets) Indentation. { char *domain_name; uint32_t socketid; -uint32_t l3_cache_occupancy; +uint32_t data; if (!libxl_psr_cmt_domain_attached(ctx, dominfo-domid)) return; @@ -7860,15 +7861,21 @@ static void psr_cmt_print_domain_cache_occupancy(libxl_dominfo *dominfo, free(domain_name); for (socketid = 0; socketid nr_sockets; socketid++) { -if ( !libxl_psr_cmt_get_cache_occupancy(ctx, dominfo-domid, - socketid, l3_cache_occupancy) ) -printf(%13u KB, l3_cache_occupancy); +switch (type) { +case LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY: +if ( !libxl_psr_cmt_get_cache_occupancy(ctx, dominfo-domid, + socketid, data) ) +printf(%13u KB, data); +break; +default: +return; +} } printf(\n); } -static int psr_cmt_show_cache_occupancy(uint32_t domid) +static int psr_cmt_show_l3_info(libxl_psr_cmt_type type, uint32_t domid) { uint32_t i, socketid, nr_sockets, total_rmid; uint32_t l3_cache_size; @@ -7904,18 +7911,22 @@ static int psr_cmt_show_cache_occupancy(uint32_t domid) printf(%14s %d, Socket, socketid); printf(\n); -/* Total L3 cache size */ -printf(%-46s, Total L3 Cache Size); -for (socketid = 0; socketid nr_sockets; socketid++) { -rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, l3_cache_size); -if (rc 0) { -fprintf(stderr, Failed to get system l3 cache size for socket:%d\n, -socketid); -return -1; -} -printf(%13u KB, l3_cache_size); +if ( type == LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY ) { Coding style, no space after ( and before ). I missed this issue when I reviewed your previous patches. You can fix this style problem here while you're at it. Wei. ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
[Xen-devel] [PATCH 3/4] tools: libxl: code preparation for MBM
Make some internal routines common so that total/local memory bandwidth monitoring in the next patch can make use of them. Signed-off-by: Chao Peng chao.p.p...@linux.intel.com --- tools/libxl/libxl_psr.c | 42 ++ tools/libxl/xl_cmdimpl.c | 51 -- 2 files changed, 56 insertions(+), 37 deletions(-) diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c index 0437465..21ad819 100644 --- a/tools/libxl/libxl_psr.c +++ b/tools/libxl/libxl_psr.c @@ -160,40 +160,48 @@ out: return rc; } -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; } 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, +XC_PSR_CMT_L3_OCCUPANCY, socketid, data); +if (rc 0) +goto out; + rc = xc_psr_cmt_get_l3_upscaling_factor(ctx-xch, upscaling_factor); if (rc 0) { LOGE(ERROR, failed to get L3 upscaling factor); @@ -201,8 +209,8 @@ int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, uint32_t domid, goto out; } -*l3_cache_occupancy = upscaling_factor * monitor_data / 1024; -rc = 0; +*l3_cache_occupancy = upscaling_factor * data / 1024; + out: GC_FREE; return rc; diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 3737c7e..f4534ec 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7845,12 +7845,13 @@ out: } #ifdef LIBXL_HAVE_PSR_CMT -static void psr_cmt_print_domain_cache_occupancy(libxl_dominfo *dominfo, +static void psr_cmt_print_domain_l3_info(libxl_dominfo *dominfo, +libxl_psr_cmt_type type, uint32_t nr_sockets) { char *domain_name; uint32_t socketid; -uint32_t l3_cache_occupancy; +uint32_t data; if (!libxl_psr_cmt_domain_attached(ctx, dominfo-domid)) return; @@ -7860,15 +7861,21 @@ static void psr_cmt_print_domain_cache_occupancy(libxl_dominfo *dominfo, free(domain_name); for (socketid = 0; socketid nr_sockets; socketid++) { -if ( !libxl_psr_cmt_get_cache_occupancy(ctx, dominfo-domid, - socketid, l3_cache_occupancy) ) -printf(%13u KB, l3_cache_occupancy); +switch (type) { +case LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY: +if ( !libxl_psr_cmt_get_cache_occupancy(ctx, dominfo-domid, + socketid, data) ) +printf(%13u KB, data); +break; +default: +return; +} } printf(\n); } -static int psr_cmt_show_cache_occupancy(uint32_t domid) +static int psr_cmt_show_l3_info(libxl_psr_cmt_type type, uint32_t domid) { uint32_t i, socketid, nr_sockets, total_rmid; uint32_t l3_cache_size; @@ -7904,18 +7911,22 @@ static int psr_cmt_show_cache_occupancy(uint32_t domid) printf(%14s %d, Socket, socketid); printf(\n); -/* Total L3 cache size */ -printf(%-46s, Total L3 Cache Size); -for (socketid = 0; socketid nr_sockets; socketid++) { -rc = libxl_psr_cmt_get_l3_cache_size(ctx, socketid, l3_cache_size); -if (rc 0) { -fprintf(stderr, Failed to get system l3 cache size for socket:%d\n, -socketid); -return -1; -} -printf(%13u KB, l3_cache_size); +if ( type == LIBXL_PSR_CMT_TYPE_CACHE_OCCUPANCY ) { +/* Total L3 cache size */ +