@@ -28,7 +28,8 @@ import (
28
28
*
29
29
* Memory Bandwidth Allocation (MBA) provides indirect and approximate throttle
30
30
* over memory bandwidth for the software. A user controls the resource by
31
- * indicating the percentage of maximum memory bandwidth.
31
+ * indicating the percentage of maximum memory bandwidth or memory bandwidth
32
+ * limit in MBps unit if MBA Software Controller is enabled.
32
33
*
33
34
* More details about Intel RDT CAT and MBA can be found in the section 17.18
34
35
* of Intel Software Developer Manual:
@@ -95,7 +96,7 @@ import (
95
96
*
96
97
* Memory bandwidth schema:
97
98
* It has allocation values for memory bandwidth on each socket, which contains
98
- * L3 cache id and memory bandwidth percentage .
99
+ * L3 cache id and memory bandwidth.
99
100
* Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
100
101
* For example, on a two-socket machine, the schema line could be "MB:0=20;1=70"
101
102
*
@@ -106,6 +107,18 @@ import (
106
107
* min_bw + N * bw_gran. Intermediate values are rounded to the next control
107
108
* step available on the hardware.
108
109
*
110
+ * If MBA Software Controller is enabled through mount option "-o mba_MBps":
111
+ * mount -t resctrl resctrl -o mba_MBps /sys/fs/resctrl
112
+ * We could specify memory bandwidth in "MBps" (Mega Bytes per second) unit
113
+ * instead of "percentages". The kernel underneath would use a software feedback
114
+ * mechanism or a "Software Controller" which reads the actual bandwidth using
115
+ * MBM counters and adjust the memory bandwidth percentages to ensure:
116
+ * "actual memory bandwidth < user specified memory bandwidth".
117
+ *
118
+ * For example, on a two-socket machine, the schema line could be
119
+ * "MB:0=5000;1=7000" which means 5000 MBps memory bandwidth limit on socket 0
120
+ * and 7000 MBps memory bandwidth limit on socket 1.
121
+ *
109
122
* For more information about Intel RDT kernel interface:
110
123
* https://www.kernel.org/doc/Documentation/x86/intel_rdt_ui.txt
111
124
*
@@ -165,6 +178,8 @@ var (
165
178
isCatEnabled bool
166
179
// The flag to indicate if Intel RDT/MBA is enabled
167
180
isMbaEnabled bool
181
+ // The flag to indicate if Intel RDT/MBA Software Controller is enabled
182
+ isMbaScEnabled bool
168
183
)
169
184
170
185
type intelRdtData struct {
@@ -197,7 +212,12 @@ func init() {
197
212
isCatEnabled = true
198
213
}
199
214
}
200
- if isMbaFlagSet {
215
+ if isMbaScEnabled {
216
+ // We confirm MBA Software Controller is enabled in step 2,
217
+ // MBA should be enabled because MBA Software Controller
218
+ // depends on MBA
219
+ isMbaEnabled = true
220
+ } else if isMbaFlagSet {
201
221
if _ , err := os .Stat (filepath .Join (intelRdtRoot , "info" , "MB" )); err == nil {
202
222
isMbaEnabled = true
203
223
}
@@ -232,6 +252,11 @@ func findIntelRdtMountpointDir() (string, error) {
232
252
return "" , fmt .Errorf ("Error found less than 3 fields post '-' in %q" , text )
233
253
}
234
254
255
+ // Check if MBA Software Controller is enabled through mount option "-o mba_MBps"
256
+ if strings .Contains (postSeparatorFields [2 ], "mba_MBps" ) {
257
+ isMbaScEnabled = true
258
+ }
259
+
235
260
return fields [4 ], nil
236
261
}
237
262
}
@@ -480,6 +505,11 @@ func IsMbaEnabled() bool {
480
505
return isMbaEnabled
481
506
}
482
507
508
+ // Check if Intel RDT/MBA Software Controller is enabled
509
+ func IsMbaScEnabled () bool {
510
+ return isMbaScEnabled
511
+ }
512
+
483
513
// Get the 'container_id' path in Intel RDT "resource control" filesystem
484
514
func GetIntelRdtPath (id string ) (string , error ) {
485
515
rootPath , err := getIntelRdtRoot ()
@@ -633,7 +663,7 @@ func (m *IntelRdtManager) Set(container *configs.Config) error {
633
663
//
634
664
// About memory bandwidth schema:
635
665
// It has allocation values for memory bandwidth on each socket, which
636
- // contains L3 cache id and memory bandwidth percentage .
666
+ // contains L3 cache id and memory bandwidth.
637
667
// Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
638
668
// For example, on a two-socket machine, the schema line could be:
639
669
// "MB:0=20;1=70"
@@ -645,6 +675,19 @@ func (m *IntelRdtManager) Set(container *configs.Config) error {
645
675
// The available bandwidth control steps are: min_bw + N * bw_gran.
646
676
// Intermediate values are rounded to the next control step available
647
677
// on the hardware.
678
+ //
679
+ // If MBA Software Controller is enabled through mount option
680
+ // "-o mba_MBps": mount -t resctrl resctrl -o mba_MBps /sys/fs/resctrl
681
+ // We could specify memory bandwidth in "MBps" (Mega Bytes per second)
682
+ // unit instead of "percentages". The kernel underneath would use a
683
+ // software feedback mechanism or a "Software Controller" which reads
684
+ // the actual bandwidth using MBM counters and adjust the memory
685
+ // bandwidth percentages to ensure:
686
+ // "actual memory bandwidth < user specified memory bandwidth".
687
+ //
688
+ // For example, on a two-socket machine, the schema line could be
689
+ // "MB:0=5000;1=7000" which means 5000 MBps memory bandwidth limit on
690
+ // socket 0 and 7000 MBps memory bandwidth limit on socket 1.
648
691
if container .IntelRdt != nil {
649
692
path := m .GetPath ()
650
693
l3CacheSchema := container .IntelRdt .L3CacheSchema
0 commit comments