aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-05 00:34:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-05 00:34:39 -0400
commitab20fd0013cd086230bb39344918f5b6eb41c4ad (patch)
tree1828996b036347cb7a49ae89c9ab4b8a55df4716
parentba252f16e4433e7599fec986e77722e6d0eed186 (diff)
parentde73f38f768021610bd305cf74ef3702fcf6a1eb (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.txt75
-rw-r--r--arch/x86/kernel/cpu/intel_rdt.c50
-rw-r--r--arch/x86/kernel/cpu/intel_rdt.h18
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_ctrlmondata.c24
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_monitor.c170
-rw-r--r--arch/x86/kernel/cpu/intel_rdt_rdtgroup.c33
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
18To use the feature mount the file system: 18To 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
22mount options are: 22mount 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
27L2 and L3 CDP are controlled seperately. 29L2 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%
270of the capacity of the cache. You could partition the cache into four 272of the capacity of the cache. You could partition the cache into four
271equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000. 273equal parts with masks: 0x1f, 0x3e0, 0x7c00, 0xf8000.
272 274
273Memory bandwidth(b/w) percentage 275Memory bandwidth Allocation and monitoring
274-------------------------------- 276------------------------------------------
275For Memory b/w resource, user controls the resource by indicating the 277
276percentage of total memory b/w. 278For Memory bandwidth resource, by default the user controls the resource
279by indicating the percentage of total memory bandwidth.
277 280
278The minimum bandwidth percentage value for each cpu model is predefined 281The minimum bandwidth percentage value for each cpu model is predefined
279and can be looked up through "info/MB/min_bandwidth". The bandwidth 282and can be looked up through "info/MB/min_bandwidth". The bandwidth
@@ -285,7 +288,47 @@ to the next control step available on the hardware.
285The bandwidth throttling is a core specific mechanism on some of Intel 288The bandwidth throttling is a core specific mechanism on some of Intel
286SKUs. Using a high bandwidth and a low bandwidth setting on two threads 289SKUs. Using a high bandwidth and a low bandwidth setting on two threads
287sharing a core will result in both threads being throttled to use the 290sharing a core will result in both threads being throttled to use the
288low bandwidth. 291low bandwidth. The fact that Memory bandwidth allocation(MBA) is a core
292specific mechanism where as memory bandwidth monitoring(MBM) is done at
293the package level may lead to confusion when users try to apply control
294via the MBA and then monitor the bandwidth to see if the controls are
295effective. Below are such scenarios:
296
2971. User may *not* see increase in actual bandwidth when percentage
298 values are increased:
299
300This can occur when aggregate L2 external bandwidth is more than L3
301external bandwidth. Consider an SKL SKU with 24 cores on a package and
302where L2 external is 10GBps (hence aggregate L2 external bandwidth is
303240GBps) and L3 external bandwidth is 100GBps. Now a workload with '20
304threads, having 50% bandwidth, each consuming 5GBps' consumes the max L3
305bandwidth of 100GBps although the percentage value specified is only 50%
306<< 100%. Hence increasing the bandwidth percentage will not yeild any
307more bandwidth. This is because although the L2 external bandwidth still
308has capacity, the L3 external bandwidth is fully used. Also note that
309this would be dependent on number of cores the benchmark is run on.
310
3112. Same bandwidth percentage may mean different actual bandwidth
312 depending on # of threads:
313
314For the same SKU in #1, a 'single thread, with 10% bandwidth' and '4
315thread, with 10% bandwidth' can consume upto 10GBps and 40GBps although
316they have same percentage bandwidth of 10%. This is simply because as
317threads start using more cores in an rdtgroup, the actual bandwidth may
318increase or vary although user specified bandwidth percentage is same.
319
320In order to mitigate this and make the interface more user friendly,
321resctrl added support for specifying the bandwidth in MBps as well. The
322kernel underneath would use a software feedback mechanism or a "Software
323Controller(mba_sc)" which reads the actual bandwidth using MBM counters
324and adjust the memowy bandwidth percentages to ensure
325
326 "actual bandwidth < user specified bandwidth".
327
328By default, the schemata would take the bandwidth percentage values
329where as user can switch to the "MBA software controller" mode using
330a mount option 'mba_MBps'. The schemata format is specified in the below
331sections.
289 332
290L3 schemata file details (code and data prioritization disabled) 333L3 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
311Memory b/w Allocation details 354Memory bandwidth Allocation (default mode)
312----------------------------- 355------------------------------------------
313 356
314Memory b/w domain is L3 cache. 357Memory 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
361Memory bandwidth Allocation specified in MBps
362---------------------------------------------
363
364Memory bandwidth domain is L3 cache.
365
366 MB:<cache_id0>=bw_MBps0;<cache_id1>=bw_MBps1;...
367
318Reading/writing the schemata file 368Reading/writing the schemata file
319--------------------------------- 369---------------------------------
320Reading the schemata file will show the state of all resources 370Reading the schemata file will show the state of all resources
@@ -358,6 +408,15 @@ allocations can overlap or not. The allocations specifies the maximum
358b/w that the group may be able to use and the system admin can configure 408b/w that the group may be able to use and the system admin can configure
359the b/w accordingly. 409the b/w accordingly.
360 410
411If the MBA is specified in MB(megabytes) then user can enter the max b/w in MB
412rather 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
417In the above example the tasks in "p1" and "p0" on socket 0 would use a max b/w
418of 1024MB where as on socket 1 they would use 500MB.
419
361Example 2 420Example 2
362--------- 421---------
363Again two sockets, but this time with a more realistic 20-bit mask. 422Again 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. */
40DEFINE_MUTEX(rdtgroup_mutex); 40DEFINE_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
233bool 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<