diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-05 00:34:39 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-05 00:34:39 -0400 |
| commit | ab20fd0013cd086230bb39344918f5b6eb41c4ad (patch) | |
| tree | 1828996b036347cb7a49ae89c9ab4b8a55df4716 | |
| parent | ba252f16e4433e7599fec986e77722e6d0eed186 (diff) | |
| parent | de73f38f768021610bd305cf74ef3702fcf6a1eb (diff) | |
Merge branch 'x86-cache-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cache resource controller updates from Thomas Gleixner:
"An update for the Intel Resource Director Technolgy (RDT) which adds a
feedback driven software controller to runtime adjust the bandwidth
allocation MSRs.
This makes the allocations more accurate and allows to use bandwidth
values in understandable units (MB/s) instead of using percentage
based allocations as the original, still available, interface.
The software controller can be enabled with a new mount option for the
resctrl filesystem"
* 'x86-cache-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/intel_rdt/mba_sc: Feedback loop to dynamically update mem bandwidth
x86/intel_rdt/mba_sc: Prepare for feedback loop
x86/intel_rdt/mba_sc: Add schemata support
x86/intel_rdt/mba_sc: Add initialization support
x86/intel_rdt/mba_sc: Enable/disable MBA software controller
x86/intel_rdt/mba_sc: Documentation for MBA software controller(mba_sc)
| -rw-r--r-- | Documentation/x86/intel_rdt_ui.txt | 75 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/intel_rdt.c | 50 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/intel_rdt.h | 18 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c | 24 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/intel_rdt_monitor.c | 170 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 33 |
6 files changed, 337 insertions, 33 deletions
diff --git a/Documentation/x86/intel_rdt_ui.txt b/Documentation/x86/intel_rdt_ui.txt index 71c30984e94d..a16aa2113840 100644 --- a/Documentation/x86/intel_rdt_ui.txt +++ b/Documentation/x86/intel_rdt_ui.txt | |||
| @@ -17,12 +17,14 @@ MBA (Memory Bandwidth Allocation) - "mba" | |||
| 17 | 17 | ||
| 18 | To use the feature mount the file system: | 18 | To use the feature mount the file system: |
| 19 | 19 | ||
| 20 | # mount -t resctrl resctrl [-o cdp[,cdpl2]] /sys/fs/resctrl | 20 | # mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps]] /sys/fs/resctrl |
| 21 | 21 | ||
| 22 | mount options are: | 22 | mount options are: |
| 23 | 23 | ||
| 24 | "cdp": Enable code/data prioritization in L3 cache allocations. | 24 | "cdp": Enable code/data prioritization in L3 cache allocations. |
| 25 | "cdpl2": Enable code/data prioritization in L2 cache allocations. | 25 | "cdpl2": Enable code/data prioritization in L2 cache allocations. |
| 26 | "mba_MBps": Enable the MBA Software Controller(mba_sc) to specify MBA | ||
| 27 | bandwidth in MBps | ||
| 26 | 28 | ||
| 27 | L2 and L3 CDP are controlled seperately. | 29 | L2 and L3 CDP are controlled seperately. |
| 28 | 30 | ||
| @@ -270,10 +272,11 @@ and 0xA are not. On a system with a 20-bit mask each bit represents 5% | |||
| 270 | of the capacity of the cache. You could partition the cache into four | 272 | of the capacity of the cache. You could partition the cache into four |
| 271 | equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000. | 273 | equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000. |
| 272 | 274 | ||
| 273 | Memory bandwidth(b/w) percentage | 275 | Memory bandwidth Allocation and monitoring |
| 274 | -------------------------------- | 276 | ------------------------------------------ |
| 275 | For Memory b/w resource, user controls the resource by indicating the | 277 | |
| 276 | percentage of total memory b/w. | 278 | For Memory bandwidth resource, by default the user controls the resource |
| 279 | by indicating the percentage of total memory bandwidth. | ||
| 277 | 280 | ||
| 278 | The minimum bandwidth percentage value for each cpu model is predefined | 281 | The minimum bandwidth percentage value for each cpu model is predefined |
| 279 | and can be looked up through "info/MB/min_bandwidth". The bandwidth | 282 | and can be looked up through "info/MB/min_bandwidth". The bandwidth |
| @@ -285,7 +288,47 @@ to the next control step available on the hardware. | |||
| 285 | The bandwidth throttling is a core specific mechanism on some of Intel | 288 | The bandwidth throttling is a core specific mechanism on some of Intel |
| 286 | SKUs. Using a high bandwidth and a low bandwidth setting on two threads | 289 | SKUs. Using a high bandwidth and a low bandwidth setting on two threads |
| 287 | sharing a core will result in both threads being throttled to use the | 290 | sharing a core will result in both threads being throttled to use the |
| 288 | low bandwidth. | 291 | low bandwidth. The fact that Memory bandwidth allocation(MBA) is a core |
| 292 | specific mechanism where as memory bandwidth monitoring(MBM) is done at | ||
| 293 | the package level may lead to confusion when users try to apply control | ||
| 294 | via the MBA and then monitor the bandwidth to see if the controls are | ||
| 295 | effective. Below are such scenarios: | ||
| 296 | |||
| 297 | 1. User may *not* see increase in actual bandwidth when percentage | ||
| 298 | values are increased: | ||
| 299 | |||
| 300 | This can occur when aggregate L2 external bandwidth is more than L3 | ||
| 301 | external bandwidth. Consider an SKL SKU with 24 cores on a package and | ||
| 302 | where L2 external is 10GBps (hence aggregate L2 external bandwidth is | ||
| 303 | 240GBps) and L3 external bandwidth is 100GBps. Now a workload with '20 | ||
| 304 | threads, having 50% bandwidth, each consuming 5GBps' consumes the max L3 | ||
| 305 | bandwidth of 100GBps although the percentage value specified is only 50% | ||
| 306 | << 100%. Hence increasing the bandwidth percentage will not yeild any | ||
| 307 | more bandwidth. This is because although the L2 external bandwidth still | ||
| 308 | has capacity, the L3 external bandwidth is fully used. Also note that | ||
| 309 | this would be dependent on number of cores the benchmark is run on. | ||
| 310 | |||
| 311 | 2. Same bandwidth percentage may mean different actual bandwidth | ||
| 312 | depending on # of threads: | ||
| 313 | |||
| 314 | For the same SKU in #1, a 'single thread, with 10% bandwidth' and '4 | ||
| 315 | thread, with 10% bandwidth' can consume upto 10GBps and 40GBps although | ||
| 316 | they have same percentage bandwidth of 10%. This is simply because as | ||
| 317 | threads start using more cores in an rdtgroup, the actual bandwidth may | ||
| 318 | increase or vary although user specified bandwidth percentage is same. | ||
| 319 | |||
| 320 | In order to mitigate this and make the interface more user friendly, | ||
| 321 | resctrl added support for specifying the bandwidth in MBps as well. The | ||
| 322 | kernel underneath would use a software feedback mechanism or a "Software | ||
| 323 | Controller(mba_sc)" which reads the actual bandwidth using MBM counters | ||
| 324 | and adjust the memowy bandwidth percentages to ensure | ||
| 325 | |||
| 326 | "actual bandwidth < user specified bandwidth". | ||
| 327 | |||
| 328 | By default, the schemata would take the bandwidth percentage values | ||
| 329 | where as user can switch to the "MBA software controller" mode using | ||
| 330 | a mount option 'mba_MBps'. The schemata format is specified in the below | ||
| 331 | sections. | ||
| 289 | 332 | ||
| 290 | L3 schemata file details (code and data prioritization disabled) | 333 | L3 schemata file details (code and data prioritization disabled) |
| 291 | ---------------------------------------------------------------- | 334 | ---------------------------------------------------------------- |
| @@ -308,13 +351,20 @@ schemata format is always: | |||
| 308 | 351 | ||
| 309 | L2:<cache_id0>=<cbm>;<cache_id1>=<cbm>;... | 352 | L2:<cache_id0>=<cbm>;<cache_id1>=<cbm>;... |
| 310 | 353 | ||
| 311 | Memory b/w Allocation details | 354 | Memory bandwidth Allocation (default mode) |
| 312 | ----------------------------- | 355 | ------------------------------------------ |
| 313 | 356 | ||
| 314 | Memory b/w domain is L3 cache. | 357 | Memory b/w domain is L3 cache. |
| 315 | 358 | ||
| 316 | MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;... | 359 | MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;... |
| 317 | 360 | ||
| 361 | Memory bandwidth Allocation specified in MBps | ||
| 362 | --------------------------------------------- | ||
| 363 | |||
| 364 | Memory bandwidth domain is L3 cache. | ||
| 365 | |||
| 366 | MB:<cache_id0>=bw_MBps0;<cache_id1>=bw_MBps1;... | ||
| 367 | |||
| 318 | Reading/writing the schemata file | 368 | Reading/writing the schemata file |
| 319 | --------------------------------- | 369 | --------------------------------- |
| 320 | Reading the schemata file will show the state of all resources | 370 | Reading the schemata file will show the state of all resources |
| @@ -358,6 +408,15 @@ allocations can overlap or not. The allocations specifies the maximum | |||
| 358 | b/w that the group may be able to use and the system admin can configure | 408 | b/w that the group may be able to use and the system admin can configure |
| 359 | the b/w accordingly. | 409 | the b/w accordingly. |
| 360 | 410 | ||
| 411 | If the MBA is specified in MB(megabytes) then user can enter the max b/w in MB | ||
| 412 | rather than the percentage values. | ||
| 413 | |||
| 414 | # echo "L3:0=3;1=c\nMB:0=1024;1=500" > /sys/fs/resctrl/p0/schemata | ||
| 415 | # echo "L3:0=3;1=3\nMB:0=1024;1=500" > /sys/fs/resctrl/p1/schemata | ||
| 416 | |||
| 417 | In the above example the tasks in "p1" and "p0" on socket 0 would use a max b/w | ||
| 418 | of 1024MB where as on socket 1 they would use 500MB. | ||
| 419 | |||
| 361 | Example 2 | 420 | Example 2 |
| 362 | --------- | 421 | --------- |
| 363 | Again two sockets, but this time with a more realistic 20-bit mask. | 422 | Again two sockets, but this time with a more realistic 20-bit mask. |
diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c index 589b948e6e01..24bfa63e86cf 100644 --- a/arch/x86/kernel/cpu/intel_rdt.c +++ b/arch/x86/kernel/cpu/intel_rdt.c | |||
| @@ -33,8 +33,8 @@ | |||
| 33 | #include <asm/intel_rdt_sched.h> | 33 | #include <asm/intel_rdt_sched.h> |
| 34 | #include "intel_rdt.h" | 34 | #include "intel_rdt.h" |
| 35 | 35 | ||
| 36 | #define MAX_MBA_BW 100u | ||
| 37 | #define MBA_IS_LINEAR 0x4 | 36 | #define MBA_IS_LINEAR 0x4 |
| 37 | #define MBA_MAX_MBPS U32_MAX | ||
| 38 | 38 | ||
| 39 | /* Mutex to protect rdtgroup access. */ | 39 | /* Mutex to protect rdtgroup access. */ |
| 40 | DEFINE_MUTEX(rdtgroup_mutex); | 40 | DEFINE_MUTEX(rdtgroup_mutex); |
| @@ -178,7 +178,7 @@ struct rdt_resource rdt_resources_all[] = { | |||
| 178 | .msr_update = mba_wrmsr, | 178 | .msr_update = mba_wrmsr, |
| 179 | .cache_level = 3, | 179 | .cache_level = 3, |
| 180 | .parse_ctrlval = parse_bw, | 180 | .parse_ctrlval = parse_bw, |
| 181 | .format_str = "%d=%*d", | 181 | .format_str = "%d=%*u", |
| 182 | .fflags = RFTYPE_RES_MB, | 182 | .fflags = RFTYPE_RES_MB, |
| 183 | }, | 183 | }, |
| 184 | }; | 184 | }; |
| @@ -230,6 +230,14 @@ static inline void cache_alloc_hsw_probe(void) | |||
| 230 | rdt_alloc_capable = true; | 230 | rdt_alloc_capable = true; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | bool is_mba_sc(struct rdt_resource *r) | ||
| 234 | { | ||
| 235 | if (!r) | ||
| 236 | return rdt_resources_all[RDT_RESOURCE_MBA].membw.mba_sc; | ||
| 237 | |||
| 238 | return r->membw.mba_sc; | ||
| 239 | } | ||
| 240 | |||
| 233 | /* | 241 | /* |
| 234 | * rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values | 242 | * rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values |
| 235 | * exposed to user interface and the h/w understandable delay values. | 243 | * exposed to user interface and the h/w understandable delay values. |
| @@ -341,7 +349,7 @@ static int get_cache_id(int cpu, int level) | |||
| 341 | * that can be written to QOS_MSRs. | 349 | * that can be written to QOS_MSRs. |
| 342 | * There are currently no SKUs which support non linear delay values. | 350 | * There are currently no SKUs which support non linear delay values. |
| 343 | */ | 351< | |
