enable Memory Bandwidth Monitoring (MBM) for VMs
v9 cover enable Memory Bandwidth Monitoring (MBM) for VMs
Changes from v8:
* Merge event mask patch to MBM enabling patch;
* Address comments from Ian Campbell(Detail in patch itself).
Changes from v7:
* Make obfuscating more complex as Jan suggested.
* Minor adjustment for commit message.
Changes from v6:
* Obfuscate the read value of MSR_IA32_TSC by adding a booting random;
* Minor coding style/comments adjustment;
Changes from v5:
* Remove common IRQ disable flag but instead disable IRQ when other MSR read followed by MSR_IA32_TSC read;
* Add comments for special handle for MSR_IA32_TSC;
Changes from v4:
* Make the counter read and timestamp read atomic by disable IRQ;
* Treat MSR_IA32_TSC as a special case and return NOW() for read path;
* Add MBM description in xl command line.
Changes from v3:
* Get timestamp information from host along with the monitoring counter; This is required for counter overlow detection.
* Address comments from Wei on the last patch.
Changes from v2:
* Remove the usage of "static" to cache data in xc;
NOTE: Other places that already existed before are not touched due to
the needs for API change. Will fix in separate patch if desirable.
* Coding style;
Changes from v1:
* Move event type check from xc to xl;
* Add retry capability for MBM sampling;
* Fix Coding style/docs;
Intel Memory Bandwidth Monitoring(MBM) is a new hardware feature which builds on the CMT infrastructure to allow monitoring of system memory bandwidth. Event codes are provided to monitor both "total" and "local" bandwidth, meaning bandwidth over QPI and other external links can be monitored.
For XEN, MBM is used to monitor memory bandwidth for VMs. Due to its dependency on CMT, the software also makes use of most of CMT codes. Actually, besides introducing two additional events and some cpuid feature bits, there are no extra changes compared to cache occupancy monitoring in CMT. Due to this, CMT should be enabled first to use this feature.
For interface changes, the patch serial introduces a new command "XEN_SYSCTL_PSR_CMT_get_l3_event_mask" which exposes MBM feature capability to user space and modified "resource_op" to support reading host system time together with the monitored counter.
On the tool stack side, two additional options introduced for "xl psr-cmt-show":
total_mem_bandwidth: Show total memory bandwidth local_mem_bandwidth: Show local memory bandwidth
The usage flow keeps the same with CMT.
Chao Peng (3):
tools: correct coding style for psr
tools: code refactoring for MBM
tools, docs: add total/local memory bandwith monitoring
docs/man/xl.pod.1 | 11 +++- docs/misc/xen-command-line.markdown | 3 + tools/libxc/include/xenctrl.h | 14 +++-- tools/libxc/xc_msr_x86.h | 1 + tools/libxc/xc_psr.c | 76 +++++++++++++++++------ tools/libxl/libxl.h | 28 +++++++-- tools/libxl/libxl_psr.c | 81 +++++++++++++++++++++---- tools/libxl/libxl_types.idl | 2 + tools/libxl/xl_cmdimpl.c | 118 ++++++++++++++++++++++++++++++------ tools/libxl/xl_cmdtable.c | 4 +- 10 files changed, 280 insertions(+), 58 deletions(-)
Signature · 1 line
1.9.1
PATCH v9 1/3 tools: correct coding style for psr
- space: remove space after '(' or before ')' in 'if' condition;
- indention: align function definition/call arguments;
--- tools/libxc/include/xenctrl.h | 10 +++++----- tools/libxc/xc_psr.c | 10 +++++----- tools/libxl/libxl.h | 11 +++++++---- tools/libxl/libxl_psr.c | 11 +++++++---- tools/libxl/xl_cmdimpl.c | 11 ++++++----- 5 files changed, 30 insertions(+), 23 deletions(-)
tools/libxc/include/xenctrl.h +5 -5
@@ -2693,14 +2693,14 @@ typedef enum xc_psr_cmt_type xc_psr_cmt_type;int xc_psr_cmt_attach (xc_interface *xch,uint32_t domid);int xc_psr_cmt_detach (xc_interface *xch,uint32_t domid);int xc_psr_cmt_get_domain_rmid (xc_interface *xch,uint32_t domid, -uint32_t *rmid); +uint32_t *rmid);int xc_psr_cmt_get_total_rmid (xc_interface *xch,uint32_t *total_rmid);int xc_psr_cmt_get_l3_upscaling_factor (xc_interface *xch, -uint32_t *upscaling_factor); +uint32_t *upscaling_factor);int xc_psr_cmt_get_l3_cache_size (xc_interface *xch,uint32_t cpu, -uint32_t *l3_cache_size); -int xc_psr_cmt_get_data (xc_interface *xch,uint32_t rmid, -uint32_t cpu,uint32_t psr_cmt_type,uint64_t *monitor_data); +uint32_t *l3_cache_size); +int xc_psr_cmt_get_data (xc_interface *xch,uint32_t rmid,uint32_t cpu, +uint32_t psr_cmt_type,uint64_t *monitor_data);int xc_psr_cmt_enabled (xc_interface *xch);#endif
tools/libxc/xc_psr.c +5 -5
@@ -47,7 +47,7 @@ int xc_psr_cmt_detach(xc_interface *xch, uint32_t domid) }int xc_psr_cmt_get_domain_rmid (xc_interface *xch,uint32_t domid, -uint32_t *rmid) +uint32_t *rmid) {int rc;DECLARE_DOMCTL ;
@@ -88,7 +88,7 @@ int xc_psr_cmt_get_total_rmid(xc_interface *xch, uint32_t *total_rmid) }int xc_psr_cmt_get_l3_upscaling_factor (xc_interface *xch, -uint32_t *upscaling_factor) +uint32_t *upscaling_factor) {static int val =0 ;int rc;
@@ -113,7 +113,7 @@ int xc_psr_cmt_get_l3_upscaling_factor(xc_interface *xch, }int xc_psr_cmt_get_l3_cache_size (xc_interface *xch,uint32_t cpu, -uint32_t *l3_cache_size) +uint32_t *l3_cache_size) {static int val =0 ;int rc;
@@ -138,8 +138,8 @@ int xc_psr_cmt_get_l3_cache_size(xc_interface *xch, uint32_t cpu,return rc; } -int xc_psr_cmt_get_data (xc_interface *xch,uint32_t rmid, -uint32_t cpu,xc_psr_cmt_type type,uint64_t *monitor_data) +int xc_psr_cmt_get_data (xc_interface *xch,uint32_t rmid,uint32_t cpu, +xc_psr_cmt_type type,uint64_t *monitor_data) {xc_resource_op_t op;xc_resource_entry_t entries[2 ];
tools/libxl/libxl.h +7 -4
@@ -1454,10 +1454,13 @@ int libxl_psr_cmt_detach(libxl_ctx *ctx, uint32_t domid);int libxl_psr_cmt_domain_attached (libxl_ctx *ctx,uint32_t domid);int libxl_psr_cmt_enabled (libxl_ctx *ctx);int libxl_psr_cmt_get_total_rmid (libxl_ctx *ctx,uint32_t *total_rmid); -int libxl_psr_cmt_get_l3_cache_size (libxl_ctx *ctx,uint32_t socketid, -uint32_t *l3_cache_size); -int libxl_psr_cmt_get_cache_occupancy (libxl_ctx *ctx,uint32_t domid, -uint32_t socketid,uint32_t *l3_cache_occupancy); +int libxl_psr_cmt_get_l3_cache_size (libxl_ctx *ctx, +uint32_t socketid, +uint32_t *l3_cache_size); +int libxl_psr_cmt_get_cache_occupancy (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +uint32_t *l3_cache_occupancy);#endif /* misc */
tools/libxl/libxl_psr.c +7 -4
@@ -135,8 +135,9 @@ int libxl_psr_cmt_get_total_rmid(libxl_ctx *ctx, uint32_t *total_rmid)return rc; } -int libxl_psr_cmt_get_l3_cache_size (libxl_ctx *ctx,uint32_t socketid, -uint32_t *l3_cache_size) +int libxl_psr_cmt_get_l3_cache_size (libxl_ctx *ctx, +uint32_t socketid, +uint32_t *l3_cache_size) {GC_INIT (ctx);
@@ -160,8 +161,10 @@ out:return rc; } -int libxl_psr_cmt_get_cache_occupancy (libxl_ctx *ctx,uint32_t domid, -uint32_t socketid,uint32_t *l3_cache_occupancy) +int libxl_psr_cmt_get_cache_occupancy (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +uint32_t *l3_cache_occupancy) {GC_INIT (ctx);
tools/libxl/xl_cmdimpl.c +6 -5
@@ -7808,7 +7808,7 @@ out:#ifdef LIBXL_HAVE_PSR_CMT static void psr_cmt_print_domain_cache_occupancy (libxl_dominfo *dominfo, -uint32_t nr_sockets) +uint32_t nr_sockets) {char *domain_name;uint32_t socketid;
@@ -7822,8 +7822,8 @@ 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) ) +if (!libxl_psr_cmt_get_cache_occupancy (ctx, dominfo->domid, socketid, + &l3_cache_occupancy))printf ("%13u KB" , l3_cache_occupancy); }
@@ -7871,8 +7871,9 @@ static int psr_cmt_show_cache_occupancy(uint32_t domid)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); +fprintf (stderr, +"Failed to get system l3 cache size for socket:%d\n" , + socketid);return -1 ; }printf ("%13u KB" , l3_cache_size);
Signature · 1 line
1.9.1
PATCH v9 2/3 tools: code refactoring for MBM
In reply to Chao PengMake some internal routines common so that total/local memory bandwidth monitoring in the next patch can make use of them.
--- tools/libxl/libxl_psr.c | 44 +++++++++++++++++++++++++++------------ tools/libxl/xl_cmdimpl.c | 54 +++++++++++++++++++++++++++++------------------- 2 files changed, 64 insertions(+), 34 deletions(-)
tools/libxl/libxl_psr.c +31 -13
@@ -161,20 +161,18 @@ 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_r) { -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" );
@@ -189,23 +187,43 @@ int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, goto out; } - 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, &monitor_data);if (rc <0 ) {LOGE (ERROR ,"failed to get monitoring data" ); rc =ERROR_FAIL ; goto out; } - rc =xc_psr_cmt_get_l3_upscaling_factor (ctx->xch, &upscaling_factor); + rc =xc_psr_cmt_get_l3_upscaling_factor (CTX ->xch, &upscaling_factor);if (rc <0 ) {LOGE (ERROR ,"failed to get L3 upscaling factor" ); rc =ERROR_FAIL ; goto out; } - *l3_cache_occupancy = upscaling_factor * monitor_data /1024 ; - rc =0 ; + *data_r = monitor_data * upscaling_factor; + +out: +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; +int rc; + + rc =libxl__psr_cmt_get_l3_monitoring_data (gc, domid, +XC_PSR_CMT_L3_OCCUPANCY , + socketid, &data); +if (rc <0 ) + goto out; + + *l3_cache_occupancy = data /1024 ; + out:GC_FREE ;return rc;
tools/libxl/xl_cmdimpl.c +33 -21
96 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v9 3/3 tools, docs: add total/local memory bandwith monitoring
In reply to Chao PengAdd Memory Bandwidth Monitoring(MBM) for VMs. Two types of monitoring are supported: total and local memory bandwidth monitoring. To use it, CMT should be enabled in hypervisor.
---
Changes in v9:
1. Refactor code in xc_psr_cmt_get_data.
2. Move bandwidth calculation(sleep) from libxl to xl.
3. Broadcast feature with LIBXL_HAVE_PSR_MBM.
4. Check event mask with libxl_psr_cmt_type_supported.
5. Coding style/Document fix.
Changes in v6:
1. Remove DISABLE_IRQ flag as hypervisor disable IRQ for MSR_IA32_TSC implicitly.
Changes in v5:
1. Add MBM description in xen command line.
2. Use the tsc from hypervisor directly which is already ns.
3. Call resource_op with DISABLE_IRQ flag.
Changes in v4:
1. Get timestamp from hypervisor and use that for bandwidth calculation.
2. Minor document and coding style fix.
--- docs/man/xl.pod.1 | 11 +++++- docs/misc/xen-command-line.markdown | 3 ++ tools/libxc/include/xenctrl.h | 6 +++- tools/libxc/xc_msr_x86.h | 1 + tools/libxc/xc_psr.c | 68 ++++++++++++++++++++++++++++++------- tools/libxl/libxl.h | 17 ++++++++++ tools/libxl/libxl_psr.c | 44 ++++++++++++++++++++++-- tools/libxl/libxl_types.idl | 2 ++ tools/libxl/xl_cmdimpl.c | 67 ++++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 4 ++- 10 files changed, 204 insertions(+), 19 deletions(-)
docs/man/xl.pod.1 +10 -1
@@ -1461,6 +1461,13 @@ is domain level. To monitor a specific domain, just attach the domain id with the monitoring service. When the domain doesn't need to be monitored any more, detach the domain id from the monitoring service. +Intel Broadwell and later server platforms also offer total/local memory +bandwidth monitoring. Xen supports per-domain monitoring for these two +additional monitoring types. Both memory bandwidth monitoring and L3 cache +occupancy monitoring share the same set of underlying monitoring service. Once +a domain is attached to the monitoring service, monitoring data can be showed +for any of these monitoring types. + =over 4 =item B<psr-cmt-attach> [I<domain-id>]
@@ -1475,7 +1482,9 @@ detach: Detach the platform shared resource monitoring service from a domain. Show monitoring data for a certain domain or all domains. Current supported monitor types are: - - "cache-occupancy": showing the L3 cache occupancy. + - "cache-occupancy": showing the L3 cache occupancy(KB). + - "total-mem-bandwidth": showing the total memory bandwidth(KB/s). + - "local-mem-bandwidth": showing the local memory bandwidth(KB/s). =back
docs/misc/xen-command-line.markdown +3 -0
@@ -1097,6 +1097,9 @@ The following resources are available: L3 cache occupancy. * `cmt` instructs Xen to enable/disable Cache Monitoring Technology. * `rmid_max` indicates the max value for rmid. +* Memory Bandwidth Monitoring (Broadwell and later). Information regarding the + total/local memory bandwidth. Follow the same options with Cache Monitoring + Technology. ### reboot > `= t[riple] | k[bd] | a[cpi] | p[ci] | n[o] [, [w]arm | [c]old]`
tools/libxc/include/xenctrl.h +5 -1
@@ -2688,6 +2688,8 @@ int xc_resource_op(xc_interface *xch, uint32_t nr_ops, xc_resource_op_t *ops);#if defined(__i386__) || defined(__x86_64__)enum xc_psr_cmt_type {XC_PSR_CMT_L3_OCCUPANCY , +XC_PSR_CMT_TOTAL_MEM_BANDWIDTH , +XC_PSR_CMT_LOCAL_MEM_BANDWIDTH , };typedef enum xc_psr_cmt_type xc_psr_cmt_type ;int xc_psr_cmt_attach (xc_interface *xch,uint32_t domid);
@@ -2697,10 +2699,12 @@ int xc_psr_cmt_get_domain_rmid(xc_interface *xch, uint32_t domid,int xc_psr_cmt_get_total_rmid (xc_interface *xch,uint32_t *total_rmid);int xc_psr_cmt_get_l3_upscaling_factor (xc_interface *xch,uint32_t *upscaling_factor); +int xc_psr_cmt_get_l3_event_mask (xc_interface *xch,uint32_t *event_mask);int xc_psr_cmt_get_l3_cache_size (xc_interface *xch,uint32_t cpu,uint32_t *l3_cache_size);int xc_psr_cmt_get_data (xc_interface *xch,uint32_t rmid,uint32_t cpu, -uint32_t psr_cmt_type,uint64_t *monitor_data); +uint32_t psr_cmt_type,uint64_t *monitor_data, +uint64_t *tsc);int xc_psr_cmt_enabled (xc_interface *xch);#endif
tools/libxc/xc_msr_x86.h +1 -0
@@ -20,6 +20,7 @@#ifndef XC_MSR_X86_H #define XC_MSR_X86_H +#define MSR_IA32_TSC 0x00000010#define MSR_IA32_CMT_EVTSEL 0x00000c8d#define MSR_IA32_CMT_CTR 0x00000c8e
tools/libxc/xc_psr.c +55 -13
111 lines not on this page · raw message
tools/libxl/libxl.h +17 -0
@@ -690,6 +690,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src);* If this is defined, the Cache Monitoring Technology feature is supported. */ #define LIBXL_HAVE_PSR_CMT 1 + +/* +* LIBXL_HAVE_PSR_MBM +* +* If this is defined, the Memory Bandwidth Monitoring feature is supported. +*/ +#define LIBXL_HAVE_PSR_MBM 1#endif typedef char **libxl_string_list ;
@@ -1463,6 +1470,16 @@ int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, uint32_t *l3_cache_occupancy);#endif +#ifdef LIBXL_HAVE_PSR_MBM +int libxl_psr_cmt_type_supported (libxl_ctx *ctx,libxl_psr_cmt_type type); +int libxl_psr_cmt_get_mem_bandwidth_sample (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +bool total, +uint64_t *sample_r, +uint64_t *tsc_r); +#endif +/* misc */ /* Each of these sets or clears the flag according to whether the
tools/libxl/libxl_psr.c +41 -3
72 lines not on this page · raw message
tools/libxl/libxl_types.idl +2 -0
@@ -694,4 +694,6 @@ libxl_event = Struct("event",[ libxl_psr_cmt_type = Enumeration("psr_cmt_type", [ (1, "CACHE_OCCUPANCY"), + (2, "TOTAL_MEM_BANDWIDTH"), + (3, "LOCAL_MEM_BANDWIDTH"), ])
tools/libxl/xl_cmdimpl.c +67 -0
97 lines not on this page · raw message
tools/libxl/xl_cmdtable.c +3 -1
@@ -538,7 +538,9 @@ struct cmd_spec cmd_table[] = {"Show Cache Monitoring Technology information" ,"<PSR-CMT-Type> <Domain>" ,"Available monitor types:\n" - "\"cache_occupancy\": Show L3 cache occupancy\n", +"\"cache_occupancy\": Show L3 cache occupancy(KB)\n" +"\"total_mem_bandwidth\": Show total memory bandwidth(KB/s)\n" + "\"local_mem_bandwidth\": Show local memory bandwidth(KB/s)\n", }, #endif };
Signature · 1 line
1.9.1
Quoted 3 lines · Chao Peng
Changes from v8:
* Merge event mask patch to MBM enabling patch;
* Address comments from Ian Campbell(Detail in patch itself).
Any comments on this revision?
Thanks,
Chao
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 09:39, <[email protected]> wrote:
Quoted 3 lines · Chao Peng
Changes from v8:
* Merge event mask patch to MBM enabling patch;
* Address comments from Ian Campbell(Detail in patch itself).Any comments on this revision?
Please be a little more patient before pinging - you only sent this 2 days ago. Please allow for at least a week.
Jan
Quoted 10 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 09:39, <[email protected]> wrote:
Quoted 3 lines · Chao Peng
Changes from v8:
* Merge event mask patch to MBM enabling patch;
* Address comments from Ian Campbell(Detail in patch itself).Any comments on this revision?
Please be a little more patient before pinging - you only sent this 2 days ago. Please allow for at least a week.
Not urgent :) . Please ignore the noise.
Quoted 4 lines · Chao Peng
Changes from v8:
* Merge event mask patch to MBM enabling patch;
* Address comments from Ian Campbell(Detail in patch itself).
I know you guys are still busy but I'd raise it again, to make sure this revision is not forgotten.
Please still take it easy. Review when you are free is greatly appreciated.
Thanks,
Chao
Re: [PATCH v9 3/3] tools, docs: add total/local memory bandwith monitoring
In reply to Chao PengQuoted 8 lines · Chao Peng
Add Memory Bandwidth Monitoring(MBM) for VMs. Two types of monitoring are supported: total and local memory bandwidth monitoring. To use it, CMT should be enabled in hypervisor.
Signed-off-by Chao Peng <[email protected]>---
Changes in v9:
1. Refactor code inxc_psr_cmt_get_data.
Preferably this should be in a separate patch. With the line "No functional change" in commit message when appropriate.
[...]
Quoted 14 lines
*/
#defineLIBXL_HAVE_PSR_CMT1tools/libxl/libxl.h +7
-0+ +/* +* LIBXL_HAVE_PSR_MBM +* +* If this is defined, the Memory Bandwidth Monitoring feature is supported. +*/ +#define LIBXL_HAVE_PSR_MBM 1#endif typedef char **libxl_string_list ;@@ -1463,6 +1470,16 @@ int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, uint32_t *l3_cache_occupancy);
tools/libxl/libxl.h int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, · line 1480
Quoted 10 lines
tools/libxl/libxl.h +8
-0#endif +#ifdef LIBXL_HAVE_PSR_MBM +int libxl_psr_cmt_type_supported (libxl_ctx *ctx,libxl_psr_cmt_type type); +int libxl_psr_cmt_get_mem_bandwidth_sample (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +bool total, +uint64_t *sample_r, +uint64_t *tsc_r);
Should the interface be only limited to socket level? Do you (Intel) has plan to provide bandwidth sampling on finer grain level (say, core level)?
I also assume that you will never have third type of memory bandwidth? I.e. do we need to change boolean total to a enum?
Wei.
Re: [PATCH v9 3/3] tools, docs: add total/local memory bandwith monitoring
Quoted 13 lines · Wei Liu
tools/libxl/libxl.h int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, · line 1480
Quoted 8 lines · Chao Peng
tools/libxl/libxl.h +8
-0+#ifdef LIBXL_HAVE_PSR_MBM +int libxl_psr_cmt_type_supported (libxl_ctx *ctx,libxl_psr_cmt_type type); +int libxl_psr_cmt_get_mem_bandwidth_sample (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +bool total, +uint64_t *sample_r, +uint64_t *tsc_r);Should the interface be only limited to socket level? Do you (Intel) has plan to provide bandwidth sampling on finer grain level (say, core level)?
If we assume not then obviously some h/w designer will implement it ;-)
The existing libxl_psr_cmt_get_l3_cache_size has uint32_t socketid though, so we may as well do the same here and fixup everything at once if it ever happens.
Quoted 2 lines
I also assume that you will never have third type of memory bandwidth? I.e. do we need to change boolean total to a enum?
There is already an enum, but some of the values it has don't really fit this interface (the "l3_cache_size" isn't really a stat which needs sampling), cf my wonder in response to v8 "if wedging all of these logically unrelated statistics into an umbrella psr interface at the libxl level makes sense."
Perhaps just call this interface psr_cmt_get_sample, pass it the enum and always return a tsc? Then other types of stats sampling would fit in the future, hopefully.
No reason to exclude l3_cache_size from it even if it is a bit pointless to use this interface for it instead of the dedicated one.
Ian.
Re: [PATCH v9 3/3] tools, docs: add total/local memory bandwith monitoring
Quoted 15 lines · Ian Campbell
Quoted 13 lines · Wei Liu
tools/libxl/libxl.h int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, · line 1480
Quoted 8 lines · Chao Peng
tools/libxl/libxl.h +8
-0+#ifdef LIBXL_HAVE_PSR_MBM +int libxl_psr_cmt_type_supported (libxl_ctx *ctx,libxl_psr_cmt_type type); +int libxl_psr_cmt_get_mem_bandwidth_sample (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +bool total, +uint64_t *sample_r, +uint64_t *tsc_r);Should the interface be only limited to socket level? Do you (Intel) has plan to provide bandwidth sampling on finer grain level (say, core level)?
Quoted 5 lines
If we assume not then obviously some h/w designer will implement it ;-)
The existing
libxl_psr_cmt_get_l3_cache_sizehasuint32_tsocketid though, so we may as well do the same here and fixup everything at once if it ever happens.
I didn't see any implementation for core-level in the near future from Intel side but perhaps it's good idea to consider it, at least for long time. Define the following types achieve this purpose?
libxl_psr_scope_type = Enumeration("psr_scope_type", [
(1, "SOCKET"),
])libxl_psr_scope = Struct("psr_scope", [
("u", KeyedUnion(None, libxl_psr_scope_type, "type",
("socket", integer),
])),], dir=DIR_OUT)
Quoted 10 lines
Quoted 3 lines
I also assume that you will never have third type of memory bandwidth? I.e. do we need to change boolean total to a enum?
There is already an enum, but some of the values it has don't really fit this interface (the "
l3_cache_size" isn't really a stat which needs sampling), cf my wonder in response to v8 "if wedging all of these logically unrelated statistics into an umbrella psr interface at the libxl level makes sense."
Quoted 3 lines
Perhaps just call this interface
psr_cmt_get_sample, pass it the enum and always return a tsc? Then other types of stats sampling would fit in the future, hopefully.
For l3_cache_size the tsc will not actually be returned if tsc is NULL. For the time being, the interface sounds enough for both cache occupancy and memory bandwidth.
The question is that if I adopt this solution will I remove the original dedicated l3_cache_size interface? Most concern is api compatibility but I think it has never been used outside of xl.
Chao
Quoted 5 lines
No reason to exclude
l3_cache_sizefrom it even if it is a bit pointless to use this interface for it instead of the dedicated one.Ian.
Re: [PATCH v9 3/3] tools, docs: add total/local memory bandwith monitoring
Quoted 27 lines · Chao Peng
Quoted 15 lines · Ian Campbell
Quoted 13 lines · Wei Liu
tools/libxl/libxl.h int libxl_psr_cmt_get_cache_occupancy(libxl_ctx *ctx, · line 1480
Quoted 8 lines · Chao Peng
tools/libxl/libxl.h +8
-0+#ifdef LIBXL_HAVE_PSR_MBM +int libxl_psr_cmt_type_supported (libxl_ctx *ctx,libxl_psr_cmt_type type); +int libxl_psr_cmt_get_mem_bandwidth_sample (libxl_ctx *ctx, +uint32_t domid, +uint32_t socketid, +bool total, +uint64_t *sample_r, +uint64_t *tsc_r);Should the interface be only limited to socket level? Do you (Intel) has plan to provide bandwidth sampling on finer grain level (say, core level)?
Quoted 5 lines
If we assume not then obviously some h/w designer will implement it ;-)
The existing
libxl_psr_cmt_get_l3_cache_sizehasuint32_tsocketid though, so we may as well do the same here and fixup everything at once if it ever happens.I didn't see any implementation for core-level in the near future from Intel side but perhaps it's good idea to consider it, at least for long time. Define the following types achieve this purpose?
libxl_psr_scope_type= Enumeration("psr_scope_type", [
Quoted 8 lines
(1, "SOCKET"), ])
libxl_psr_scope= Struct("psr_scope", [("u", KeyedUnion(None, libxl_psr_scope_type, "type", ("socket", integer), ])),], dir=DIR_OUT)
That's probably overkill. Simply expanding the socketid parameter to encode socket/cores (perhaps widening the type) would suffice, wouldn't it?
All that can wait until there is an actual sub-socket feature to actually support.
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
I also assume that you will never have third type of memory bandwidth? I.e. do we need to change boolean total to a enum?
There is already an enum, but some of the values it has don't really fit this interface (the "
l3_cache_size" isn't really a stat which needs sampling), cf my wonder in response to v8 "if wedging all of these logically unrelated statistics into an umbrella psr interface at the libxl level makes sense."
Quoted 5 lines
Quoted 3 lines
Perhaps just call this interface
psr_cmt_get_sample, pass it the enum and always return a tsc? Then other types of stats sampling would fit in the future, hopefully.For
l3_cache_sizethe tsc will not actually be returned if tsc is NULL.
But it will be if tsc != NULL, right?
Quoted 6 lines
For the time being, the interface sounds enough for both cache occupancy and memory bandwidth.
The question is that if I adopt this solution will I remove the original dedicated
l3_cache_sizeinterface? Most concern is api compatibility but I think it has never been used outside of xl.
We can leave the old interface in place (perhaps as a wrapper around the new one) as a deprecated one for compatibility, that's fine.
If we are really sure it is unused (i.e. libvirt never used it) then we could consider removing it, there's an extent to which ABI compatibility is a bit like a tree falling in the woods...
Ian.