| 1 |
# Intel Platform Shared Resource Monitoring/Control in xl |
| 2 |
|
| 3 |
This document introduces Intel Platform Shared Resource Monitoring/Control |
| 4 |
technologies, their basic concepts and the xl interfaces. |
| 5 |
|
| 6 |
## Cache Monitoring Technology (CMT) |
| 7 |
|
| 8 |
Cache Monitoring Technology (CMT) is a new feature available on Intel Haswell |
| 9 |
and later server platforms that allows an OS or Hypervisor/VMM to determine |
| 10 |
the usage of cache (currently only L3 cache supported) by applications running |
| 11 |
on the platform. A Resource Monitoring ID (RMID) is the abstraction of the |
| 12 |
application(s) that will be monitored for its cache usage. The CMT hardware |
| 13 |
tracks cache utilization of memory accesses according to the RMID and reports |
| 14 |
monitored data via a counter register. |
| 15 |
|
| 16 |
For more detailed information please refer to Intel SDM chapter |
| 17 |
"Platform Shared Resource Monitoring: Cache Monitoring Technology". |
| 18 |
|
| 19 |
In Xen's implementation, each domain in the system can be assigned a RMID |
| 20 |
independently, while RMID=0 is reserved for monitoring domains that don't |
| 21 |
have CMT service attached. RMID is opaque for xl/libxl and is only used in |
| 22 |
hypervisor. |
| 23 |
|
| 24 |
### xl interfaces |
| 25 |
|
| 26 |
A domain is assigned a RMID implicitly by attaching it to CMT service: |
| 27 |
|
| 28 |
`xl psr-cmt-attach <domid>` |
| 29 |
|
| 30 |
After that, cache usage for the domain can be shown by: |
| 31 |
|
| 32 |
`xl psr-cmt-show cache-occupancy <domid>` |
| 33 |
|
| 34 |
Once monitoring is not needed any more, the domain can be detached from the |
| 35 |
CMT service by: |
| 36 |
|
| 37 |
`xl psr-cmt-detach <domid>` |
| 38 |
|
| 39 |
An attach may fail because of no free RMID available. In such case unused |
| 40 |
RMID(s) can be freed by detaching corresponding domains from CMT service. |
| 41 |
|
| 42 |
Maximum RMID and supported monitor types in the system can be obtained by: |
| 43 |
|
| 44 |
`xl psr-hwinfo --cmt` |
| 45 |
|
| 46 |
## Memory Bandwidth Monitoring (MBM) |
| 47 |
|
| 48 |
Memory Bandwidth Monitoring(MBM) is a new hardware feature available on Intel |
| 49 |
Broadwell and later server platforms which builds on the CMT infrastructure to |
| 50 |
allow monitoring of system memory bandwidth. It introduces two new monitoring |
| 51 |
event type to monitor system total/local memory bandwidth. The same RMID can |
| 52 |
be used to monitor both cache usage and memory bandwidth at the same time. |
| 53 |
|
| 54 |
For more detailed information please refer to Intel SDM chapter |
| 55 |
"Overview of Cache Monitoring Technology and Memory Bandwidth Monitoring". |
| 56 |
|
| 57 |
In Xen's implementation, MBM shares the same set of underlying monitoring |
| 58 |
service with CMT and can be used to monitor memory bandwidth on a per domain |
| 59 |
basis. |
| 60 |
|
| 61 |
The xl interfaces are the same with that of CMT. The difference is the |
| 62 |
monitor type is corresponding memory monitoring type (local-mem-bandwidth/ |
| 63 |
total-mem-bandwidth instead of cache-occupancy). E.g. after a `xl psr-cmt-attach`: |
| 64 |
|
| 65 |
`xl psr-cmt-show local-mem-bandwidth <domid>` |
| 66 |
|
| 67 |
`xl psr-cmt-show total-mem-bandwidth <domid>` |
| 68 |
|
| 69 |
## Cache Allocation Technology (CAT) |
| 70 |
|
| 71 |
Cache Allocation Technology (CAT) is a new feature available on Intel |
| 72 |
Broadwell and later server platforms that allows an OS or Hypervisor/VMM to |
| 73 |
partition cache allocation (i.e. L3/L2 cache) based on application priority or |
| 74 |
Class of Service (COS). Each COS is configured using capacity bitmasks (CBM) |
| 75 |
which represent cache capacity and indicate the degree of overlap and |
| 76 |
isolation between classes. System cache resource is divided into numbers of |
| 77 |
minimum portions which is then made up into subset for cache partition. Each |
| 78 |
portion corresponds to a bit in CBM and the set bit represents the |
| 79 |
corresponding cache portion is available. |
| 80 |
|
| 81 |
For example, assuming a system with 8 portions and 3 domains: |
| 82 |
|
| 83 |
* A CBM of 0xff for every domain means each domain can access the whole cache. |
| 84 |
This is the default. |
| 85 |
|
| 86 |
* Giving one domain a CBM of 0x0f and the other two domain's 0xf0 means that |
| 87 |
the first domain gets exclusive access to half of the cache (half of the |
| 88 |
portions) and the other two will share the other half. |
| 89 |
|
| 90 |
* Giving one domain a CBM of 0x0f, one 0x30 and the last 0xc0 would give the |
| 91 |
first domain exclusive access to half the cache, and the other two exclusive |
| 92 |
access to one quarter each. |
| 93 |
|
| 94 |
For more detailed information please refer to Intel SDM chapter |
| 95 |
"Platform Shared Resource Control: Cache Allocation Technology". |
| 96 |
|
| 97 |
In Xen's implementation, CBM can be configured with libxl/xl interfaces but |
| 98 |
COS is maintained in hypervisor only. The cache partition granularity is per |
| 99 |
domain, each domain has COS=0 assigned by default, the corresponding CBM is |
| 100 |
all-ones, which means all the cache resource can be used by default. |
| 101 |
|
| 102 |
### xl interfaces |
| 103 |
|
| 104 |
System CAT information such as maximum COS and CBM length can be obtained by: |
| 105 |
|
| 106 |
`xl psr-hwinfo --cat` |
| 107 |
|
| 108 |
The simplest way to change a domain's CBM from its default is running: |
| 109 |
|
| 110 |
`xl psr-cat-set [OPTIONS] <domid> <cbm>` |
| 111 |
|
| 112 |
where cbm is a number to represent the corresponding cache subset can be used. |
| 113 |
A cbm is valid only when: |
| 114 |
|
| 115 |
* Set bits only exist in the range of [0, cbm_len), where cbm_len can be |
| 116 |
obtained with `xl psr-hwinfo --cat`. |
| 117 |
* All the set bits are contiguous. |
| 118 |
|
| 119 |
In a multi-socket system, the same cbm will be set on each socket by default. |
| 120 |
Per socket cbm can be specified with the `--socket SOCKET` option. |
| 121 |
|
| 122 |
In different systems, the different cache level is supported, e.g. L3 cache or |
| 123 |
L2 cache. Per cache level cbm can be specified with the `--level LEVEL` option. |
| 124 |
|
| 125 |
Setting the CBM may not be successful if insufficient COS is available. In |
| 126 |
such case unused COS(es) may be freed by setting CBM of all related domains to |
| 127 |
its default value(all-ones). |
| 128 |
|
| 129 |
Per domain CBM settings can be shown by: |
| 130 |
|
| 131 |
`xl psr-cat-show [OPTIONS] <domid>` |
| 132 |
|
| 133 |
In different systems, the different cache level is supported, e.g. L3 cache or |
| 134 |
L2 cache. Per cache level cbm can be specified with the `--level LEVEL` option. |
| 135 |
|
| 136 |
## Code and Data Prioritization (CDP) |
| 137 |
|
| 138 |
Code and Data Prioritization (CDP) Technology is an extension of CAT, which |
| 139 |
is available on Intel Broadwell and later server platforms. CDP enables |
| 140 |
isolation and separate prioritization of code and data fetches to the L3 |
| 141 |
cache in a software configurable manner, which can enable workload |
| 142 |
prioritization and tuning of cache capacity to the characteristics of the |
| 143 |
workload. CDP extends Cache Allocation Technology (CAT) by providing |
| 144 |
separate code and data masks per Class of Service (COS). |
| 145 |
|
| 146 |
CDP can be enabled by adding `psr=cdp` to Xen command line. |
| 147 |
|
| 148 |
When CDP is enabled, |
| 149 |
|
| 150 |
* the CAT masks are re-mapped into interleaved pairs of masks for data or |
| 151 |
code fetches. |
| 152 |
|
| 153 |
* the range of COS for CAT is re-indexed, with the lower-half of the COS |
| 154 |
range available for CDP. |
| 155 |
|
| 156 |
CDP allows the OS or Hypervisor to partition cache allocation in a more |
| 157 |
fine-grained manner. Code cache and data cache can be specified independently. |
| 158 |
With CDP enabled, one COS corresponds to two CBMs (code CBM & data CBM), |
| 159 |
since the sum of CBMs is fixed, that means the number of available COSes |
| 160 |
will reduce by half when CDP is on. |
| 161 |
|
| 162 |
For more detailed information please refer to Intel SDM chapter |
| 163 |
"Platform Shared Resource Control: Cache Allocation Technology". |
| 164 |
|
| 165 |
The xl interfaces are the same with that of CAT. The difference is that |
| 166 |
CBM type can be passed as option to set code CBM or data CBM. |
| 167 |
|
| 168 |
When CDP is enabled, `-c` or `--code` option is available to set code CBM |
| 169 |
for the domain. |
| 170 |
|
| 171 |
When CDP is enabled, `-d` or `--data` option is available to set data CBM |
| 172 |
for the domain. |
| 173 |
|
| 174 |
If neither `-c` nor `-d` option is specified when CDP is on, the same code |
| 175 |
CBM and data CBM will be set for the domain. Passing both `-c` and `-d` |
| 176 |
options is invalid. |
| 177 |
|
| 178 |
Example: |
| 179 |
|
| 180 |
Setting code CBM for a domain: |
| 181 |
`xl psr-cat-set -c <domid> <cbm>` |
| 182 |
|
| 183 |
Setting data CBM for a domain: |
| 184 |
`xl psr-cat-set -d <domid> <cbm>` |
| 185 |
|
| 186 |
Setting the same code and data CBM for a domain: |
| 187 |
`xl psr-cat-set <domid> <cbm>` |
| 188 |
|
| 189 |
## Memory Bandwidth Allocation (MBA) |
| 190 |
|
| 191 |
Memory Bandwidth Allocation (MBA) is a new feature available on Intel |
| 192 |
Skylake and later server platforms that allows an OS or Hypervisor/VMM to |
| 193 |
slow misbehaving apps/VMs by using a credit-based throttling mechanism. To |
| 194 |
enforce bandwidth on a specific domain, just set throttling value (THRTL) |
| 195 |
into Class of Service (COS). MBA provides two THRTL mode. One is linear mode |
| 196 |
and the other is non-linear mode. |
| 197 |
|
| 198 |
In the linear mode the input precision is defined as 100-(THRTL_MAX). Values |
| 199 |
not an even multiple of the precision (e.g., 12%) will be rounded down (e.g., |
| 200 |
to 10% delay by the hardware). |
| 201 |
|
| 202 |
If linear values are not supported then input delay values are powers-of-two |
| 203 |
from zero to the THRTL_MAX value from CPUID. In this case any values not a power |
| 204 |
of two will be rounded down the next nearest power of two. |
| 205 |
|
| 206 |
For example, assuming a system with 2 domains: |
| 207 |
|
| 208 |
* A THRTL of 0x0 for every domain means each domain can access the whole cache |
| 209 |
without any delay. This is the default. |
| 210 |
|
| 211 |
* Linear mode: Giving one domain a THRTL of 0xC and the other domain's 0 means |
| 212 |
that the first domain gets 10% delay to access the cache and the other one |
| 213 |
without any delay. |
| 214 |
|
| 215 |
* Non-linear mode: Giving one domain a THRTL of 0xC and the other domain's 0 |
| 216 |
means that the first domain gets 8% delay to access the cache and the other |
| 217 |
one without any delay. |
| 218 |
|
| 219 |
For more detailed information please refer to Intel SDM chapter |
| 220 |
"Introduction to Memory Bandwidth Allocation". |
| 221 |
|
| 222 |
In Xen's implementation, THRTL can be configured with libxl/xl interfaces but |
| 223 |
COS is maintained in hypervisor only. The cache partition granularity is per |
| 224 |
domain, each domain has COS=0 assigned by default, the corresponding THRTL is |
| 225 |
0, which means all the cache resource can be accessed without delay. |
| 226 |
|
| 227 |
### xl interfaces |
| 228 |
|
| 229 |
System MBA information such as maximum COS and maximum THRTL can be obtained by: |
| 230 |
|
| 231 |
`xl psr-hwinfo --mba` |
| 232 |
|
| 233 |
The simplest way to change a domain's THRTL from its default is running: |
| 234 |
|
| 235 |
`xl psr-mba-set [OPTIONS] <domid> <thrtl>` |
| 236 |
|
| 237 |
In a multi-socket system, the same thrtl will be set on each socket by default. |
| 238 |
Per socket thrtl can be specified with the `--socket SOCKET` option. |
| 239 |
|
| 240 |
Setting the THRTL may not be successful if insufficient COS is available. In |
| 241 |
such case unused COS(es) may be freed by setting THRTL of all related domains to |
| 242 |
its default value(0). |
| 243 |
|
| 244 |
Per domain THRTL settings can be shown by: |
| 245 |
|
| 246 |
`xl psr-mba-show [OPTIONS] <domid>` |
| 247 |
|
| 248 |
For linear mode, it shows the decimal value. For non-linear mode, it shows |
| 249 |
hexadecimal value. |
| 250 |
|
| 251 |
## Reference |
| 252 |
|
| 253 |
[1] Intel SDM |
| 254 |
(http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html). |